@@ -57,7 +57,7 @@ |
||
57 | 57 | * |
58 | 58 | * @param string|null $foreground The style foreground color name |
59 | 59 | * @param string|null $background The style background color name |
60 | - * @param array $options The style options |
|
60 | + * @param string[] $options The style options |
|
61 | 61 | * |
62 | 62 | * @api |
63 | 63 | */ |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | * Asks the user to select a value. |
33 | 33 | * |
34 | 34 | * @param OutputInterface $output An Output instance |
35 | - * @param string|array $question The question to ask |
|
36 | - * @param array $choices List of choices to pick from |
|
35 | + * @param string $question The question to ask |
|
36 | + * @param string[] $choices List of choices to pick from |
|
37 | 37 | * @param bool|string $default The default answer if the user enters nothing |
38 | 38 | * @param bool|int $attempts Max number of times to ask before giving up (false by default, which means infinite) |
39 | 39 | * @param string $errorMessage Message which will be shown if invalid value from choice list would be picked |
40 | 40 | * @param bool $multiselect Select more than one value separated by comma |
41 | 41 | * |
42 | - * @return int|string|array The selected value or values (the key of the choices array) |
|
42 | + * @return string The selected value or values (the key of the choices array) |
|
43 | 43 | * |
44 | 44 | * @throws \InvalidArgumentException |
45 | 45 | */ |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * The question will be asked until the user answers by nothing, yes, or no. |
231 | 231 | * |
232 | 232 | * @param OutputInterface $output An Output instance |
233 | - * @param string|array $question The question to ask |
|
233 | + * @param string $question The question to ask |
|
234 | 234 | * @param bool $default The default answer if the user enters nothing |
235 | 235 | * |
236 | 236 | * @return bool true if the user has confirmed, false otherwise |
@@ -327,13 +327,13 @@ discard block |
||
327 | 327 | * otherwise. |
328 | 328 | * |
329 | 329 | * @param OutputInterface $output An Output instance |
330 | - * @param string|array $question The question to ask |
|
330 | + * @param string $question The question to ask |
|
331 | 331 | * @param callable $validator A PHP callback |
332 | 332 | * @param int|false $attempts Max number of times to ask before giving up (false by default, which means infinite) |
333 | 333 | * @param string $default The default answer if none is given by the user |
334 | 334 | * @param array $autocomplete List of values to autocomplete |
335 | 335 | * |
336 | - * @return mixed |
|
336 | + * @return string |
|
337 | 337 | * |
338 | 338 | * @throws \Exception When any of the validators return an error |
339 | 339 | */ |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | /** |
393 | 393 | * Returns the helper's input stream. |
394 | 394 | * |
395 | - * @return string |
|
395 | + * @return resource |
|
396 | 396 | */ |
397 | 397 | public function getInputStream() |
398 | 398 | { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | $output->writeln($messages); |
56 | 56 | |
57 | - $result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) { |
|
57 | + $result = $this->askAndValidate($output, '> ', function($picked) use ($choices, $errorMessage, $multiselect) { |
|
58 | 58 | // Collapse all spaces. |
59 | 59 | $selectedChoices = str_replace(' ', '', $picked); |
60 | 60 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | // Save cursor position |
212 | 212 | $output->write("\0337"); |
213 | 213 | // Write highlighted text |
214 | - $output->write('<hl>'.substr($matches[$ofs], $i).'</hl>'); |
|
214 | + $output->write('<hl>' . substr($matches[$ofs], $i) . '</hl>'); |
|
215 | 215 | // Restore cursor position |
216 | 216 | $output->write("\0338"); |
217 | 217 | } |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | public function askHiddenResponse(OutputInterface $output, $question, $fallback = true) |
264 | 264 | { |
265 | 265 | if ('\\' === DIRECTORY_SEPARATOR) { |
266 | - $exe = __DIR__.'/../Resources/bin/hiddeninput.exe'; |
|
266 | + $exe = __DIR__ . '/../Resources/bin/hiddeninput.exe'; |
|
267 | 267 | |
268 | 268 | // handle code running from a phar |
269 | 269 | if ('phar:' === substr(__FILE__, 0, 5)) { |
270 | - $tmpExe = sys_get_temp_dir().'/hiddeninput.exe'; |
|
270 | + $tmpExe = sys_get_temp_dir() . '/hiddeninput.exe'; |
|
271 | 271 | copy($exe, $tmpExe); |
272 | 272 | $exe = $tmpExe; |
273 | 273 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | { |
342 | 342 | $that = $this; |
343 | 343 | |
344 | - $interviewer = function () use ($output, $question, $default, $autocomplete, $that) { |
|
344 | + $interviewer = function() use ($output, $question, $default, $autocomplete, $that) { |
|
345 | 345 | return $that->ask($output, $question, $default, $autocomplete); |
346 | 346 | }; |
347 | 347 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | { |
371 | 371 | $that = $this; |
372 | 372 | |
373 | - $interviewer = function () use ($output, $question, $fallback, $that) { |
|
373 | + $interviewer = function() use ($output, $question, $fallback, $that) { |
|
374 | 374 | return $that->askHiddenResponse($output, $question, $fallback); |
375 | 375 | }; |
376 | 376 |
@@ -105,7 +105,7 @@ |
||
105 | 105 | * @param Process $process The Process |
106 | 106 | * @param callable|null $callback A PHP callable |
107 | 107 | * |
108 | - * @return callable |
|
108 | + * @return \Closure |
|
109 | 109 | */ |
110 | 110 | public function wrapCallback(OutputInterface $output, Process $process, $callback = null) |
111 | 111 | { |
@@ -113,7 +113,7 @@ |
||
113 | 113 | |
114 | 114 | $that = $this; |
115 | 115 | |
116 | - return function ($type, $buffer) use ($output, $process, $callback, $formatter, $that) { |
|
116 | + return function($type, $buffer) use ($output, $process, $callback, $formatter, $that) { |
|
117 | 117 | $output->write($formatter->progress(spl_object_hash($process), $that->escapeString($buffer), Process::ERR === $type)); |
118 | 118 | |
119 | 119 | if (null !== $callback) { |
@@ -138,6 +138,9 @@ discard block |
||
138 | 138 | return isset(self::$formats[$name]) ? self::$formats[$name] : null; |
139 | 139 | } |
140 | 140 | |
141 | + /** |
|
142 | + * @param string $message |
|
143 | + */ |
|
141 | 144 | public function setMessage($message, $name = 'message') |
142 | 145 | { |
143 | 146 | $this->messages[$name] = $message; |
@@ -473,6 +476,7 @@ discard block |
||
473 | 476 | * Sets the progress bar maximal steps. |
474 | 477 | * |
475 | 478 | * @param int The progress bar max steps |
479 | + * @param integer $max |
|
476 | 480 | */ |
477 | 481 | private function setMaxSteps($max) |
478 | 482 | { |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | public function setFormat($format) |
305 | 305 | { |
306 | 306 | // try to use the _nomax variant if available |
307 | - if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) { |
|
308 | - $this->format = self::getFormatDefinition($format.'_nomax'); |
|
307 | + if (!$this->max && null !== self::getFormatDefinition($format . '_nomax')) { |
|
308 | + $this->format = self::getFormatDefinition($format . '_nomax'); |
|
309 | 309 | } elseif (null !== self::getFormatDefinition($format)) { |
310 | 310 | $this->format = self::getFormatDefinition($format); |
311 | 311 | } else { |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | $self = $this; |
437 | 437 | $output = $this->output; |
438 | 438 | $messages = $this->messages; |
439 | - $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self, $output, $messages) { |
|
439 | + $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function($matches) use ($self, $output, $messages) { |
|
440 | 440 | if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) { |
441 | 441 | $text = call_user_func($formatter, $self, $output); |
442 | 442 | } elseif (isset($messages[$matches[1]])) { |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | } |
447 | 447 | |
448 | 448 | if (isset($matches[2])) { |
449 | - $text = sprintf('%'.$matches[2], $text); |
|
449 | + $text = sprintf('%' . $matches[2], $text); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | return $text; |
@@ -538,20 +538,20 @@ discard block |
||
538 | 538 | private static function initPlaceholderFormatters() |
539 | 539 | { |
540 | 540 | return array( |
541 | - 'bar' => function (ProgressBar $bar, OutputInterface $output) { |
|
541 | + 'bar' => function(ProgressBar $bar, OutputInterface $output) { |
|
542 | 542 | $completeBars = floor($bar->getMaxSteps() > 0 ? $bar->getProgressPercent() * $bar->getBarWidth() : $bar->getProgress() % $bar->getBarWidth()); |
543 | 543 | $display = str_repeat($bar->getBarCharacter(), $completeBars); |
544 | 544 | if ($completeBars < $bar->getBarWidth()) { |
545 | 545 | $emptyBars = $bar->getBarWidth() - $completeBars - Helper::strlenWithoutDecoration($output->getFormatter(), $bar->getProgressCharacter()); |
546 | - $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars); |
|
546 | + $display .= $bar->getProgressCharacter() . str_repeat($bar->getEmptyBarCharacter(), $emptyBars); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | return $display; |
550 | 550 | }, |
551 | - 'elapsed' => function (ProgressBar $bar) { |
|
551 | + 'elapsed' => function(ProgressBar $bar) { |
|
552 | 552 | return Helper::formatTime(time() - $bar->getStartTime()); |
553 | 553 | }, |
554 | - 'remaining' => function (ProgressBar $bar) { |
|
554 | + 'remaining' => function(ProgressBar $bar) { |
|
555 | 555 | if (!$bar->getMaxSteps()) { |
556 | 556 | throw new \LogicException('Unable to display the remaining time if the maximum number of steps is not set.'); |
557 | 557 | } |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | |
565 | 565 | return Helper::formatTime($remaining); |
566 | 566 | }, |
567 | - 'estimated' => function (ProgressBar $bar) { |
|
567 | + 'estimated' => function(ProgressBar $bar) { |
|
568 | 568 | if (!$bar->getMaxSteps()) { |
569 | 569 | throw new \LogicException('Unable to display the estimated time if the maximum number of steps is not set.'); |
570 | 570 | } |
@@ -577,16 +577,16 @@ discard block |
||
577 | 577 | |
578 | 578 | return Helper::formatTime($estimated); |
579 | 579 | }, |
580 | - 'memory' => function (ProgressBar $bar) { |
|
580 | + 'memory' => function(ProgressBar $bar) { |
|
581 | 581 | return Helper::formatMemory(memory_get_usage(true)); |
582 | 582 | }, |
583 | - 'current' => function (ProgressBar $bar) { |
|
583 | + 'current' => function(ProgressBar $bar) { |
|
584 | 584 | return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT); |
585 | 585 | }, |
586 | - 'max' => function (ProgressBar $bar) { |
|
586 | + 'max' => function(ProgressBar $bar) { |
|
587 | 587 | return $bar->getMaxSteps(); |
588 | 588 | }, |
589 | - 'percent' => function (ProgressBar $bar) { |
|
589 | + 'percent' => function(ProgressBar $bar) { |
|
590 | 590 | return floor($bar->getProgressPercent() * 100); |
591 | 591 | }, |
592 | 592 | ); |
@@ -49,6 +49,9 @@ |
||
49 | 49 | require_once self::$fixturesPath.'/FooSubnamespaced2Command.php'; |
50 | 50 | } |
51 | 51 | |
52 | + /** |
|
53 | + * @param string $text |
|
54 | + */ |
|
52 | 55 | protected function normalizeLineBreaks($text) |
53 | 56 | { |
54 | 57 | return str_replace(PHP_EOL, "\n", $text); |
@@ -708,8 +708,8 @@ discard block |
||
708 | 708 | $application = $this->getMock('Symfony\Component\Console\Application', array('doRun')); |
709 | 709 | $application->setAutoExit(false); |
710 | 710 | $application->expects($this->once()) |
711 | - ->method('doRun') |
|
712 | - ->will($this->throwException($exception)); |
|
711 | + ->method('doRun') |
|
712 | + ->will($this->throwException($exception)); |
|
713 | 713 | |
714 | 714 | $exitCode = $application->run(new ArrayInput(array()), new NullOutput()); |
715 | 715 | |
@@ -723,8 +723,8 @@ discard block |
||
723 | 723 | $application = $this->getMock('Symfony\Component\Console\Application', array('doRun')); |
724 | 724 | $application->setAutoExit(false); |
725 | 725 | $application->expects($this->once()) |
726 | - ->method('doRun') |
|
727 | - ->will($this->throwException($exception)); |
|
726 | + ->method('doRun') |
|
727 | + ->will($this->throwException($exception)); |
|
728 | 728 | |
729 | 729 | $exitCode = $application->run(new ArrayInput(array()), new NullOutput()); |
730 | 730 |
@@ -36,17 +36,17 @@ discard block |
||
36 | 36 | |
37 | 37 | public static function setUpBeforeClass() |
38 | 38 | { |
39 | - self::$fixturesPath = realpath(__DIR__.'/Fixtures/'); |
|
40 | - require_once self::$fixturesPath.'/FooCommand.php'; |
|
41 | - require_once self::$fixturesPath.'/Foo1Command.php'; |
|
42 | - require_once self::$fixturesPath.'/Foo2Command.php'; |
|
43 | - require_once self::$fixturesPath.'/Foo3Command.php'; |
|
44 | - require_once self::$fixturesPath.'/Foo4Command.php'; |
|
45 | - require_once self::$fixturesPath.'/Foo5Command.php'; |
|
46 | - require_once self::$fixturesPath.'/FoobarCommand.php'; |
|
47 | - require_once self::$fixturesPath.'/BarBucCommand.php'; |
|
48 | - require_once self::$fixturesPath.'/FooSubnamespaced1Command.php'; |
|
49 | - require_once self::$fixturesPath.'/FooSubnamespaced2Command.php'; |
|
39 | + self::$fixturesPath = realpath(__DIR__ . '/Fixtures/'); |
|
40 | + require_once self::$fixturesPath . '/FooCommand.php'; |
|
41 | + require_once self::$fixturesPath . '/Foo1Command.php'; |
|
42 | + require_once self::$fixturesPath . '/Foo2Command.php'; |
|
43 | + require_once self::$fixturesPath . '/Foo3Command.php'; |
|
44 | + require_once self::$fixturesPath . '/Foo4Command.php'; |
|
45 | + require_once self::$fixturesPath . '/Foo5Command.php'; |
|
46 | + require_once self::$fixturesPath . '/FoobarCommand.php'; |
|
47 | + require_once self::$fixturesPath . '/BarBucCommand.php'; |
|
48 | + require_once self::$fixturesPath . '/FooSubnamespaced1Command.php'; |
|
49 | + require_once self::$fixturesPath . '/FooSubnamespaced2Command.php'; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | protected function normalizeLineBreaks($text) |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | public function testHelp() |
98 | 98 | { |
99 | 99 | $application = new Application(); |
100 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_gethelp.txt', $this->normalizeLineBreaks($application->getHelp()), '->getHelp() returns a help message'); |
|
100 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_gethelp.txt', $this->normalizeLineBreaks($application->getHelp()), '->getHelp() returns a help message'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | public function testAll() |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | |
479 | 479 | $application->setCatchExceptions(true); |
480 | 480 | $tester->run(array('command' => 'foo'), array('decorated' => false)); |
481 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getDisplay(true), '->setCatchExceptions() sets the catch exception flag'); |
|
481 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception1.txt', $tester->getDisplay(true), '->setCatchExceptions() sets the catch exception flag'); |
|
482 | 482 | |
483 | 483 | $application->setCatchExceptions(false); |
484 | 484 | try { |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | $application = new Application(); |
501 | 501 | $application->add(new \FooCommand()); |
502 | 502 | $this->ensureStaticCommandHelp($application); |
503 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_astext1.txt', $this->normalizeLineBreaks($application->asText()), '->asText() returns a text representation of the application'); |
|
504 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_astext2.txt', $this->normalizeLineBreaks($application->asText('foo')), '->asText() returns a text representation of the application'); |
|
503 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_astext1.txt', $this->normalizeLineBreaks($application->asText()), '->asText() returns a text representation of the application'); |
|
504 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_astext2.txt', $this->normalizeLineBreaks($application->asText('foo')), '->asText() returns a text representation of the application'); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | /** |
@@ -514,8 +514,8 @@ discard block |
||
514 | 514 | $application = new Application(); |
515 | 515 | $application->add(new \FooCommand()); |
516 | 516 | $this->ensureStaticCommandHelp($application); |
517 | - $this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml1.txt', $application->asXml(), '->asXml() returns an XML representation of the application'); |
|
518 | - $this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml2.txt', $application->asXml('foo'), '->asXml() returns an XML representation of the application'); |
|
517 | + $this->assertXmlStringEqualsXmlFile(self::$fixturesPath . '/application_asxml1.txt', $application->asXml(), '->asXml() returns an XML representation of the application'); |
|
518 | + $this->assertXmlStringEqualsXmlFile(self::$fixturesPath . '/application_asxml2.txt', $application->asXml('foo'), '->asXml() returns an XML representation of the application'); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | public function testRenderException() |
@@ -528,21 +528,21 @@ discard block |
||
528 | 528 | $tester = new ApplicationTester($application); |
529 | 529 | |
530 | 530 | $tester->run(array('command' => 'foo'), array('decorated' => false)); |
531 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getDisplay(true), '->renderException() renders a pretty exception'); |
|
531 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception1.txt', $tester->getDisplay(true), '->renderException() renders a pretty exception'); |
|
532 | 532 | |
533 | 533 | $tester->run(array('command' => 'foo'), array('decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE)); |
534 | 534 | $this->assertContains('Exception trace', $tester->getDisplay(), '->renderException() renders a pretty exception with a stack trace when verbosity is verbose'); |
535 | 535 | |
536 | 536 | $tester->run(array('command' => 'list', '--foo' => true), array('decorated' => false)); |
537 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception2.txt', $tester->getDisplay(true), '->renderException() renders the command synopsis when an exception occurs in the context of a command'); |
|
537 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception2.txt', $tester->getDisplay(true), '->renderException() renders the command synopsis when an exception occurs in the context of a command'); |
|
538 | 538 | |
539 | 539 | $application->add(new \Foo3Command()); |
540 | 540 | $tester = new ApplicationTester($application); |
541 | 541 | $tester->run(array('command' => 'foo3:bar'), array('decorated' => false)); |
542 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
542 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception3.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
543 | 543 | |
544 | 544 | $tester->run(array('command' => 'foo3:bar'), array('decorated' => true)); |
545 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
545 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception3decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
546 | 546 | |
547 | 547 | $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); |
548 | 548 | $application->setAutoExit(false); |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | $tester = new ApplicationTester($application); |
553 | 553 | |
554 | 554 | $tester->run(array('command' => 'foo'), array('decorated' => false)); |
555 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception4.txt', $tester->getDisplay(true), '->renderException() wraps messages when they are bigger than the terminal'); |
|
555 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception4.txt', $tester->getDisplay(true), '->renderException() wraps messages when they are bigger than the terminal'); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | public function testRenderExceptionWithDoubleWidthCharacters() |
@@ -562,28 +562,28 @@ discard block |
||
562 | 562 | $application->expects($this->any()) |
563 | 563 | ->method('getTerminalWidth') |
564 | 564 | ->will($this->returnValue(120)); |
565 | - $application->register('foo')->setCode(function () { |
|
565 | + $application->register('foo')->setCode(function() { |
|
566 | 566 | throw new \Exception('エラーメッセージ'); |
567 | 567 | }); |
568 | 568 | $tester = new ApplicationTester($application); |
569 | 569 | |
570 | 570 | $tester->run(array('command' => 'foo'), array('decorated' => false)); |
571 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth1.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
571 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception_doublewidth1.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
572 | 572 | |
573 | 573 | $tester->run(array('command' => 'foo'), array('decorated' => true)); |
574 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth1decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
574 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception_doublewidth1decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
575 | 575 | |
576 | 576 | $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); |
577 | 577 | $application->setAutoExit(false); |
578 | 578 | $application->expects($this->any()) |
579 | 579 | ->method('getTerminalWidth') |
580 | 580 | ->will($this->returnValue(32)); |
581 | - $application->register('foo')->setCode(function () { |
|
581 | + $application->register('foo')->setCode(function() { |
|
582 | 582 | throw new \Exception('コマンドの実行中にエラーが発生しました。'); |
583 | 583 | }); |
584 | 584 | $tester = new ApplicationTester($application); |
585 | 585 | $tester->run(array('command' => 'foo'), array('decorated' => false)); |
586 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth2.txt', $tester->getDisplay(true), '->renderException() wraps messages when they are bigger than the terminal'); |
|
586 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception_doublewidth2.txt', $tester->getDisplay(true), '->renderException() wraps messages when they are bigger than the terminal'); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | public function testRun() |
@@ -609,19 +609,19 @@ discard block |
||
609 | 609 | $tester = new ApplicationTester($application); |
610 | 610 | |
611 | 611 | $tester->run(array(), array('decorated' => false)); |
612 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_run1.txt', $tester->getDisplay(true), '->run() runs the list command if no argument is passed'); |
|
612 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_run1.txt', $tester->getDisplay(true), '->run() runs the list command if no argument is passed'); |
|
613 | 613 | |
614 | 614 | $tester->run(array('--help' => true), array('decorated' => false)); |
615 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if --help is passed'); |
|
615 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if --help is passed'); |
|
616 | 616 | |
617 | 617 | $tester->run(array('-h' => true), array('decorated' => false)); |
618 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if -h is passed'); |
|
618 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if -h is passed'); |
|
619 | 619 | |
620 | 620 | $tester->run(array('command' => 'list', '--help' => true), array('decorated' => false)); |
621 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if --help is passed'); |
|
621 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if --help is passed'); |
|
622 | 622 | |
623 | 623 | $tester->run(array('command' => 'list', '-h' => true), array('decorated' => false)); |
624 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if -h is passed'); |
|
624 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if -h is passed'); |
|
625 | 625 | |
626 | 626 | $tester->run(array('--ansi' => true)); |
627 | 627 | $this->assertTrue($tester->getOutput()->isDecorated(), '->run() forces color output if --ansi is passed'); |
@@ -630,10 +630,10 @@ discard block |
||
630 | 630 | $this->assertFalse($tester->getOutput()->isDecorated(), '->run() forces color output to be disabled if --no-ansi is passed'); |
631 | 631 | |
632 | 632 | $tester->run(array('--version' => true), array('decorated' => false)); |
633 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if --version is passed'); |
|
633 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if --version is passed'); |
|
634 | 634 | |
635 | 635 | $tester->run(array('-V' => true), array('decorated' => false)); |
636 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if -v is passed'); |
|
636 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if -v is passed'); |
|
637 | 637 | |
638 | 638 | $tester->run(array('command' => 'list', '--quiet' => true)); |
639 | 639 | $this->assertSame('', $tester->getDisplay(), '->run() removes all output if --quiet is passed'); |
@@ -672,10 +672,10 @@ discard block |
||
672 | 672 | $tester = new ApplicationTester($application); |
673 | 673 | |
674 | 674 | $tester->run(array('command' => 'foo:bar', '--no-interaction' => true), array('decorated' => false)); |
675 | - $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed'); |
|
675 | + $this->assertSame('called' . PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed'); |
|
676 | 676 | |
677 | 677 | $tester->run(array('command' => 'foo:bar', '-n' => true), array('decorated' => false)); |
678 | - $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed'); |
|
678 | + $this->assertSame('called' . PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed'); |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | /** |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | $application |
744 | 744 | ->register('foo') |
745 | 745 | ->setDefinition(array($def)) |
746 | - ->setCode(function (InputInterface $input, OutputInterface $output) {}) |
|
746 | + ->setCode(function(InputInterface $input, OutputInterface $output) {}) |
|
747 | 747 | ; |
748 | 748 | |
749 | 749 | $input = new ArrayInput(array('command' => 'foo')); |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | $application->setAutoExit(false); |
879 | 879 | $application->setDispatcher($this->getDispatcher()); |
880 | 880 | |
881 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
881 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output) { |
|
882 | 882 | $output->write('foo.'); |
883 | 883 | }); |
884 | 884 | |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | $application->setAutoExit(false); |
899 | 899 | $application->setCatchExceptions(false); |
900 | 900 | |
901 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
901 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output) { |
|
902 | 902 | throw new \RuntimeException('foo'); |
903 | 903 | }); |
904 | 904 | |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | $application->setDispatcher($this->getDispatcher()); |
913 | 913 | $application->setAutoExit(false); |
914 | 914 | |
915 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
915 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output) { |
|
916 | 916 | $output->write('foo.'); |
917 | 917 | |
918 | 918 | throw new \RuntimeException('foo'); |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | $application->setDispatcher($this->getDispatcher(true)); |
930 | 930 | $application->setAutoExit(false); |
931 | 931 | |
932 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
932 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output) { |
|
933 | 933 | $output->write('foo.'); |
934 | 934 | }); |
935 | 935 | |
@@ -957,21 +957,21 @@ discard block |
||
957 | 957 | protected function getDispatcher($skipCommand = false) |
958 | 958 | { |
959 | 959 | $dispatcher = new EventDispatcher(); |
960 | - $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use ($skipCommand) { |
|
960 | + $dispatcher->addListener('console.command', function(ConsoleCommandEvent $event) use ($skipCommand) { |
|
961 | 961 | $event->getOutput()->write('before.'); |
962 | 962 | |
963 | 963 | if ($skipCommand) { |
964 | 964 | $event->disableCommand(); |
965 | 965 | } |
966 | 966 | }); |
967 | - $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand) { |
|
967 | + $dispatcher->addListener('console.terminate', function(ConsoleTerminateEvent $event) use ($skipCommand) { |
|
968 | 968 | $event->getOutput()->write('after.'); |
969 | 969 | |
970 | 970 | if (!$skipCommand) { |
971 | 971 | $event->setExitCode(113); |
972 | 972 | } |
973 | 973 | }); |
974 | - $dispatcher->addListener('console.exception', function (ConsoleExceptionEvent $event) { |
|
974 | + $dispatcher->addListener('console.exception', function(ConsoleExceptionEvent $event) { |
|
975 | 975 | $event->getOutput()->writeln('caught.'); |
976 | 976 | |
977 | 977 | $event->setException(new \LogicException('caught.', $event->getExitCode(), $event->getException())); |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | |
992 | 992 | $tester = new ApplicationTester($application); |
993 | 993 | $tester->run(array()); |
994 | - $this->assertEquals('interact called'.PHP_EOL.'called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); |
|
994 | + $this->assertEquals('interact called' . PHP_EOL . 'called' . PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); |
|
995 | 995 | |
996 | 996 | $application = new CustomDefaultCommandApplication(); |
997 | 997 | $application->setAutoExit(false); |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | $tester = new ApplicationTester($application); |
1000 | 1000 | $tester->run(array()); |
1001 | 1001 | |
1002 | - $this->assertEquals('interact called'.PHP_EOL.'called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); |
|
1002 | + $this->assertEquals('interact called' . PHP_EOL . 'called' . PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | public function testCanCheckIfTerminalIsInteractive() |
@@ -177,6 +177,9 @@ |
||
177 | 177 | $this->assertEquals('not yet', $dialog->ask($this->getOutputStream(), 'Do you have a job?', 'not yet')); |
178 | 178 | } |
179 | 179 | |
180 | + /** |
|
181 | + * @param string $input |
|
182 | + */ |
|
180 | 183 | protected function getInputStream($input) |
181 | 184 | { |
182 | 185 | $stream = fopen('php://memory', 'r+', false); |
@@ -173,7 +173,7 @@ |
||
173 | 173 | $dialog->setHelperSet($helperSet); |
174 | 174 | |
175 | 175 | $error = 'This is not a color!'; |
176 | - $validator = function ($color) use ($error) { |
|
176 | + $validator = function($color) use ($error) { |
|
177 | 177 | if (!in_array($color, array('white', 'black'))) { |
178 | 178 | throw new \InvalidArgumentException($error); |
179 | 179 | } |
@@ -589,6 +589,9 @@ |
||
589 | 589 | return new StreamOutput(fopen('php://memory', 'r+', false), $verbosity, $decorated); |
590 | 590 | } |
591 | 591 | |
592 | + /** |
|
593 | + * @param string $expected |
|
594 | + */ |
|
592 | 595 | protected function generateOutput($expected) |
593 | 596 | { |
594 | 597 | $count = substr_count($expected, "\n"); |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | |
27 | 27 | rewind($output->getStream()); |
28 | 28 | $this->assertEquals( |
29 | - $this->generateOutput(' 0 [>---------------------------]'). |
|
30 | - $this->generateOutput(' 1 [->--------------------------]'). |
|
29 | + $this->generateOutput(' 0 [>---------------------------]') . |
|
30 | + $this->generateOutput(' 1 [->--------------------------]') . |
|
31 | 31 | $this->generateOutput(' 0 [>---------------------------]'), |
32 | 32 | stream_get_contents($output->getStream()) |
33 | 33 | ); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | rewind($output->getStream()); |
43 | 43 | $this->assertEquals( |
44 | - $this->generateOutput(' 0 [>---------------------------]'). |
|
44 | + $this->generateOutput(' 0 [>---------------------------]') . |
|
45 | 45 | $this->generateOutput(' 1 [->--------------------------]'), |
46 | 46 | stream_get_contents($output->getStream()) |
47 | 47 | ); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | rewind($output->getStream()); |
57 | 57 | $this->assertEquals( |
58 | - $this->generateOutput(' 0 [>---------------------------]'). |
|
58 | + $this->generateOutput(' 0 [>---------------------------]') . |
|
59 | 59 | $this->generateOutput(' 5 [----->----------------------]'), |
60 | 60 | stream_get_contents($output->getStream()) |
61 | 61 | ); |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | |
71 | 71 | rewind($output->getStream()); |
72 | 72 | $this->assertEquals( |
73 | - $this->generateOutput(' 0 [>---------------------------]'). |
|
74 | - $this->generateOutput(' 3 [--->------------------------]'). |
|
73 | + $this->generateOutput(' 0 [>---------------------------]') . |
|
74 | + $this->generateOutput(' 3 [--->------------------------]') . |
|
75 | 75 | $this->generateOutput(' 5 [----->----------------------]'), |
76 | 76 | stream_get_contents($output->getStream()) |
77 | 77 | ); |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | |
87 | 87 | rewind($output->getStream()); |
88 | 88 | $this->assertEquals( |
89 | - $this->generateOutput(' 9/10 [=========================>--] 90%'). |
|
90 | - $this->generateOutput(' 10/10 [============================] 100%'). |
|
89 | + $this->generateOutput(' 9/10 [=========================>--] 90%') . |
|
90 | + $this->generateOutput(' 10/10 [============================] 100%') . |
|
91 | 91 | $this->generateOutput(' 11/11 [============================] 100%'), |
92 | 92 | stream_get_contents($output->getStream()) |
93 | 93 | ); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | rewind($output->getStream()); |
108 | 108 | $this->assertEquals( |
109 | - $this->generateOutput(' 0/10 [/ ] 0%'). |
|
109 | + $this->generateOutput(' 0/10 [/ ] 0%') . |
|
110 | 110 | $this->generateOutput(' 1/10 [_/ ] 10%'), |
111 | 111 | stream_get_contents($output->getStream()) |
112 | 112 | ); |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | |
159 | 159 | rewind($output->getStream()); |
160 | 160 | $this->assertEquals( |
161 | - $this->generateOutput(' 0/50 [>---------------------------] 0%'). |
|
162 | - $this->generateOutput(' 0/50 [>---------------------------] 0%'). |
|
163 | - $this->generateOutput(' 1/50 [>---------------------------] 2%'). |
|
161 | + $this->generateOutput(' 0/50 [>---------------------------] 0%') . |
|
162 | + $this->generateOutput(' 0/50 [>---------------------------] 0%') . |
|
163 | + $this->generateOutput(' 1/50 [>---------------------------] 2%') . |
|
164 | 164 | $this->generateOutput(' 2/50 [=>--------------------------] 4%'), |
165 | 165 | stream_get_contents($output->getStream()) |
166 | 166 | ); |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | |
181 | 181 | rewind($output->getStream()); |
182 | 182 | $this->assertEquals( |
183 | - $this->generateOutput(' 0/50 [>---------------------------] 0%'). |
|
184 | - $this->generateOutput(' 0/50 [>---------------------------] 0%'). |
|
185 | - $this->generateOutput(' 1/50 [>---------------------------] 2%'). |
|
183 | + $this->generateOutput(' 0/50 [>---------------------------] 0%') . |
|
184 | + $this->generateOutput(' 0/50 [>---------------------------] 0%') . |
|
185 | + $this->generateOutput(' 1/50 [>---------------------------] 2%') . |
|
186 | 186 | $this->generateOutput(' 2/50 [=>--------------------------] '), |
187 | 187 | stream_get_contents($output->getStream()) |
188 | 188 | ); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | rewind($output->getStream()); |
199 | 199 | $this->assertEquals( |
200 | - $this->generateOutput(' 0/50 [>---------------------------]'). |
|
200 | + $this->generateOutput(' 0/50 [>---------------------------]') . |
|
201 | 201 | $this->generateOutput(' 1/50 [>---------------------------]'), |
202 | 202 | stream_get_contents($output->getStream()) |
203 | 203 | ); |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | |
215 | 215 | rewind($output->getStream()); |
216 | 216 | $this->assertEquals( |
217 | - $this->generateOutput(' 0/50 [>---------------------------] 0%'). |
|
218 | - $this->generateOutput(' 0/50 [>---------------------------] 0%'). |
|
219 | - $this->generateOutput(' 1/50 [>---------------------------] 2%'). |
|
220 | - $this->generateOutput(' 15/50 [========>-------------------] 30%'). |
|
217 | + $this->generateOutput(' 0/50 [>---------------------------] 0%') . |
|
218 | + $this->generateOutput(' 0/50 [>---------------------------] 0%') . |
|
219 | + $this->generateOutput(' 1/50 [>---------------------------] 2%') . |
|
220 | + $this->generateOutput(' 15/50 [========>-------------------] 30%') . |
|
221 | 221 | $this->generateOutput(' 25/50 [==============>-------------] 50%'), |
222 | 222 | stream_get_contents($output->getStream()) |
223 | 223 | ); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | |
271 | 271 | rewind($output->getStream()); |
272 | 272 | $this->assertEquals( |
273 | - $this->generateOutput(' 0 [>---------------------------]'). |
|
273 | + $this->generateOutput(' 0 [>---------------------------]') . |
|
274 | 274 | $this->generateOutput(' 3 [■■■>------------------------]'), |
275 | 275 | stream_get_contents($output->getStream()) |
276 | 276 | ); |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | |
286 | 286 | rewind($output->getStream()); |
287 | 287 | $this->assertEquals( |
288 | - $this->generateOutput(' 0/50 [>---------------------------] 0%'). |
|
289 | - $this->generateOutput(' 25/50 [==============>-------------] 50%'). |
|
288 | + $this->generateOutput(' 0/50 [>---------------------------] 0%') . |
|
289 | + $this->generateOutput(' 25/50 [==============>-------------] 50%') . |
|
290 | 290 | $this->generateOutput(' '), |
291 | 291 | stream_get_contents($output->getStream()) |
292 | 292 | ); |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | |
303 | 303 | rewind($output->getStream()); |
304 | 304 | $this->assertEquals( |
305 | - $this->generateOutput(' 0/200 [>---------------------------] 0%'). |
|
306 | - $this->generateOutput(' 0/200 [>---------------------------] 0%'). |
|
307 | - $this->generateOutput(' 199/200 [===========================>] 99%'). |
|
305 | + $this->generateOutput(' 0/200 [>---------------------------] 0%') . |
|
306 | + $this->generateOutput(' 0/200 [>---------------------------] 0%') . |
|
307 | + $this->generateOutput(' 199/200 [===========================>] 99%') . |
|
308 | 308 | $this->generateOutput(' 200/200 [============================] 100%'), |
309 | 309 | stream_get_contents($output->getStream()) |
310 | 310 | ); |
@@ -323,16 +323,16 @@ discard block |
||
323 | 323 | |
324 | 324 | rewind($output->getStream()); |
325 | 325 | $this->assertEquals( |
326 | - " 0/200 [>---------------------------] 0%\n". |
|
327 | - " 20/200 [==>-------------------------] 10%\n". |
|
328 | - " 40/200 [=====>----------------------] 20%\n". |
|
329 | - " 60/200 [========>-------------------] 30%\n". |
|
330 | - " 80/200 [===========>----------------] 40%\n". |
|
331 | - " 100/200 [==============>-------------] 50%\n". |
|
332 | - " 120/200 [================>-----------] 60%\n". |
|
333 | - " 140/200 [===================>--------] 70%\n". |
|
334 | - " 160/200 [======================>-----] 80%\n". |
|
335 | - " 180/200 [=========================>--] 90%\n". |
|
326 | + " 0/200 [>---------------------------] 0%\n" . |
|
327 | + " 20/200 [==>-------------------------] 10%\n" . |
|
328 | + " 40/200 [=====>----------------------] 20%\n" . |
|
329 | + " 60/200 [========>-------------------] 30%\n" . |
|
330 | + " 80/200 [===========>----------------] 40%\n" . |
|
331 | + " 100/200 [==============>-------------] 50%\n" . |
|
332 | + " 120/200 [================>-----------] 60%\n" . |
|
333 | + " 140/200 [===================>--------] 70%\n" . |
|
334 | + " 160/200 [======================>-----] 80%\n" . |
|
335 | + " 180/200 [=========================>--] 90%\n" . |
|
336 | 336 | " 200/200 [============================] 100%", |
337 | 337 | stream_get_contents($output->getStream()) |
338 | 338 | ); |
@@ -349,8 +349,8 @@ discard block |
||
349 | 349 | |
350 | 350 | rewind($output->getStream()); |
351 | 351 | $this->assertEquals( |
352 | - " 0/50 [>---------------------------] 0%\n". |
|
353 | - " 25/50 [==============>-------------] 50%\n". |
|
352 | + " 0/50 [>---------------------------] 0%\n" . |
|
353 | + " 25/50 [==============>-------------] 50%\n" . |
|
354 | 354 | " 50/50 [============================] 100%", |
355 | 355 | stream_get_contents($output->getStream()) |
356 | 356 | ); |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | |
365 | 365 | rewind($output->getStream()); |
366 | 366 | $this->assertEquals( |
367 | - " 0 [>---------------------------]\n". |
|
367 | + " 0 [>---------------------------]\n" . |
|
368 | 368 | " 1 [->--------------------------]", |
369 | 369 | stream_get_contents($output->getStream()) |
370 | 370 | ); |
@@ -402,28 +402,28 @@ discard block |
||
402 | 402 | |
403 | 403 | rewind($output->getStream()); |
404 | 404 | $this->assertEquals( |
405 | - $this->generateOutput(' 0/2 [>---------------------------] 0%')."\n". |
|
406 | - $this->generateOutput(' 0/3 [#---------------------------] 0%')."\n". |
|
407 | - rtrim($this->generateOutput(' 0 [>---------------------------]')). |
|
408 | - |
|
409 | - "\033[2A". |
|
410 | - $this->generateOutput(' 1/2 [==============>-------------] 50%')."\n". |
|
411 | - $this->generateOutput(' 1/3 [=========#------------------] 33%')."\n". |
|
412 | - rtrim($this->generateOutput(' 1 [->--------------------------]')). |
|
413 | - |
|
414 | - "\033[2A". |
|
415 | - $this->generateOutput(' 2/2 [============================] 100%')."\n". |
|
416 | - $this->generateOutput(' 2/3 [==================#---------] 66%')."\n". |
|
417 | - rtrim($this->generateOutput(' 2 [-->-------------------------]')). |
|
418 | - |
|
419 | - "\033[2A". |
|
420 | - "\n". |
|
421 | - $this->generateOutput(' 3/3 [============================] 100%')."\n". |
|
422 | - rtrim($this->generateOutput(' 3 [--->------------------------]')). |
|
423 | - |
|
424 | - "\033[2A". |
|
425 | - "\n". |
|
426 | - "\n". |
|
405 | + $this->generateOutput(' 0/2 [>---------------------------] 0%') . "\n" . |
|
406 | + $this->generateOutput(' 0/3 [#---------------------------] 0%') . "\n" . |
|
407 | + rtrim($this->generateOutput(' 0 [>---------------------------]')) . |
|
408 | + |
|
409 | + "\033[2A" . |
|
410 | + $this->generateOutput(' 1/2 [==============>-------------] 50%') . "\n" . |
|
411 | + $this->generateOutput(' 1/3 [=========#------------------] 33%') . "\n" . |
|
412 | + rtrim($this->generateOutput(' 1 [->--------------------------]')) . |
|
413 | + |
|
414 | + "\033[2A" . |
|
415 | + $this->generateOutput(' 2/2 [============================] 100%') . "\n" . |
|
416 | + $this->generateOutput(' 2/3 [==================#---------] 66%') . "\n" . |
|
417 | + rtrim($this->generateOutput(' 2 [-->-------------------------]')) . |
|
418 | + |
|
419 | + "\033[2A" . |
|
420 | + "\n" . |
|
421 | + $this->generateOutput(' 3/3 [============================] 100%') . "\n" . |
|
422 | + rtrim($this->generateOutput(' 3 [--->------------------------]')) . |
|
423 | + |
|
424 | + "\033[2A" . |
|
425 | + "\n" . |
|
426 | + "\n" . |
|
427 | 427 | rtrim($this->generateOutput(' 3 [============================]')), |
428 | 428 | stream_get_contents($output->getStream()) |
429 | 429 | ); |
@@ -442,10 +442,10 @@ discard block |
||
442 | 442 | |
443 | 443 | rewind($output->getStream()); |
444 | 444 | $this->assertEquals( |
445 | - rtrim($this->generateOutput(' 0 [>---------------------------]')). |
|
446 | - rtrim($this->generateOutput(' 1 [->--------------------------]')). |
|
447 | - rtrim($this->generateOutput(' 2 [-->-------------------------]')). |
|
448 | - rtrim($this->generateOutput(' 3 [--->------------------------]')). |
|
445 | + rtrim($this->generateOutput(' 0 [>---------------------------]')) . |
|
446 | + rtrim($this->generateOutput(' 1 [->--------------------------]')) . |
|
447 | + rtrim($this->generateOutput(' 2 [-->-------------------------]')) . |
|
448 | + rtrim($this->generateOutput(' 3 [--->------------------------]')) . |
|
449 | 449 | rtrim($this->generateOutput(' 3 [============================]')), |
450 | 450 | stream_get_contents($output->getStream()) |
451 | 451 | ); |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | |
454 | 454 | public function testAddingPlaceholderFormatter() |
455 | 455 | { |
456 | - ProgressBar::setPlaceholderFormatterDefinition('remaining_steps', function (ProgressBar $bar) { |
|
456 | + ProgressBar::setPlaceholderFormatterDefinition('remaining_steps', function(ProgressBar $bar) { |
|
457 | 457 | return $bar->getMaxSteps() - $bar->getProgress(); |
458 | 458 | }); |
459 | 459 | $bar = new ProgressBar($output = $this->getOutputStream(), 3); |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | |
466 | 466 | rewind($output->getStream()); |
467 | 467 | $this->assertEquals( |
468 | - $this->generateOutput(' 3 [>---------------------------]'). |
|
469 | - $this->generateOutput(' 2 [=========>------------------]'). |
|
468 | + $this->generateOutput(' 3 [>---------------------------]') . |
|
469 | + $this->generateOutput(' 2 [=========>------------------]') . |
|
470 | 470 | $this->generateOutput(' 0 [============================]'), |
471 | 471 | stream_get_contents($output->getStream()) |
472 | 472 | ); |
@@ -484,9 +484,9 @@ discard block |
||
484 | 484 | |
485 | 485 | rewind($output->getStream()); |
486 | 486 | $this->assertEquals( |
487 | - $this->generateOutput(">---------------------------\nfoobar"). |
|
488 | - $this->generateOutput("=========>------------------\nfoobar "). |
|
489 | - $this->generateOutput(" \n "). |
|
487 | + $this->generateOutput(">---------------------------\nfoobar") . |
|
488 | + $this->generateOutput("=========>------------------\nfoobar ") . |
|
489 | + $this->generateOutput(" \n ") . |
|
490 | 490 | $this->generateOutput("============================\nfoobar "), |
491 | 491 | stream_get_contents($output->getStream()) |
492 | 492 | ); |
@@ -495,12 +495,12 @@ discard block |
||
495 | 495 | public function testAnsiColorsAndEmojis() |
496 | 496 | { |
497 | 497 | $bar = new ProgressBar($output = $this->getOutputStream(), 15); |
498 | - ProgressBar::setPlaceholderFormatterDefinition('memory', function (ProgressBar $bar) { |
|
498 | + ProgressBar::setPlaceholderFormatterDefinition('memory', function(ProgressBar $bar) { |
|
499 | 499 | static $i = 0; |
500 | 500 | $mem = 100000 * $i; |
501 | 501 | $colors = $i++ ? '41;37' : '44;37'; |
502 | 502 | |
503 | - return "\033[".$colors."m ".Helper::formatMemory($mem)." \033[0m"; |
|
503 | + return "\033[" . $colors . "m " . Helper::formatMemory($mem) . " \033[0m"; |
|
504 | 504 | }); |
505 | 505 | $bar->setFormat(" \033[44;37m %title:-37s% \033[0m\n %current%/%max% %bar% %percent:3s%%\n |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | |
32 | 32 | function menu_ul($sel = 'inicio') |
33 | - { |
|
33 | + { |
|
34 | 34 | $items = array( |
35 | 35 | 'inicio' => array( |
36 | 36 | 'id' => 'inicio', |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | function menu_p($sel = 'inicio', $separador = '') |
68 | - { |
|
68 | + { |
|
69 | 69 | //$CI =& get_instance(); |
70 | 70 | $items = array( |
71 | 71 | 'inicio' => array( |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | ) |
54 | 54 | ); |
55 | 55 | |
56 | - $menu = '<ul class="inline" >'. PHP_EOL; |
|
57 | - foreach($items as $item) |
|
56 | + $menu = '<ul class="inline" >' . PHP_EOL; |
|
57 | + foreach ($items as $item) |
|
58 | 58 | { |
59 | 59 | $current = (in_array($sel, $item)) ? ' class="current"' : ''; |
60 | - $id = (!empty($item['id'])) ? ' id="'.$item['id'].'"' : ''; |
|
61 | - $menu .= '<li'.$current.'><a href="'.$item['link'].'"'.$id.'>'.$item['title'].'</a></li>'."\n"; |
|
60 | + $id = (!empty($item['id'])) ? ' id="' . $item['id'] . '"' : ''; |
|
61 | + $menu .= '<li' . $current . '><a href="' . $item['link'] . '"' . $id . '>' . $item['title'] . '</a></li>' . "\n"; |
|
62 | 62 | } |
63 | - $menu .= '</ul>'. PHP_EOL . PHP_EOL; |
|
63 | + $menu .= '</ul>' . PHP_EOL . PHP_EOL; |
|
64 | 64 | return $menu; |
65 | 65 | } |
66 | 66 | |
@@ -91,19 +91,19 @@ discard block |
||
91 | 91 | |
92 | 92 | $count = count($items); |
93 | 93 | $i = 0; |
94 | - $menu = PHP_EOL .'<p class="bottom_nav">'; |
|
95 | - foreach($items as $item) |
|
94 | + $menu = PHP_EOL . '<p class="bottom_nav">'; |
|
95 | + foreach ($items as $item) |
|
96 | 96 | { |
97 | 97 | $current = (in_array($sel, $item)) ? ' class="current"' : ''; |
98 | - $id = (!empty($item['id'])) ? ' id="'.$item['id'].'"' : ''; |
|
99 | - $menu .= '<a'.$current.' href="'.$item['link'].'"'.$id.'>'.$item['title'].'</a>'; |
|
98 | + $id = (!empty($item['id'])) ? ' id="' . $item['id'] . '"' : ''; |
|
99 | + $menu .= '<a' . $current . ' href="' . $item['link'] . '"' . $id . '>' . $item['title'] . '</a>'; |
|
100 | 100 | $i++; |
101 | - if($count != $i) |
|
101 | + if ($count != $i) |
|
102 | 102 | { |
103 | - $menu .= ' '.$separador.' '; |
|
103 | + $menu .= ' ' . $separador . ' '; |
|
104 | 104 | } |
105 | 105 | } |
106 | - $menu .= '</p>'. PHP_EOL ; |
|
106 | + $menu .= '</p>' . PHP_EOL; |
|
107 | 107 | return $menu; |
108 | 108 | } |
109 | 109 |
@@ -39,311 +39,311 @@ |
||
39 | 39 | * (you can pass the most critical GETs manually if you like) |
40 | 40 | */ |
41 | 41 | |
42 | - //Esta clase fue editada por programadores de Cf con la aprobacion de Ruben Arroyo |
|
42 | + //Esta clase fue editada por programadores de Cf con la aprobacion de Ruben Arroyo |
|
43 | 43 | |
44 | 44 | namespace Sistema\Ayudantes; |
45 | 45 | |
46 | 46 | class Cf_PHPPaginator { |
47 | - /* |
|
47 | + /* |
|
48 | 48 | * MAIN Settings (required) |
49 | 49 | */ |
50 | 50 | |
51 | - /** |
|
52 | - * |
|
53 | - * @total_records string Total of records to paginate (specify manually) |
|
54 | - */ |
|
55 | - public $total_records = 0; |
|
51 | + /** |
|
52 | + * |
|
53 | + * @total_records string Total of records to paginate (specify manually) |
|
54 | + */ |
|
55 | + public $total_records = 0; |
|
56 | 56 | |
57 | 57 | |
58 | - /* |
|
58 | + /* |
|
59 | 59 | * MAIN Settings (optional) |
60 | 60 | */ |
61 | 61 | |
62 | - /** |
|
63 | - * @style string Specify Class to define |
|
64 | - * @tutorial If is specified, it would create <div class="style"> otherwise it not create div |
|
65 | - */ |
|
66 | - public $style = ''; |
|
62 | + /** |
|
63 | + * @style string Specify Class to define |
|
64 | + * @tutorial If is specified, it would create <div class="style"> otherwise it not create div |
|
65 | + */ |
|
66 | + public $style = ''; |
|
67 | 67 | |
68 | - /** |
|
69 | - * @records number Max records to show on every page |
|
70 | - */ |
|
71 | - public $records = 20; |
|
68 | + /** |
|
69 | + * @records number Max records to show on every page |
|
70 | + */ |
|
71 | + public $records = 20; |
|
72 | 72 | |
73 | - /** |
|
74 | - * @max_links number Maxium quantity of links to show before and after actual page |
|
75 | - * @example If current page is 4 and MAX is 2, it show "2 3 4 5 6" |
|
76 | - */ |
|
77 | - public $max_links = 3; |
|
73 | + /** |
|
74 | + * @max_links number Maxium quantity of links to show before and after actual page |
|
75 | + * @example If current page is 4 and MAX is 2, it show "2 3 4 5 6" |
|
76 | + */ |
|
77 | + public $max_links = 3; |
|
78 | 78 | |
79 | - /** |
|
80 | - * @get_name string Specify INDEX of GET that is used |
|
81 | - * |
|
82 | - * It will load automatically the current page. |
|
83 | - * If you like, you can specify manually in "$cur_page" |
|
84 | - * (if you like filter previously or the script will not load directly from URL) |
|
85 | - */ |
|
86 | - public $get_name = 'pag'; |
|
79 | + /** |
|
80 | + * @get_name string Specify INDEX of GET that is used |
|
81 | + * |
|
82 | + * It will load automatically the current page. |
|
83 | + * If you like, you can specify manually in "$cur_page" |
|
84 | + * (if you like filter previously or the script will not load directly from URL) |
|
85 | + */ |
|
86 | + public $get_name = 'pag'; |
|
87 | 87 | |
88 | - /** |
|
89 | - * @max_records number Specify maxium quantity of registers will be loaded. "0" disable this |
|
90 | - */ |
|
91 | - public $max_records = 0; |
|
88 | + /** |
|
89 | + * @max_records number Specify maxium quantity of registers will be loaded. "0" disable this |
|
90 | + */ |
|
91 | + public $max_records = 0; |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * @recicle_url boolean If is true, modify directly tue current URL to put the pagination (if not exist any, add &pag= to the end) |
|
96 | - * If is true, $url_start and $url_end will be ignored |
|
97 | - */ |
|
98 | - public $recicle_url = true; |
|
94 | + /** |
|
95 | + * @recicle_url boolean If is true, modify directly tue current URL to put the pagination (if not exist any, add &pag= to the end) |
|
96 | + * If is true, $url_start and $url_end will be ignored |
|
97 | + */ |
|
98 | + public $recicle_url = true; |
|
99 | 99 | |
100 | - /** |
|
101 | - * @specific_get array Specify what GETs (and order) you like recicle. |
|
102 | - * Set array() to ALL (not recomended to avoid atacks DoS) |
|
103 | - * Set '' for any |
|
104 | - * @example array('section', 'pag', 'subsection'); |
|
105 | - * If you don't need 'pag' in the midle, you can ignore it. |
|
106 | - * WARNING: If the order is very important, use the pag at THE END of url |
|
107 | - */ |
|
108 | - public $specific_get = ''; |
|
100 | + /** |
|
101 | + * @specific_get array Specify what GETs (and order) you like recicle. |
|
102 | + * Set array() to ALL (not recomended to avoid atacks DoS) |
|
103 | + * Set '' for any |
|
104 | + * @example array('section', 'pag', 'subsection'); |
|
105 | + * If you don't need 'pag' in the midle, you can ignore it. |
|
106 | + * WARNING: If the order is very important, use the pag at THE END of url |
|
107 | + */ |
|
108 | + public $specific_get = ''; |
|
109 | 109 | |
110 | - /** |
|
111 | - * @url_start string specify how the URL of every link start. IF $recicle_url is TRUE, this will be ignored |
|
112 | - * @example If you use MOD_REWRITE or JAVASCRIPT, you can put "http://mywebsite.com/subdir/pag-" or "javascript:paginate(" |
|
113 | - * |
|
114 | - * This value will auto completed if you leave empty |
|
115 | - */ |
|
116 | - public $url_start = ''; |
|
110 | + /** |
|
111 | + * @url_start string specify how the URL of every link start. IF $recicle_url is TRUE, this will be ignored |
|
112 | + * @example If you use MOD_REWRITE or JAVASCRIPT, you can put "http://mywebsite.com/subdir/pag-" or "javascript:paginate(" |
|
113 | + * |
|
114 | + * This value will auto completed if you leave empty |
|
115 | + */ |
|
116 | + public $url_start = ''; |
|
117 | 117 | |
118 | - /** |
|
119 | - * @url_end string specify how the URL of every link ends. IF $recicle_url is TRUE, this will be ignored |
|
120 | - * @example If you use MOD_REWRITE or JAVASCRIPT, you can put "/" or ");" |
|
121 | - * |
|
122 | - * This value will auto completed if you leave empty |
|
123 | - */ |
|
124 | - public $url_end = ''; |
|
118 | + /** |
|
119 | + * @url_end string specify how the URL of every link ends. IF $recicle_url is TRUE, this will be ignored |
|
120 | + * @example If you use MOD_REWRITE or JAVASCRIPT, you can put "/" or ");" |
|
121 | + * |
|
122 | + * This value will auto completed if you leave empty |
|
123 | + */ |
|
124 | + public $url_end = ''; |
|
125 | 125 | |
126 | 126 | |
127 | 127 | |
128 | - /* |
|
128 | + /* |
|
129 | 129 | * Design settings |
130 | 130 | */ |
131 | 131 | |
132 | - // Icons to show "First | Previous | Next | Last" |
|
133 | - //& laquo; = � | & lt; = < |
|
132 | + // Icons to show "First | Previous | Next | Last" |
|
133 | + //& laquo; = � | & lt; = < |
|
134 | 134 | //& raquo; = � | & gt; = > |
135 | 135 | // Leave empty '' to not show or ' ' to show empty |
136 | - public $first = '[<<]'; |
|
137 | - public $previous = '[<]'; |
|
138 | - public $next = '[>]'; |
|
139 | - public $last = '[>>]'; |
|
136 | + public $first = '[<<]'; |
|
137 | + public $previous = '[<]'; |
|
138 | + public $next = '[>]'; |
|
139 | + public $last = '[>>]'; |
|
140 | 140 | |
141 | 141 | |
142 | - /* |
|
142 | + /* |
|
143 | 143 | * RETURNS FROM PAGINATOR and internal use |
144 | 144 | */ |
145 | - // Return current page (auto loaded) |
|
146 | - public $cur_page; |
|
145 | + // Return current page (auto loaded) |
|
146 | + public $cur_page; |
|
147 | 147 | |
148 | - // original page loaded |
|
149 | - // it contains the real value in GET (ex: -1, 5...) to compare later |
|
150 | - public $original_page; |
|
148 | + // original page loaded |
|
149 | + // it contains the real value in GET (ex: -1, 5...) to compare later |
|
150 | + public $original_page; |
|
151 | 151 | |
152 | - // Return total pages |
|
153 | - public $total_pages; |
|
152 | + // Return total pages |
|
153 | + public $total_pages; |
|
154 | 154 | |
155 | - // LIMIT_START / Specify the first record of the page (ex, in page 3 and 20 records is record num 40) |
|
156 | - // Limit max is $records |
|
157 | - public $first_record; |
|
155 | + // LIMIT_START / Specify the first record of the page (ex, in page 3 and 20 records is record num 40) |
|
156 | + // Limit max is $records |
|
157 | + public $first_record; |
|
158 | 158 | |
159 | - // Specify limit to put directly in mysql query ( LIMIT 0,20 ) |
|
160 | - public $limit; |
|
159 | + // Specify limit to put directly in mysql query ( LIMIT 0,20 ) |
|
160 | + public $limit; |
|
161 | 161 | |
162 | 162 | |
163 | 163 | /* |
164 | 164 | * Functions |
165 | 165 | */ |
166 | - /** |
|
167 | - * @name paginate |
|
168 | - * @tutorial This function is called directly to load all params |
|
169 | - * @example $pag->paginate(); |
|
170 | - */ |
|
171 | - public function paginate() { |
|
172 | - $this->get(); // Filtering and obtaining variables |
|
173 | - $this->calculate(); // Calc current page |
|
174 | - $this->prepareUrl(); // Preparing URL to show |
|
175 | - } |
|
166 | + /** |
|
167 | + * @name paginate |
|
168 | + * @tutorial This function is called directly to load all params |
|
169 | + * @example $pag->paginate(); |
|
170 | + */ |
|
171 | + public function paginate() { |
|
172 | + $this->get(); // Filtering and obtaining variables |
|
173 | + $this->calculate(); // Calc current page |
|
174 | + $this->prepareUrl(); // Preparing URL to show |
|
175 | + } |
|
176 | 176 | |
177 | - /** |
|
178 | - * @name show |
|
179 | - * @tutorial Show links of pagination |
|
180 | - * @example $pag->show(); |
|
181 | - */ |
|
182 | - public function show() { |
|
183 | - // Prepare string with links |
|
184 | - // Reading here variables is faster than "$this->var" |
|
185 | - $cur_page = $this->cur_page; |
|
186 | - $url_start = $this->url_start; |
|
187 | - $url_end = $this->url_end; |
|
177 | + /** |
|
178 | + * @name show |
|
179 | + * @tutorial Show links of pagination |
|
180 | + * @example $pag->show(); |
|
181 | + */ |
|
182 | + public function show() { |
|
183 | + // Prepare string with links |
|
184 | + // Reading here variables is faster than "$this->var" |
|
185 | + $cur_page = $this->cur_page; |
|
186 | + $url_start = $this->url_start; |
|
187 | + $url_end = $this->url_end; |
|
188 | 188 | |
189 | - $start = $cur_page - $this->max_links; |
|
190 | - $end = $cur_page + $this->max_links; |
|
189 | + $start = $cur_page - $this->max_links; |
|
190 | + $end = $cur_page + $this->max_links; |
|
191 | 191 | |
192 | - if ($start < 1) $start = 1; |
|
193 | - if ($end > $this->total_pages) $end = $this->total_pages; |
|
192 | + if ($start < 1) $start = 1; |
|
193 | + if ($end > $this->total_pages) $end = $this->total_pages; |
|
194 | 194 | |
195 | - // Showing all clickable pages (create div if class is defined) |
|
196 | - if ($this->style != '') $r = '<div class="'.$this->style.'">'; |
|
197 | - else $r = ''; |
|
195 | + // Showing all clickable pages (create div if class is defined) |
|
196 | + if ($this->style != '') $r = '<div class="'.$this->style.'">'; |
|
197 | + else $r = ''; |
|
198 | 198 | |
199 | 199 | |
200 | - // First / previous |
|
201 | - if ($this->cur_page > 1) { |
|
202 | - if ($this->first != '') $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">'.$this->first.'</a> '; |
|
203 | - if ($this->previous != '') $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">'.$this->previous.'</a> '; |
|
204 | - } |
|
200 | + // First / previous |
|
201 | + if ($this->cur_page > 1) { |
|
202 | + if ($this->first != '') $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">'.$this->first.'</a> '; |
|
203 | + if ($this->previous != '') $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">'.$this->previous.'</a> '; |
|
204 | + } |
|
205 | 205 | |
206 | - // You can optimize this separating BEFORE and AFTER current page in two for (to avoid load "if" in each loop) |
|
207 | - // but it would be difficult on changes |
|
208 | - for ($n=$start; $n<=$end; $n++) { |
|
209 | - if ($n != $cur_page) $r .= '<a class="link" href="'. $url_start . $n . $url_end . '">'.$n.'</a> '; |
|
210 | - else $r .= '<a class="current">'.$n.'</a> '; |
|
211 | - } |
|
206 | + // You can optimize this separating BEFORE and AFTER current page in two for (to avoid load "if" in each loop) |
|
207 | + // but it would be difficult on changes |
|
208 | + for ($n=$start; $n<=$end; $n++) { |
|
209 | + if ($n != $cur_page) $r .= '<a class="link" href="'. $url_start . $n . $url_end . '">'.$n.'</a> '; |
|
210 | + else $r .= '<a class="current">'.$n.'</a> '; |
|
211 | + } |
|
212 | 212 | |
213 | - // next / last |
|
214 | - if ($this->cur_page < $this->total_pages) { |
|
215 | - if ($this->next != '') $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">'.$this->next.'</a> '; |
|
216 | - if ($this->last != '') $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end .'">'.$this->last.'</a> '; |
|
217 | - } |
|
213 | + // next / last |
|
214 | + if ($this->cur_page < $this->total_pages) { |
|
215 | + if ($this->next != '') $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">'.$this->next.'</a> '; |
|
216 | + if ($this->last != '') $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end .'">'.$this->last.'</a> '; |
|
217 | + } |
|
218 | 218 | |
219 | - // End div (if exist) |
|
220 | - if ($this->style != '') $r .= '</div>'; |
|
219 | + // End div (if exist) |
|
220 | + if ($this->style != '') $r .= '</div>'; |
|
221 | 221 | |
222 | - return $r; |
|
223 | - } |
|
222 | + return $r; |
|
223 | + } |
|
224 | 224 | |
225 | 225 | |
226 | - /** |
|
227 | - * @name get |
|
228 | - * @tutorial This function is autoloaded, it get the current page and filter number to avoid hackers |
|
229 | - */ |
|
230 | - private function get() { |
|
231 | - if (!is_numeric($this->cur_page)) { |
|
232 | - // First get the actual page, by default 1 |
|
233 | - $cur_page = isset($_GET[$this->get_name]) ? $_GET[$this->get_name] : 1; |
|
234 | - $this->original_page = $cur_page; |
|
226 | + /** |
|
227 | + * @name get |
|
228 | + * @tutorial This function is autoloaded, it get the current page and filter number to avoid hackers |
|
229 | + */ |
|
230 | + private function get() { |
|
231 | + if (!is_numeric($this->cur_page)) { |
|
232 | + // First get the actual page, by default 1 |
|
233 | + $cur_page = isset($_GET[$this->get_name]) ? $_GET[$this->get_name] : 1; |
|
234 | + $this->original_page = $cur_page; |
|
235 | 235 | |
236 | - // Filter values |
|
237 | - if (!is_numeric($cur_page) or $cur_page < 1) $cur_page = 1; |
|
236 | + // Filter values |
|
237 | + if (!is_numeric($cur_page) or $cur_page < 1) $cur_page = 1; |
|
238 | 238 | |
239 | - // Set new filtered values (is faster this method) |
|
240 | - $this->cur_page = $cur_page; |
|
241 | - } else { |
|
242 | - $this->original_page = $cur_page; |
|
243 | - } |
|
244 | - } |
|
239 | + // Set new filtered values (is faster this method) |
|
240 | + $this->cur_page = $cur_page; |
|
241 | + } else { |
|
242 | + $this->original_page = $cur_page; |
|
243 | + } |
|
244 | + } |
|
245 | 245 | |
246 | - /** |
|
247 | - * @name calculate |
|
248 | - * @tutorial Do all calcs about current and last page |
|
249 | - */ |
|
250 | - private function calculate() { |
|
251 | - // This vars are very used, so is faster do this |
|
252 | - $max_records = $this->max_records; |
|
253 | - $records = $this->records; |
|
246 | + /** |
|
247 | + * @name calculate |
|
248 | + * @tutorial Do all calcs about current and last page |
|
249 | + */ |
|
250 | + private function calculate() { |
|
251 | + // This vars are very used, so is faster do this |
|
252 | + $max_records = $this->max_records; |
|
253 | + $records = $this->records; |
|
254 | 254 | |
255 | - // Force maxium records loaded (only if is specified by user) |
|
256 | - if ($max_records > 0 and $max_records > $total_records) |
|
257 | - $this->total_records = $max_records; |
|
255 | + // Force maxium records loaded (only if is specified by user) |
|
256 | + if ($max_records > 0 and $max_records > $total_records) |
|
257 | + $this->total_records = $max_records; |
|
258 | 258 | |
259 | - // Calculate total pages that have |
|
260 | - $total_pages = ceil($this->total_records / $records); |
|
259 | + // Calculate total pages that have |
|
260 | + $total_pages = ceil($this->total_records / $records); |
|
261 | 261 | |
262 | - // Is correct current page? |
|
263 | - if ($this->cur_page > $total_pages) $this->cur_page = $total_pages; |
|
264 | - $this->total_pages = $total_pages; |
|
262 | + // Is correct current page? |
|
263 | + if ($this->cur_page > $total_pages) $this->cur_page = $total_pages; |
|
264 | + $this->total_pages = $total_pages; |
|
265 | 265 | |
266 | - // Specify LIMIT to do a query |
|
267 | - $start = ($this->cur_page - 1) * $records; |
|
266 | + // Specify LIMIT to do a query |
|
267 | + $start = ($this->cur_page - 1) * $records; |
|
268 | 268 | |
269 | - // Forcing maixum records to show (only if is specified by user) |
|
270 | - if ($max_records > 0 and $records > $max_records) { |
|
271 | - $records = $max_records; |
|
272 | - $this->records = $records; |
|
273 | - } |
|
269 | + // Forcing maixum records to show (only if is specified by user) |
|
270 | + if ($max_records > 0 and $records > $max_records) { |
|
271 | + $records = $max_records; |
|
272 | + $this->records = $records; |
|
273 | + } |
|
274 | 274 | |
275 | 275 | |
276 | - // Saving changes |
|
277 | - $this->first_record = $start; |
|
278 | - $this->limit = ' LIMIT '.$start.','.$records.' '; |
|
279 | - } |
|
276 | + // Saving changes |
|
277 | + $this->first_record = $start; |
|
278 | + $this->limit = ' LIMIT '.$start.','.$records.' '; |
|
279 | + } |
|
280 | 280 | |
281 | - /** |
|
282 | - * @name prepareUrl |
|
283 | - * @tutorial It prepare the url to show in each link, specified by user |
|
284 | - * If recicle URL is false, it will auto load $url_start and $url_end |
|
285 | - */ |
|
286 | - private function prepareUrl() { |
|
287 | - // This script use three methods to recicle GET depending user selection |
|
288 | - if ($this->recicle_url) { |
|
289 | - // gonna to recicle the URL |
|
290 | - $gets = $this->specific_get; |
|
291 | - $get_name = $this->get_name; |
|
281 | + /** |
|
282 | + * @name prepareUrl |
|
283 | + * @tutorial It prepare the url to show in each link, specified by user |
|
284 | + * If recicle URL is false, it will auto load $url_start and $url_end |
|
285 | + */ |
|
286 | + private function prepareUrl() { |
|
287 | + // This script use three methods to recicle GET depending user selection |
|
288 | + if ($this->recicle_url) { |
|
289 | + // gonna to recicle the URL |
|
290 | + $gets = $this->specific_get; |
|
291 | + $get_name = $this->get_name; |
|
292 | 292 | |
293 | - // If user specified an array |
|
294 | - if (is_array($gets)) { |
|
295 | - if (empty($gets)) { |
|
296 | - // And is empty, we have to Recicle ALL GET |
|
297 | - // To know that page needs to be replaced we will use the "original_page" (the real get) |
|
298 | - // Cortamos "pag=2" para obtener lo que va antes y despues, as� poder modificar directamente ese pag=2 por la pagina actual |
|
299 | - $query_string = explode($this->get_name.'='.$this->original_page, $_SERVER['QUERY_STRING']); |
|
293 | + // If user specified an array |
|
294 | + if (is_array($gets)) { |
|
295 | + if (empty($gets)) { |
|
296 | + // And is empty, we have to Recicle ALL GET |
|
297 | + // To know that page needs to be replaced we will use the "original_page" (the real get) |
|
298 | + // Cortamos "pag=2" para obtener lo que va antes y despues, as� poder modificar directamente ese pag=2 por la pagina actual |
|
299 | + $query_string = explode($this->get_name.'='.$this->original_page, $_SERVER['QUERY_STRING']); |
|
300 | 300 | |
301 | - // How start the new URL? To know it, we need to see the last character from current string |
|
302 | - if (!in_array(substr($query_string[0], -1), array('?', '&'))) { |
|
303 | - // Current string haven't any at end and it isn't "&" or "?" ? |
|
304 | - // If initial string have one character at least it means that not is the first index |
|
305 | - if (isset($query_string[0][0])) $this->url_start = '?'.$query_string[0].'&'; |
|
306 | - else $this->url_start = '?'.$query_string[0]; |
|
307 | - } else { |
|
308 | - // Current string already have ? or &, |
|
309 | - $this->url_start = '?'.$query_string[0]; |
|
310 | - } |
|
301 | + // How start the new URL? To know it, we need to see the last character from current string |
|
302 | + if (!in_array(substr($query_string[0], -1), array('?', '&'))) { |
|
303 | + // Current string haven't any at end and it isn't "&" or "?" ? |
|
304 | + // If initial string have one character at least it means that not is the first index |
|
305 | + if (isset($query_string[0][0])) $this->url_start = '?'.$query_string[0].'&'; |
|
306 | + else $this->url_start = '?'.$query_string[0]; |
|
307 | + } else { |
|
308 | + // Current string already have ? or &, |
|
309 | + $this->url_start = '?'.$query_string[0]; |
|
310 | + } |
|
311 | 311 | |
312 | - $this->url_end = isset($query_string[1]) ? $query_string[1] : ''; |
|
313 | - } else { |
|
314 | - // Only specifics GET, reading all and finally leave in the same order |
|
315 | - // With this we can clean all GET that we don't need (like hacker attempts) |
|
316 | - $tmp = ''; |
|
317 | - $tmp_start = ''; // If we found the current page, we move here all $tmp |
|
318 | - foreach ($gets as $get) { |
|
319 | - if ($get != $get_name) { |
|
320 | - // Trying to get the GET |
|
321 | - if (isset($_GET[$get])) $tmp .= $get.'='.$_GET[$get].'&'; |
|
322 | - } else { |
|
323 | - // Pour the $tmp content to $tmp_start |
|
324 | - if ($tmp_start == '') $tmp_start .= '?'; |
|
325 | - $tmp_start .= $tmp; |
|
326 | - $tmp = ''; |
|
327 | - } |
|
328 | - } |
|
312 | + $this->url_end = isset($query_string[1]) ? $query_string[1] : ''; |
|
313 | + } else { |
|
314 | + // Only specifics GET, reading all and finally leave in the same order |
|
315 | + // With this we can clean all GET that we don't need (like hacker attempts) |
|
316 | + $tmp = ''; |
|
317 | + $tmp_start = ''; // If we found the current page, we move here all $tmp |
|
318 | + foreach ($gets as $get) { |
|
319 | + if ($get != $get_name) { |
|
320 | + // Trying to get the GET |
|
321 | + if (isset($_GET[$get])) $tmp .= $get.'='.$_GET[$get].'&'; |
|
322 | + } else { |
|
323 | + // Pour the $tmp content to $tmp_start |
|
324 | + if ($tmp_start == '') $tmp_start .= '?'; |
|
325 | + $tmp_start .= $tmp; |
|
326 | + $tmp = ''; |
|
327 | + } |
|
328 | + } |
|
329 | 329 | |
330 | - // Finally, write the changes in the object |
|
331 | - if ($tmp_start != '') { |
|
332 | - // If have start and end |
|
333 | - $this->url_start = $tmp_start; |
|
334 | - $this->url_end = $tmp; |
|
335 | - } |
|
336 | - else $this->url_start = '?'.$tmp; |
|
337 | - } |
|
338 | - } else{ |
|
339 | - // Non recicle |
|
340 | - $this->url_start = '?'; |
|
341 | - $this->url_end = ''; |
|
342 | - } |
|
330 | + // Finally, write the changes in the object |
|
331 | + if ($tmp_start != '') { |
|
332 | + // If have start and end |
|
333 | + $this->url_start = $tmp_start; |
|
334 | + $this->url_end = $tmp; |
|
335 | + } |
|
336 | + else $this->url_start = '?'.$tmp; |
|
337 | + } |
|
338 | + } else{ |
|
339 | + // Non recicle |
|
340 | + $this->url_start = '?'; |
|
341 | + $this->url_end = ''; |
|
342 | + } |
|
343 | 343 | |
344 | - // Add the pagination |
|
345 | - $this->url_start .= $this->get_name.'='; |
|
346 | - } |
|
347 | - } |
|
344 | + // Add the pagination |
|
345 | + $this->url_start .= $this->get_name.'='; |
|
346 | + } |
|
347 | + } |
|
348 | 348 | } |
349 | 349 | ?> |
350 | 350 | \ No newline at end of file |
@@ -193,27 +193,27 @@ discard block |
||
193 | 193 | if ($end > $this->total_pages) $end = $this->total_pages; |
194 | 194 | |
195 | 195 | // Showing all clickable pages (create div if class is defined) |
196 | - if ($this->style != '') $r = '<div class="'.$this->style.'">'; |
|
196 | + if ($this->style != '') $r = '<div class="' . $this->style . '">'; |
|
197 | 197 | else $r = ''; |
198 | 198 | |
199 | 199 | |
200 | 200 | // First / previous |
201 | 201 | if ($this->cur_page > 1) { |
202 | - if ($this->first != '') $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">'.$this->first.'</a> '; |
|
203 | - if ($this->previous != '') $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">'.$this->previous.'</a> '; |
|
202 | + if ($this->first != '') $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">' . $this->first . '</a> '; |
|
203 | + if ($this->previous != '') $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">' . $this->previous . '</a> '; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | // You can optimize this separating BEFORE and AFTER current page in two for (to avoid load "if" in each loop) |
207 | 207 | // but it would be difficult on changes |
208 | - for ($n=$start; $n<=$end; $n++) { |
|
209 | - if ($n != $cur_page) $r .= '<a class="link" href="'. $url_start . $n . $url_end . '">'.$n.'</a> '; |
|
210 | - else $r .= '<a class="current">'.$n.'</a> '; |
|
208 | + for ($n = $start; $n <= $end; $n++) { |
|
209 | + if ($n != $cur_page) $r .= '<a class="link" href="' . $url_start . $n . $url_end . '">' . $n . '</a> '; |
|
210 | + else $r .= '<a class="current">' . $n . '</a> '; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | // next / last |
214 | 214 | if ($this->cur_page < $this->total_pages) { |
215 | - if ($this->next != '') $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">'.$this->next.'</a> '; |
|
216 | - if ($this->last != '') $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end .'">'.$this->last.'</a> '; |
|
215 | + if ($this->next != '') $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">' . $this->next . '</a> '; |
|
216 | + if ($this->last != '') $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end . '">' . $this->last . '</a> '; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | // End div (if exist) |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $records = $this->records; |
254 | 254 | |
255 | 255 | // Force maxium records loaded (only if is specified by user) |
256 | - if ($max_records > 0 and $max_records > $total_records) |
|
256 | + if ($max_records > 0 and $max_records > $total_records) |
|
257 | 257 | $this->total_records = $max_records; |
258 | 258 | |
259 | 259 | // Calculate total pages that have |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | // Saving changes |
277 | 277 | $this->first_record = $start; |
278 | - $this->limit = ' LIMIT '.$start.','.$records.' '; |
|
278 | + $this->limit = ' LIMIT ' . $start . ',' . $records . ' '; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -296,17 +296,17 @@ discard block |
||
296 | 296 | // And is empty, we have to Recicle ALL GET |
297 | 297 | // To know that page needs to be replaced we will use the "original_page" (the real get) |
298 | 298 | // Cortamos "pag=2" para obtener lo que va antes y despues, as� poder modificar directamente ese pag=2 por la pagina actual |
299 | - $query_string = explode($this->get_name.'='.$this->original_page, $_SERVER['QUERY_STRING']); |
|
299 | + $query_string = explode($this->get_name . '=' . $this->original_page, $_SERVER['QUERY_STRING']); |
|
300 | 300 | |
301 | 301 | // How start the new URL? To know it, we need to see the last character from current string |
302 | 302 | if (!in_array(substr($query_string[0], -1), array('?', '&'))) { |
303 | 303 | // Current string haven't any at end and it isn't "&" or "?" ? |
304 | 304 | // If initial string have one character at least it means that not is the first index |
305 | - if (isset($query_string[0][0])) $this->url_start = '?'.$query_string[0].'&'; |
|
306 | - else $this->url_start = '?'.$query_string[0]; |
|
305 | + if (isset($query_string[0][0])) $this->url_start = '?' . $query_string[0] . '&'; |
|
306 | + else $this->url_start = '?' . $query_string[0]; |
|
307 | 307 | } else { |
308 | 308 | // Current string already have ? or &, |
309 | - $this->url_start = '?'.$query_string[0]; |
|
309 | + $this->url_start = '?' . $query_string[0]; |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | $this->url_end = isset($query_string[1]) ? $query_string[1] : ''; |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | foreach ($gets as $get) { |
319 | 319 | if ($get != $get_name) { |
320 | 320 | // Trying to get the GET |
321 | - if (isset($_GET[$get])) $tmp .= $get.'='.$_GET[$get].'&'; |
|
321 | + if (isset($_GET[$get])) $tmp .= $get . '=' . $_GET[$get] . '&'; |
|
322 | 322 | } else { |
323 | 323 | // Pour the $tmp content to $tmp_start |
324 | 324 | if ($tmp_start == '') $tmp_start .= '?'; |
@@ -333,16 +333,16 @@ discard block |
||
333 | 333 | $this->url_start = $tmp_start; |
334 | 334 | $this->url_end = $tmp; |
335 | 335 | } |
336 | - else $this->url_start = '?'.$tmp; |
|
336 | + else $this->url_start = '?' . $tmp; |
|
337 | 337 | } |
338 | - } else{ |
|
338 | + } else { |
|
339 | 339 | // Non recicle |
340 | 340 | $this->url_start = '?'; |
341 | 341 | $this->url_end = ''; |
342 | 342 | } |
343 | 343 | |
344 | 344 | // Add the pagination |
345 | - $this->url_start .= $this->get_name.'='; |
|
345 | + $this->url_start .= $this->get_name . '='; |
|
346 | 346 | } |
347 | 347 | } |
348 | 348 | } |
@@ -189,35 +189,55 @@ discard block |
||
189 | 189 | $start = $cur_page - $this->max_links; |
190 | 190 | $end = $cur_page + $this->max_links; |
191 | 191 | |
192 | - if ($start < 1) $start = 1; |
|
193 | - if ($end > $this->total_pages) $end = $this->total_pages; |
|
192 | + if ($start < 1) { |
|
193 | + $start = 1; |
|
194 | + } |
|
195 | + if ($end > $this->total_pages) { |
|
196 | + $end = $this->total_pages; |
|
197 | + } |
|
194 | 198 | |
195 | 199 | // Showing all clickable pages (create div if class is defined) |
196 | - if ($this->style != '') $r = '<div class="'.$this->style.'">'; |
|
197 | - else $r = ''; |
|
200 | + if ($this->style != '') { |
|
201 | + $r = '<div class="'.$this->style.'">'; |
|
202 | + } else { |
|
203 | + $r = ''; |
|
204 | + } |
|
198 | 205 | |
199 | 206 | |
200 | 207 | // First / previous |
201 | 208 | if ($this->cur_page > 1) { |
202 | - if ($this->first != '') $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">'.$this->first.'</a> '; |
|
203 | - if ($this->previous != '') $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">'.$this->previous.'</a> '; |
|
209 | + if ($this->first != '') { |
|
210 | + $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">'.$this->first.'</a> '; |
|
211 | + } |
|
212 | + if ($this->previous != '') { |
|
213 | + $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">'.$this->previous.'</a> '; |
|
214 | + } |
|
204 | 215 | } |
205 | 216 | |
206 | 217 | // You can optimize this separating BEFORE and AFTER current page in two for (to avoid load "if" in each loop) |
207 | 218 | // but it would be difficult on changes |
208 | 219 | for ($n=$start; $n<=$end; $n++) { |
209 | - if ($n != $cur_page) $r .= '<a class="link" href="'. $url_start . $n . $url_end . '">'.$n.'</a> '; |
|
210 | - else $r .= '<a class="current">'.$n.'</a> '; |
|
220 | + if ($n != $cur_page) { |
|
221 | + $r .= '<a class="link" href="'. $url_start . $n . $url_end . '">'.$n.'</a> '; |
|
222 | + } else { |
|
223 | + $r .= '<a class="current">'.$n.'</a> '; |
|
224 | + } |
|
211 | 225 | } |
212 | 226 | |
213 | 227 | // next / last |
214 | 228 | if ($this->cur_page < $this->total_pages) { |
215 | - if ($this->next != '') $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">'.$this->next.'</a> '; |
|
216 | - if ($this->last != '') $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end .'">'.$this->last.'</a> '; |
|
229 | + if ($this->next != '') { |
|
230 | + $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">'.$this->next.'</a> '; |
|
231 | + } |
|
232 | + if ($this->last != '') { |
|
233 | + $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end .'">'.$this->last.'</a> '; |
|
234 | + } |
|
217 | 235 | } |
218 | 236 | |
219 | 237 | // End div (if exist) |
220 | - if ($this->style != '') $r .= '</div>'; |
|
238 | + if ($this->style != '') { |
|
239 | + $r .= '</div>'; |
|
240 | + } |
|
221 | 241 | |
222 | 242 | return $r; |
223 | 243 | } |
@@ -234,7 +254,9 @@ discard block |
||
234 | 254 | $this->original_page = $cur_page; |
235 | 255 | |
236 | 256 | // Filter values |
237 | - if (!is_numeric($cur_page) or $cur_page < 1) $cur_page = 1; |
|
257 | + if (!is_numeric($cur_page) or $cur_page < 1) { |
|
258 | + $cur_page = 1; |
|
259 | + } |
|
238 | 260 | |
239 | 261 | // Set new filtered values (is faster this method) |
240 | 262 | $this->cur_page = $cur_page; |
@@ -253,14 +275,17 @@ discard block |
||
253 | 275 | $records = $this->records; |
254 | 276 | |
255 | 277 | // Force maxium records loaded (only if is specified by user) |
256 | - if ($max_records > 0 and $max_records > $total_records) |
|
257 | - $this->total_records = $max_records; |
|
278 | + if ($max_records > 0 and $max_records > $total_records) { |
|
279 | + $this->total_records = $max_records; |
|
280 | + } |
|
258 | 281 | |
259 | 282 | // Calculate total pages that have |
260 | 283 | $total_pages = ceil($this->total_records / $records); |
261 | 284 | |
262 | 285 | // Is correct current page? |
263 | - if ($this->cur_page > $total_pages) $this->cur_page = $total_pages; |
|
286 | + if ($this->cur_page > $total_pages) { |
|
287 | + $this->cur_page = $total_pages; |
|
288 | + } |
|
264 | 289 | $this->total_pages = $total_pages; |
265 | 290 | |
266 | 291 | // Specify LIMIT to do a query |
@@ -302,8 +327,11 @@ discard block |
||
302 | 327 | if (!in_array(substr($query_string[0], -1), array('?', '&'))) { |
303 | 328 | // Current string haven't any at end and it isn't "&" or "?" ? |
304 | 329 | // If initial string have one character at least it means that not is the first index |
305 | - if (isset($query_string[0][0])) $this->url_start = '?'.$query_string[0].'&'; |
|
306 | - else $this->url_start = '?'.$query_string[0]; |
|
330 | + if (isset($query_string[0][0])) { |
|
331 | + $this->url_start = '?'.$query_string[0].'&'; |
|
332 | + } else { |
|
333 | + $this->url_start = '?'.$query_string[0]; |
|
334 | + } |
|
307 | 335 | } else { |
308 | 336 | // Current string already have ? or &, |
309 | 337 | $this->url_start = '?'.$query_string[0]; |
@@ -318,10 +346,14 @@ discard block |
||
318 | 346 | foreach ($gets as $get) { |
319 | 347 | if ($get != $get_name) { |
320 | 348 | // Trying to get the GET |
321 | - if (isset($_GET[$get])) $tmp .= $get.'='.$_GET[$get].'&'; |
|
349 | + if (isset($_GET[$get])) { |
|
350 | + $tmp .= $get.'='.$_GET[$get].'&'; |
|
351 | + } |
|
322 | 352 | } else { |
323 | 353 | // Pour the $tmp content to $tmp_start |
324 | - if ($tmp_start == '') $tmp_start .= '?'; |
|
354 | + if ($tmp_start == '') { |
|
355 | + $tmp_start .= '?'; |
|
356 | + } |
|
325 | 357 | $tmp_start .= $tmp; |
326 | 358 | $tmp = ''; |
327 | 359 | } |
@@ -332,8 +364,9 @@ discard block |
||
332 | 364 | // If have start and end |
333 | 365 | $this->url_start = $tmp_start; |
334 | 366 | $this->url_end = $tmp; |
367 | + } else { |
|
368 | + $this->url_start = '?'.$tmp; |
|
335 | 369 | } |
336 | - else $this->url_start = '?'.$tmp; |
|
337 | 370 | } |
338 | 371 | } else{ |
339 | 372 | // Non recicle |