@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | /** |
| 85 | 85 | * Script path relative to the TClientScriptManager::SCRIPT_PATH |
| 86 | 86 | */ |
| 87 | - const SCRIPT_PATH = 'datepicker'; |
|
| 87 | + const SCRIPT_PATH='datepicker'; |
|
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * @var TDatePickerClientScript validator client-script options. |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function getDateFormat() |
| 106 | 106 | { |
| 107 | - return $this->getViewState('DateFormat','dd-MM-yyyy'); |
|
| 107 | + return $this->getViewState('DateFormat', 'dd-MM-yyyy'); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function setDateFormat($value) |
| 115 | 115 | { |
| 116 | - $this->setViewState('DateFormat',$value,'dd-MM-yyyy'); |
|
| 116 | + $this->setViewState('DateFormat', $value, 'dd-MM-yyyy'); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function getShowCalendar() |
| 123 | 123 | { |
| 124 | - return $this->getViewState('ShowCalendar',true); |
|
| 124 | + return $this->getViewState('ShowCalendar', true); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function setShowCalendar($value) |
| 132 | 132 | { |
| 133 | - $this->setViewState('ShowCalendar',TPropertyValue::ensureBoolean($value),true); |
|
| 133 | + $this->setViewState('ShowCalendar', TPropertyValue::ensureBoolean($value), true); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | public function setFromYear($value) |
| 254 | 254 | { |
| 255 | - $this->setViewState('FromYear', TPropertyValue::ensureInteger($value), intval(@date('Y'))-5); |
|
| 255 | + $this->setViewState('FromYear', TPropertyValue::ensureInteger($value), intval(@date('Y')) - 5); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function getFromYear() |
| 262 | 262 | { |
| 263 | - return $this->getViewState('FromYear', intval(@date('Y'))-5); |
|
| 263 | + return $this->getViewState('FromYear', intval(@date('Y')) - 5); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /** |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | public function setUpToYear($value) |
| 270 | 270 | { |
| 271 | - $this->setViewState('UpToYear', TPropertyValue::ensureInteger($value), intval(@date('Y'))+10); |
|
| 271 | + $this->setViewState('UpToYear', TPropertyValue::ensureInteger($value), intval(@date('Y')) + 10); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | public function getUpToYear() |
| 278 | 278 | { |
| 279 | - return $this->getViewState('UpToYear', intval(@date('Y'))+10); |
|
| 279 | + return $this->getViewState('UpToYear', intval(@date('Y')) + 10); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -316,8 +316,8 @@ discard block |
||
| 316 | 316 | $this->setText(''); |
| 317 | 317 | else |
| 318 | 318 | { |
| 319 | - $date = TPropertyValue::ensureFloat($value); |
|
| 320 | - $formatter = new TSimpleDateFormatter($this->getDateFormat()); |
|
| 319 | + $date=TPropertyValue::ensureFloat($value); |
|
| 320 | + $formatter=new TSimpleDateFormatter($this->getDateFormat()); |
|
| 321 | 321 | $this->setText($formatter->format($date)); |
| 322 | 322 | } |
| 323 | 323 | } |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | public function getClientSide() |
| 378 | 378 | { |
| 379 | 379 | if($this->_clientScript===null) |
| 380 | - $this->_clientScript = $this->createClientScript(); |
|
| 380 | + $this->_clientScript=$this->createClientScript(); |
|
| 381 | 381 | return $this->_clientScript; |
| 382 | 382 | } |
| 383 | 383 | |
@@ -396,10 +396,10 @@ discard block |
||
| 396 | 396 | */ |
| 397 | 397 | public function getValidationPropertyValue() |
| 398 | 398 | { |
| 399 | - if(($text = $this->getText()) === '') |
|
| 399 | + if(($text=$this->getText())==='') |
|
| 400 | 400 | return ''; |
| 401 | - $date = $this->getTimeStamp(); |
|
| 402 | - return $date == null ? $text : $date; |
|
| 401 | + $date=$this->getTimeStamp(); |
|
| 402 | + return $date==null ? $text : $date; |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | /** |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | */ |
| 421 | 421 | public function render($writer) |
| 422 | 422 | { |
| 423 | - if($this->getInputMode() == TDatePickerInputMode::TextBox) |
|
| 423 | + if($this->getInputMode()==TDatePickerInputMode::TextBox) |
|
| 424 | 424 | { |
| 425 | 425 | parent::render($writer); |
| 426 | 426 | $this->renderDatePickerButtons($writer); |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | { |
| 444 | 444 | if($this->getShowCalendar()) |
| 445 | 445 | { |
| 446 | - switch ($this->getMode()) |
|
| 446 | + switch($this->getMode()) |
|
| 447 | 447 | { |
| 448 | 448 | case TDatePickerMode::Button: |
| 449 | 449 | $this->renderButtonDatePicker($writer); |
@@ -463,11 +463,11 @@ discard block |
||
| 463 | 463 | * @param array the input data collection |
| 464 | 464 | * @return boolean whether the data of the component has been changed |
| 465 | 465 | */ |
| 466 | - public function loadPostData($key,$values) |
|
| 466 | + public function loadPostData($key, $values) |
|
| 467 | 467 | { |
| 468 | - if($this->getInputMode() == TDatePickerInputMode::TextBox) |
|
| 468 | + if($this->getInputMode()==TDatePickerInputMode::TextBox) |
|
| 469 | 469 | return parent::loadPostData($key, $values); |
| 470 | - $value = $this->getDateFromPostData($key, $values); |
|
| 470 | + $value=$this->getDateFromPostData($key, $values); |
|
| 471 | 471 | if(!$this->getReadOnly() && $this->getText()!==$value) |
| 472 | 472 | { |
| 473 | 473 | $this->setText($value); |
@@ -485,42 +485,42 @@ discard block |
||
| 485 | 485 | */ |
| 486 | 486 | protected function getDateFromPostData($key, $values) |
| 487 | 487 | { |
| 488 | - $date = @getdate(); |
|
| 488 | + $date=@getdate(); |
|
| 489 | 489 | |
| 490 | - $pattern = $this->getDateFormat(); |
|
| 491 | - $pattern = str_replace(array('MMMM', 'MMM'), array('MM','MM'), $pattern); |
|
| 492 | - $formatter = new TSimpleDateFormatter($pattern); |
|
| 490 | + $pattern=$this->getDateFormat(); |
|
| 491 | + $pattern=str_replace(array('MMMM', 'MMM'), array('MM', 'MM'), $pattern); |
|
| 492 | + $formatter=new TSimpleDateFormatter($pattern); |
|
| 493 | 493 | |
| 494 | - $order = $formatter->getDayMonthYearOrdering(); |
|
| 494 | + $order=$formatter->getDayMonthYearOrdering(); |
|
| 495 | 495 | |
| 496 | 496 | if(isset($values[$key.'$day'])) { |
| 497 | - $day = intval($values[$key.'$day']); |
|
| 497 | + $day=intval($values[$key.'$day']); |
|
| 498 | 498 | } elseif(in_array('day', $order)) { |
| 499 | - $day = $date['mday']; |
|
| 499 | + $day=$date['mday']; |
|
| 500 | 500 | } else { |
| 501 | - $day = 1; |
|
| 501 | + $day=1; |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | if(isset($values[$key.'$month'])) |
| 505 | - $month = intval($values[$key.'$month']) + 1; |
|
| 505 | + $month=intval($values[$key.'$month']) + 1; |
|
| 506 | 506 | else |
| 507 | - $month = $date['mon']; |
|
| 507 | + $month=$date['mon']; |
|
| 508 | 508 | |
| 509 | 509 | if(isset($values[$key.'$year'])) |
| 510 | - $year = intval($values[$key.'$year']); |
|
| 510 | + $year=intval($values[$key.'$year']); |
|
| 511 | 511 | else |
| 512 | - $year = $date['year']; |
|
| 512 | + $year=$date['year']; |
|
| 513 | 513 | |
| 514 | - $s = new \DateTime; |
|
| 514 | + $s=new \DateTime; |
|
| 515 | 515 | $s->setDate($year, $month, $day); |
| 516 | - $s->setTime(0, 0 , 0); |
|
| 517 | - $date = $s->getTimeStamp(); |
|
| 516 | + $s->setTime(0, 0, 0); |
|
| 517 | + $date=$s->getTimeStamp(); |
|
| 518 | 518 | //$date = @mktime(0, 0, 0, $month, $day, $year); |
| 519 | 519 | |
| 520 | - $pattern = $this->getDateFormat(); |
|
| 521 | - $pattern = str_replace(array('MMMM', 'MMM'), array('MM','MM'), $pattern); |
|
| 520 | + $pattern=$this->getDateFormat(); |
|
| 521 | + $pattern=str_replace(array('MMMM', 'MMM'), array('MM', 'MM'), $pattern); |
|
| 522 | 522 | |
| 523 | - $formatter = new TSimpleDateFormatter($pattern); |
|
| 523 | + $formatter=new TSimpleDateFormatter($pattern); |
|
| 524 | 524 | return $formatter->format($date); |
| 525 | 525 | } |
| 526 | 526 | |
@@ -530,31 +530,31 @@ discard block |
||
| 530 | 530 | */ |
| 531 | 531 | protected function getDatePickerOptions() |
| 532 | 532 | { |
| 533 | - $options['ID'] = $this->getClientID(); |
|
| 534 | - $options['InputMode'] = $this->getInputMode(); |
|
| 535 | - $options['Format'] = $this->getDateFormat(); |
|
| 536 | - $options['FirstDayOfWeek'] = $this->getFirstDayOfWeek(); |
|
| 533 | + $options['ID']=$this->getClientID(); |
|
| 534 | + $options['InputMode']=$this->getInputMode(); |
|
| 535 | + $options['Format']=$this->getDateFormat(); |
|
| 536 | + $options['FirstDayOfWeek']=$this->getFirstDayOfWeek(); |
|
| 537 | 537 | if(($cssClass=$this->getCssClass())!=='') |
| 538 | - $options['ClassName'] = $cssClass; |
|
| 539 | - $options['CalendarStyle'] = $this->getCalendarStyle(); |
|
| 540 | - $options['FromYear'] = $this->getFromYear(); |
|
| 541 | - $options['UpToYear'] = $this->getUpToYear(); |
|
| 538 | + $options['ClassName']=$cssClass; |
|
| 539 | + $options['CalendarStyle']=$this->getCalendarStyle(); |
|
| 540 | + $options['FromYear']=$this->getFromYear(); |
|
| 541 | + $options['UpToYear']=$this->getUpToYear(); |
|
| 542 | 542 | switch($this->getMode()) |
| 543 | 543 | { |
| 544 | 544 | case TDatePickerMode::Basic: |
| 545 | 545 | break; |
| 546 | 546 | case TDatePickerMode::Clickable: |
| 547 | - $options['TriggerEvent'] = "click"; |
|
| 547 | + $options['TriggerEvent']="click"; |
|
| 548 | 548 | break; |
| 549 | 549 | default: |
| 550 | - $options['Trigger'] = $this->getDatePickerButtonID(); |
|
| 550 | + $options['Trigger']=$this->getDatePickerButtonID(); |
|
| 551 | 551 | break; |
| 552 | 552 | } |
| 553 | - $options['PositionMode'] = $this->getPositionMode(); |
|
| 553 | + $options['PositionMode']=$this->getPositionMode(); |
|
| 554 | 554 | |
| 555 | - $options = array_merge($options, $this->getCulturalOptions()); |
|
| 555 | + $options=array_merge($options, $this->getCulturalOptions()); |
|
| 556 | 556 | if($this->_clientScript!==null) |
| 557 | - $options = array_merge($options, |
|
| 557 | + $options=array_merge($options, |
|
| 558 | 558 | $this->_clientScript->getOptions()->toArray()); |
| 559 | 559 | return $options; |
| 560 | 560 | } |
@@ -565,13 +565,13 @@ discard block |
||
| 565 | 565 | */ |
| 566 | 566 | protected function getCulturalOptions() |
| 567 | 567 | { |
| 568 | - if($this->getCurrentCulture() == 'en') |
|
| 568 | + if($this->getCurrentCulture()=='en') |
|
| 569 | 569 | return array(); |
| 570 | 570 | |
| 571 | - $date = $this->getLocalizedCalendarInfo(); |
|
| 572 | - $options['MonthNames'] = $date->getMonthNames(); |
|
| 573 | - $options['AbbreviatedMonthNames'] = $date->getAbbreviatedMonthNames(); |
|
| 574 | - $options['ShortWeekDayNames'] = $date->getAbbreviatedDayNames(); |
|
| 571 | + $date=$this->getLocalizedCalendarInfo(); |
|
| 572 | + $options['MonthNames']=$date->getMonthNames(); |
|
| 573 | + $options['AbbreviatedMonthNames']=$date->getAbbreviatedMonthNames(); |
|
| 574 | + $options['ShortWeekDayNames']=$date->getAbbreviatedDayNames(); |
|
| 575 | 575 | |
| 576 | 576 | return $options; |
| 577 | 577 | } |
@@ -581,8 +581,8 @@ discard block |
||
| 581 | 581 | */ |
| 582 | 582 | protected function getCurrentCulture() |
| 583 | 583 | { |
| 584 | - $app = $this->getApplication()->getGlobalization(false); |
|
| 585 | - return $this->getCulture() == '' ? |
|
| 584 | + $app=$this->getApplication()->getGlobalization(false); |
|
| 585 | + return $this->getCulture()=='' ? |
|
| 586 | 586 | ($app ? $app->getCulture() : 'en') : $this->getCulture(); |
| 587 | 587 | } |
| 588 | 588 | |
@@ -592,8 +592,8 @@ discard block |
||
| 592 | 592 | protected function getLocalizedCalendarInfo() |
| 593 | 593 | { |
| 594 | 594 | //expensive operations |
| 595 | - $culture = $this->getCurrentCulture(); |
|
| 596 | - $info = new CultureInfo($culture); |
|
| 595 | + $culture=$this->getCurrentCulture(); |
|
| 596 | + $info=new CultureInfo($culture); |
|
| 597 | 597 | return $info->getDateTimeFormat(); |
| 598 | 598 | } |
| 599 | 599 | |
@@ -602,18 +602,18 @@ discard block |
||
| 602 | 602 | */ |
| 603 | 603 | protected function renderDropDownListCalendar($writer) |
| 604 | 604 | { |
| 605 | - if($this->getMode() == TDatePickerMode::Basic) |
|
| 605 | + if($this->getMode()==TDatePickerMode::Basic) |
|
| 606 | 606 | $this->setMode(TDatePickerMode::ImageButton); |
| 607 | 607 | parent::addAttributesToRender($writer); |
| 608 | 608 | $writer->removeAttribute('name'); |
| 609 | 609 | $writer->removeAttribute('type'); |
| 610 | 610 | $writer->addAttribute('id', $this->getClientID()); |
| 611 | 611 | |
| 612 | - if(strlen($class = $this->getCssClass()) > 0) |
|
| 612 | + if(strlen($class=$this->getCssClass()) > 0) |
|
| 613 | 613 | $writer->addAttribute('class', $class); |
| 614 | 614 | $writer->renderBeginTag('span'); |
| 615 | 615 | |
| 616 | - $date = new \DateTime; |
|
| 616 | + $date=new \DateTime; |
|
| 617 | 617 | $date->setTimeStamp($this->getTimeStampFromText()); |
| 618 | 618 | $this->renderCalendarSelections($writer, $date); |
| 619 | 619 | |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | |
| 630 | 630 | protected function hasDayPattern() |
| 631 | 631 | { |
| 632 | - $formatter = new TSimpleDateFormatter($this->getDateFormat()); |
|
| 632 | + $formatter=new TSimpleDateFormatter($this->getDateFormat()); |
|
| 633 | 633 | return ($formatter->getDayPattern()!==null); |
| 634 | 634 | } |
| 635 | 635 | |
@@ -640,15 +640,15 @@ discard block |
||
| 640 | 640 | */ |
| 641 | 641 | protected function renderCalendarSelections($writer, $date) |
| 642 | 642 | { |
| 643 | - $formatter = new TSimpleDateFormatter($this->getDateFormat()); |
|
| 643 | + $formatter=new TSimpleDateFormatter($this->getDateFormat()); |
|
| 644 | 644 | |
| 645 | 645 | foreach($formatter->getDayMonthYearOrdering() as $type) |
| 646 | 646 | { |
| 647 | - if($type == 'day') |
|
| 647 | + if($type=='day') |
|
| 648 | 648 | $this->renderCalendarDayOptions($writer, $date->format('j')); |
| 649 | - elseif($type == 'month') |
|
| 649 | + elseif($type=='month') |
|
| 650 | 650 | $this->renderCalendarMonthOptions($writer, $date->format('n')); |
| 651 | - elseif($type == 'year') |
|
| 651 | + elseif($type=='year') |
|
| 652 | 652 | $this->renderCalendarYearOptions($writer, $date->format('Y')); |
| 653 | 653 | } |
| 654 | 654 | } |
@@ -659,9 +659,9 @@ discard block |
||
| 659 | 659 | */ |
| 660 | 660 | protected function getTimeStampFromText() |
| 661 | 661 | { |
| 662 | - $pattern = $this->getDateFormat(); |
|
| 663 | - $pattern = str_replace(array('MMMM', 'MMM'), array('MM','MM'), $pattern); |
|
| 664 | - $formatter = new TSimpleDateFormatter($pattern); |
|
| 662 | + $pattern=$this->getDateFormat(); |
|
| 663 | + $pattern=str_replace(array('MMMM', 'MMM'), array('MM', 'MM'), $pattern); |
|
| 664 | + $formatter=new TSimpleDateFormatter($pattern); |
|
| 665 | 665 | return $formatter->parse($this->getText()); |
| 666 | 666 | } |
| 667 | 667 | |
@@ -671,12 +671,12 @@ discard block |
||
| 671 | 671 | * @param array list of selection options |
| 672 | 672 | * @param mixed selected key. |
| 673 | 673 | */ |
| 674 | - private function renderDropDownListOptions($writer,$options,$selected=null) |
|
| 674 | + private function renderDropDownListOptions($writer, $options, $selected=null) |
|
| 675 | 675 | { |
| 676 | 676 | foreach($options as $k => $v) |
| 677 | 677 | { |
| 678 | 678 | $writer->addAttribute('value', $k); |
| 679 | - if($k == $selected) |
|
| 679 | + if($k==$selected) |
|
| 680 | 680 | $writer->addAttribute('selected', 'selected'); |
| 681 | 681 | $writer->renderBeginTag('option'); |
| 682 | 682 | $writer->write($v); |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | */ |
| 692 | 692 | protected function renderCalendarDayOptions($writer, $selected=null) |
| 693 | 693 | { |
| 694 | - $days = $this->getDropDownDayOptions(); |
|
| 694 | + $days=$this->getDropDownDayOptions(); |
|
| 695 | 695 | $writer->addAttribute('id', $this->getClientID().TControl::CLIENT_ID_SEPARATOR.'day'); |
| 696 | 696 | $writer->addAttribute('name', $this->getUniqueID().TControl::ID_SEPARATOR.'day'); |
| 697 | 697 | $writer->addAttribute('class', 'datepicker_day_options'); |
@@ -707,12 +707,12 @@ discard block |
||
| 707 | 707 | */ |
| 708 | 708 | protected function getDropDownDayOptions() |
| 709 | 709 | { |
| 710 | - $formatter = new TSimpleDateFormatter($this->getDateFormat()); |
|
| 711 | - $days = array(); |
|
| 712 | - $requiresPadding = $formatter->getDayPattern() === 'dd'; |
|
| 713 | - for($i=1;$i<=31;$i++) |
|
| 710 | + $formatter=new TSimpleDateFormatter($this->getDateFormat()); |
|
| 711 | + $days=array(); |
|
| 712 | + $requiresPadding=$formatter->getDayPattern()==='dd'; |
|
| 713 | + for($i=1; $i <= 31; $i++) |
|
| 714 | 714 | { |
| 715 | - $days[$i] = $requiresPadding ? str_pad($i, 2, '0', STR_PAD_LEFT) : $i; |
|
| 715 | + $days[$i]=$requiresPadding ? str_pad($i, 2, '0', STR_PAD_LEFT) : $i; |
|
| 716 | 716 | } |
| 717 | 717 | return $days; |
| 718 | 718 | } |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | */ |
| 725 | 725 | protected function renderCalendarMonthOptions($writer, $selected=null) |
| 726 | 726 | { |
| 727 | - $info = $this->getLocalizedCalendarInfo(); |
|
| 727 | + $info=$this->getLocalizedCalendarInfo(); |
|
| 728 | 728 | $writer->addAttribute('id', $this->getClientID().TControl::CLIENT_ID_SEPARATOR.'month'); |
| 729 | 729 | $writer->addAttribute('name', $this->getUniqueID().TControl::ID_SEPARATOR.'month'); |
| 730 | 730 | $writer->addAttribute('class', 'datepicker_month_options'); |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | $writer->addAttribute('disabled', 'disabled'); |
| 733 | 733 | $writer->renderBeginTag('select'); |
| 734 | 734 | $this->renderDropDownListOptions($writer, |
| 735 | - $this->getLocalizedMonthNames($info), $selected-1); |
|
| 735 | + $this->getLocalizedMonthNames($info), $selected - 1); |
|
| 736 | 736 | $writer->renderEndTag(); |
| 737 | 737 | } |
| 738 | 738 | |
@@ -745,17 +745,17 @@ discard block |
||
| 745 | 745 | */ |
| 746 | 746 | protected function getLocalizedMonthNames($info) |
| 747 | 747 | { |
| 748 | - $formatter = new TSimpleDateFormatter($this->getDateFormat()); |
|
| 748 | + $formatter=new TSimpleDateFormatter($this->getDateFormat()); |
|
| 749 | 749 | switch($formatter->getMonthPattern()) |
| 750 | 750 | { |
| 751 | 751 | case 'MMM': return $info->getAbbreviatedMonthNames(); |
| 752 | 752 | case 'MM': |
| 753 | - $array = array(); |
|
| 754 | - for($i=1;$i<=12;$i++) |
|
| 755 | - $array[$i-1] = $i < 10 ? '0'.$i : $i; |
|
| 753 | + $array=array(); |
|
| 754 | + for($i=1; $i <= 12; $i++) |
|
| 755 | + $array[$i - 1]=$i < 10 ? '0'.$i : $i; |
|
| 756 | 756 | return $array; |
| 757 | 757 | case 'M': |
| 758 | - $array = array(); for($i=1;$i<=12;$i++) $array[$i-1] = $i; |
|
| 758 | + $array=array(); for($i=1; $i <= 12; $i++) $array[$i - 1]=$i; |
|
| 759 | 759 | return $array; |
| 760 | 760 | default : return $info->getMonthNames(); |
| 761 | 761 | } |
@@ -768,9 +768,9 @@ discard block |
||
| 768 | 768 | */ |
| 769 | 769 | protected function renderCalendarYearOptions($writer, $selected=null) |
| 770 | 770 | { |
| 771 | - $years = array(); |
|
| 772 | - for($i = $this->getFromYear(); $i <= $this->getUpToYear(); $i++) |
|
| 773 | - $years[$i] = $i; |
|
| 771 | + $years=array(); |
|
| 772 | + for($i=$this->getFromYear(); $i <= $this->getUpToYear(); $i++) |
|
| 773 | + $years[$i]=$i; |
|
| 774 | 774 | $writer->addAttribute('id', $this->getClientID().TControl::CLIENT_ID_SEPARATOR.'year'); |
| 775 | 775 | $writer->addAttribute('name', $this->getUniqueID().TControl::ID_SEPARATOR.'year'); |
| 776 | 776 | $writer->addAttribute('class', 'datepicker_year_options'); |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | $writer->addAttribute('id', $this->getDatePickerButtonID()); |
| 800 | 800 | $writer->addAttribute('type', 'button'); |
| 801 | 801 | $writer->addAttribute('class', $this->getCssClass().' TDatePickerButton'); |
| 802 | - $writer->addAttribute('value',$this->getButtonText()); |
|
| 802 | + $writer->addAttribute('value', $this->getButtonText()); |
|
| 803 | 803 | if(!$this->getEnabled(true)) |
| 804 | 804 | $writer->addAttribute('disabled', 'disabled'); |
| 805 | 805 | $writer->renderBeginTag("input"); |
@@ -812,8 +812,8 @@ discard block |
||
| 812 | 812 | */ |
| 813 | 813 | protected function renderImageButtonDatePicker($writer) |
| 814 | 814 | { |
| 815 | - $url = $this->getButtonImageUrl(); |
|
| 816 | - $url = empty($url) ? $this->getAssetUrl('calendar.png') : $url; |
|
| 815 | + $url=$this->getButtonImageUrl(); |
|
| 816 | + $url=empty($url) ? $this->getAssetUrl('calendar.png') : $url; |
|
| 817 | 817 | $writer->addAttribute('id', $this->getDatePickerButtonID()); |
| 818 | 818 | $writer->addAttribute('src', $url); |
| 819 | 819 | $writer->addAttribute('alt', ' '); |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | */ |
| 833 | 833 | protected function getAssetUrl($file='') |
| 834 | 834 | { |
| 835 | - $base = $this->getPage()->getClientScript()->getPradoScriptAssetUrl(); |
|
| 835 | + $base=$this->getPage()->getClientScript()->getPradoScriptAssetUrl(); |
|
| 836 | 836 | return $base.'/'.self::SCRIPT_PATH.'/'.$file; |
| 837 | 837 | } |
| 838 | 838 | |
@@ -842,8 +842,8 @@ discard block |
||
| 842 | 842 | */ |
| 843 | 843 | protected function publishCalendarStyle() |
| 844 | 844 | { |
| 845 | - $url = $this->getAssetUrl($this->getCalendarStyle().'.css'); |
|
| 846 | - $cs = $this->getPage()->getClientScript(); |
|
| 845 | + $url=$this->getAssetUrl($this->getCalendarStyle().'.css'); |
|
| 846 | + $cs=$this->getPage()->getClientScript(); |
|
| 847 | 847 | if(!$cs->isStyleSheetFileRegistered($url)) |
| 848 | 848 | $cs->registerStyleSheetFile($url, $url); |
| 849 | 849 | return $url; |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | protected function addAttributesToRender($writer) |
| 857 | 857 | { |
| 858 | 858 | parent::addAttributesToRender($writer); |
| 859 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 859 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 860 | 860 | } |
| 861 | 861 | |
| 862 | 862 | /** |
@@ -866,7 +866,7 @@ discard block |
||
| 866 | 866 | { |
| 867 | 867 | if($this->getShowCalendar()) |
| 868 | 868 | { |
| 869 | - $cs = $this->getPage()->getClientScript(); |
|
| 869 | + $cs=$this->getPage()->getClientScript(); |
|
| 870 | 870 | $cs->registerPradoScript("datepicker"); |
| 871 | 871 | } |
| 872 | 872 | } |
@@ -875,16 +875,16 @@ discard block |
||
| 875 | 875 | { |
| 876 | 876 | if($this->getShowCalendar()) |
| 877 | 877 | { |
| 878 | - $cs = $this->getPage()->getClientScript(); |
|
| 878 | + $cs=$this->getPage()->getClientScript(); |
|
| 879 | 879 | if(!$cs->isEndScriptRegistered('TDatePicker.spacer')) |
| 880 | 880 | { |
| 881 | - $spacer = $this->getAssetUrl('spacer.gif'); |
|
| 882 | - $code = "Prado.WebUI.TDatePicker.spacer = '$spacer';"; |
|
| 881 | + $spacer=$this->getAssetUrl('spacer.gif'); |
|
| 882 | + $code="Prado.WebUI.TDatePicker.spacer = '$spacer';"; |
|
| 883 | 883 | $cs->registerEndScript('TDatePicker.spacer', $code); |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | - $options = TJavaScript::encode($this->getDatePickerOptions()); |
|
| 887 | - $code = "new Prado.WebUI.TDatePicker($options);"; |
|
| 886 | + $options=TJavaScript::encode($this->getDatePickerOptions()); |
|
| 887 | + $code="new Prado.WebUI.TDatePicker($options);"; |
|
| 888 | 888 | $cs->registerEndScript("prado:".$this->getClientID(), $code); |
| 889 | 889 | } |
| 890 | 890 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * A list of tokens and their function call. |
| 55 | 55 | * @var array |
| 56 | 56 | */ |
| 57 | - protected $tokens = array( |
|
| 57 | + protected $tokens=array( |
|
| 58 | 58 | 'G'=>'Era', |
| 59 | 59 | 'y'=>'Year', |
| 60 | 60 | 'M'=>'Month', |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * A list of methods, to be used by the token function calls. |
| 79 | 79 | * @var array |
| 80 | 80 | */ |
| 81 | - protected $methods = array(); |
|
| 81 | + protected $methods=array(); |
|
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * The DateTimeFormatInfo, containing culture specific patterns and names. |
@@ -94,16 +94,16 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | function __construct($formatInfo=null) |
| 96 | 96 | { |
| 97 | - if($formatInfo === null) |
|
| 98 | - $this->formatInfo = DateTimeFormatInfo::getInvariantInfo(); |
|
| 97 | + if($formatInfo===null) |
|
| 98 | + $this->formatInfo=DateTimeFormatInfo::getInvariantInfo(); |
|
| 99 | 99 | else if($formatInfo instanceof CultureInfo) |
| 100 | - $this->formatInfo = $formatInfo->DateTimeFormat; |
|
| 100 | + $this->formatInfo=$formatInfo->DateTimeFormat; |
|
| 101 | 101 | else if($formatInfo instanceof DateTimeFormatInfo) |
| 102 | - $this->formatInfo = $formatInfo; |
|
| 102 | + $this->formatInfo=$formatInfo; |
|
| 103 | 103 | else |
| 104 | - $this->formatInfo = DateTimeFormatInfo::getInstance($formatInfo); |
|
| 104 | + $this->formatInfo=DateTimeFormatInfo::getInstance($formatInfo); |
|
| 105 | 105 | |
| 106 | - $this->methods = get_class_methods($this); |
|
| 106 | + $this->methods=get_class_methods($this); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -113,44 +113,44 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function format($time, $pattern='F', $charset='UTF-8') |
| 115 | 115 | { |
| 116 | - if (is_numeric($time)) //assumes unix epoch |
|
| 117 | - $time = floatval($time); |
|
| 116 | + if(is_numeric($time)) //assumes unix epoch |
|
| 117 | + $time=floatval($time); |
|
| 118 | 118 | else if(is_string($time)) |
| 119 | - $time = @strtotime($time); |
|
| 119 | + $time=@strtotime($time); |
|
| 120 | 120 | |
| 121 | - if($pattern === null) |
|
| 122 | - $pattern = 'F'; |
|
| 121 | + if($pattern===null) |
|
| 122 | + $pattern='F'; |
|
| 123 | 123 | |
| 124 | - $date = new \DateTime; |
|
| 124 | + $date=new \DateTime; |
|
| 125 | 125 | $date->setTimestamp($time); |
| 126 | 126 | |
| 127 | - $pattern = $this->getPattern($pattern); |
|
| 127 | + $pattern=$this->getPattern($pattern); |
|
| 128 | 128 | |
| 129 | - $tokens = $this->getTokens($pattern); |
|
| 129 | + $tokens=$this->getTokens($pattern); |
|
| 130 | 130 | |
| 131 | - for($i = 0, $k = count($tokens); $i<$k; ++$i) |
|
| 131 | + for($i=0, $k=count($tokens); $i < $k; ++$i) |
|
| 132 | 132 | { |
| 133 | - $pattern = $tokens[$i]; |
|
| 134 | - if($pattern{0} == "'" |
|
| 135 | - && $pattern{strlen($pattern)-1} == "'") |
|
| 133 | + $pattern=$tokens[$i]; |
|
| 134 | + if($pattern{0}=="'" |
|
| 135 | + && $pattern{strlen($pattern) - 1}=="'") |
|
| 136 | 136 | { |
| 137 | - $sub = preg_replace('/(^\')|(\'$)/','',$pattern); |
|
| 138 | - $tokens[$i] = str_replace('``````','\'',$sub); |
|
| 137 | + $sub=preg_replace('/(^\')|(\'$)/', '', $pattern); |
|
| 138 | + $tokens[$i]=str_replace('``````', '\'', $sub); |
|
| 139 | 139 | } |
| 140 | - else if($pattern == '``````') |
|
| 140 | + else if($pattern=='``````') |
|
| 141 | 141 | { |
| 142 | - $tokens[$i] = '\''; |
|
| 142 | + $tokens[$i]='\''; |
|
| 143 | 143 | } |
| 144 | 144 | else |
| 145 | 145 | { |
| 146 | - $function = $this->getFunctionName($pattern); |
|
| 147 | - if($function != null) |
|
| 146 | + $function=$this->getFunctionName($pattern); |
|
| 147 | + if($function!=null) |
|
| 148 | 148 | { |
| 149 | - $fName = 'get'.$function; |
|
| 149 | + $fName='get'.$function; |
|
| 150 | 150 | if(in_array($fName, $this->methods)) |
| 151 | 151 | { |
| 152 | - $rs = $this->$fName($date, $pattern); |
|
| 153 | - $tokens[$i] = $rs; |
|
| 152 | + $rs=$this->$fName($date, $pattern); |
|
| 153 | + $tokens[$i]=$rs; |
|
| 154 | 154 | } |
| 155 | 155 | else |
| 156 | 156 | throw new |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - return I18N_toEncoding(implode('',$tokens), $charset); |
|
| 162 | + return I18N_toEncoding(implode('', $tokens), $charset); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | protected function getPattern($pattern) |
| 188 | 188 | { |
| 189 | - if(is_array($pattern) && count($pattern) == 2) |
|
| 189 | + if(is_array($pattern) && count($pattern)==2) |
|
| 190 | 190 | { |
| 191 | 191 | return $this->formatInfo->formatDateTime( |
| 192 | 192 | $this->getPattern($pattern[0]), |
@@ -275,36 +275,36 @@ discard block |
||
| 275 | 275 | */ |
| 276 | 276 | protected function getTokens($pattern) |
| 277 | 277 | { |
| 278 | - $char = null; |
|
| 279 | - $tokens = array(); |
|
| 280 | - $token = null; |
|
| 278 | + $char=null; |
|
| 279 | + $tokens=array(); |
|
| 280 | + $token=null; |
|
| 281 | 281 | |
| 282 | - $text = false; |
|
| 283 | - $pattern = preg_replace("/''/", '``````', $pattern); |
|
| 282 | + $text=false; |
|
| 283 | + $pattern=preg_replace("/''/", '``````', $pattern); |
|
| 284 | 284 | |
| 285 | - for($i = 0; $i < strlen($pattern); $i++) |
|
| 285 | + for($i=0; $i < strlen($pattern); $i++) |
|
| 286 | 286 | { |
| 287 | - if($char==null || $pattern{$i} == $char || $text) |
|
| 287 | + if($char==null || $pattern{$i}==$char || $text) |
|
| 288 | 288 | { |
| 289 | - $token .= $pattern{$i}; |
|
| 289 | + $token.=$pattern{$i}; |
|
| 290 | 290 | } |
| 291 | 291 | else |
| 292 | 292 | { |
| 293 | - $tokens[] = str_replace("","'",$token); |
|
| 294 | - $token = $pattern{$i}; |
|
| 293 | + $tokens[]=str_replace("", "'", $token); |
|
| 294 | + $token=$pattern{$i}; |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if($pattern{$i} == "'" && $text == false) |
|
| 298 | - $text = true; |
|
| 299 | - else if($text && $pattern{$i} == "'" && $char == "'") |
|
| 300 | - $text = true; |
|
| 301 | - else if($text && $char != "'" && $pattern{$i} == "'") |
|
| 302 | - $text = false; |
|
| 297 | + if($pattern{$i}=="'" && $text==false) |
|
| 298 | + $text=true; |
|
| 299 | + else if($text && $pattern{$i}=="'" && $char=="'") |
|
| 300 | + $text=true; |
|
| 301 | + else if($text && $char!="'" && $pattern{$i}=="'") |
|
| 302 | + $text=false; |
|
| 303 | 303 | |
| 304 | - $char = $pattern{$i}; |
|
| 304 | + $char=$pattern{$i}; |
|
| 305 | 305 | |
| 306 | 306 | } |
| 307 | - $tokens[] = $token; |
|
| 307 | + $tokens[]=$token; |
|
| 308 | 308 | return $tokens; |
| 309 | 309 | } |
| 310 | 310 | |
@@ -348,9 +348,9 @@ discard block |
||
| 348 | 348 | case 'MM': |
| 349 | 349 | return $date->format('m'); |
| 350 | 350 | case 'MMM': |
| 351 | - return $this->formatInfo->AbbreviatedMonthNames[$date->format('n')-1]; |
|
| 351 | + return $this->formatInfo->AbbreviatedMonthNames[$date->format('n') - 1]; |
|
| 352 | 352 | case 'MMMM': |
| 353 | - return $this->formatInfo->MonthNames[$date->format('n')-1]; |
|
| 353 | + return $this->formatInfo->MonthNames[$date->format('n') - 1]; |
|
| 354 | 354 | default: |
| 355 | 355 | throw new Exception('The pattern for month is "M", "MM", "MMM", or "MMMM".'); |
| 356 | 356 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | */ |
| 369 | 369 | protected function getDayInWeek($date, $pattern='EEEE') |
| 370 | 370 | { |
| 371 | - $day = $date->format('w'); |
|
| 371 | + $day=$date->format('w'); |
|
| 372 | 372 | switch($pattern) |
| 373 | 373 | { |
| 374 | 374 | case 'E': |
@@ -414,10 +414,10 @@ discard block |
||
| 414 | 414 | */ |
| 415 | 415 | protected function getEra($date, $pattern='G') |
| 416 | 416 | { |
| 417 | - if($pattern != 'G') |
|
| 417 | + if($pattern!='G') |
|
| 418 | 418 | throw new Exception('The pattern for era is "G".'); |
| 419 | 419 | |
| 420 | - $year = $date->format('Y'); |
|
| 420 | + $year=$date->format('Y'); |
|
| 421 | 421 | if($year > 0) |
| 422 | 422 | return $this->formatInfo->getEra(1); |
| 423 | 423 | else |
@@ -452,11 +452,11 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | protected function getAMPM($date, $pattern='a') |
| 454 | 454 | { |
| 455 | - if($pattern != 'a') |
|
| 455 | + if($pattern!='a') |
|
| 456 | 456 | throw new Exception('The pattern for AM/PM marker is "a".'); |
| 457 | 457 | |
| 458 | - $hour = $date->format('G'); |
|
| 459 | - $ampm = (int)($hour/12); |
|
| 458 | + $hour=$date->format('G'); |
|
| 459 | + $ampm=(int) ($hour / 12); |
|
| 460 | 460 | return $this->formatInfo->AMPMMarkers[$ampm]; |
| 461 | 461 | } |
| 462 | 462 | |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | */ |
| 530 | 530 | protected function getTimeZone($date, $pattern='z') |
| 531 | 531 | { |
| 532 | - if($pattern != 'z') |
|
| 532 | + if($pattern!='z') |
|
| 533 | 533 | throw new Exception('The pattern for time zone is "z".'); |
| 534 | 534 | |
| 535 | 535 | return $date->format('T'); |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | protected function getDayInYear($date, $pattern='D') |
| 545 | 545 | { |
| 546 | - if($pattern != 'D') |
|
| 546 | + if($pattern!='D') |
|
| 547 | 547 | throw new Exception('The pattern for day in year is "D".'); |
| 548 | 548 | |
| 549 | 549 | return $date->format('z'); |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | */ |
| 558 | 558 | protected function getDayInMonth($date, $pattern='FF') |
| 559 | 559 | { |
| 560 | - switch ($pattern) { |
|
| 560 | + switch($pattern) { |
|
| 561 | 561 | case 'F': |
| 562 | 562 | return $date->format('j'); |
| 563 | 563 | case 'FF': |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | */ |
| 576 | 576 | protected function getWeekInYear($date, $pattern='w') |
| 577 | 577 | { |
| 578 | - if($pattern != 'w') |
|
| 578 | + if($pattern!='w') |
|
| 579 | 579 | throw new Exception('The pattern for week in year is "w".'); |
| 580 | 580 | |
| 581 | 581 | return $date->format('W'); |
@@ -588,10 +588,10 @@ discard block |
||
| 588 | 588 | */ |
| 589 | 589 | protected function getWeekInMonth($date, $pattern='W') |
| 590 | 590 | { |
| 591 | - if($pattern != 'W') |
|
| 591 | + if($pattern!='W') |
|
| 592 | 592 | throw new Exception('The pattern for week in month is "W".'); |
| 593 | 593 | |
| 594 | - $firstInMonth = clone($date); |
|
| 594 | + $firstInMonth=clone($date); |
|
| 595 | 595 | $firstInMonth->setDate($firstInMonth->format('Y'), $firstInMonth->format('m'), 1); |
| 596 | 596 | return $date->format('W') - $firstInMonth->format('W'); |
| 597 | 597 | } |
@@ -604,10 +604,10 @@ discard block |
||
| 604 | 604 | */ |
| 605 | 605 | protected function getHourInDay($date, $pattern='k') |
| 606 | 606 | { |
| 607 | - if($pattern != 'k') |
|
| 607 | + if($pattern!='k') |
|
| 608 | 608 | throw new Exception('The pattern for hour in day is "k".'); |
| 609 | 609 | |
| 610 | - return $date->format('G')+1; |
|
| 610 | + return $date->format('G') + 1; |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | /** |
@@ -618,9 +618,9 @@ discard block |
||
| 618 | 618 | */ |
| 619 | 619 | protected function getHourInAMPM($date, $pattern='K') |
| 620 | 620 | { |
| 621 | - if($pattern != 'K') |
|
| 621 | + if($pattern!='K') |
|
| 622 | 622 | throw new Exception('The pattern for hour in AM/PM is "K".'); |
| 623 | 623 | |
| 624 | - return $date->format('g')+1; |
|
| 624 | + return $date->format('g') + 1; |
|
| 625 | 625 | } |
| 626 | 626 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | private $_port=11211; |
| 107 | 107 | |
| 108 | - private $_timeout = 360; |
|
| 108 | + private $_timeout=360; |
|
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * @var integer Controls the minimum value length before attempting to compress automatically. |
@@ -156,26 +156,26 @@ discard block |
||
| 156 | 156 | if(!extension_loaded('memcached') && $this->_useMemcached) |
| 157 | 157 | throw new TConfigurationException('memcached_extension_required'); |
| 158 | 158 | |
| 159 | - $this->_cache = $this->_useMemcached ? new Memcached : new Memcache; |
|
| 159 | + $this->_cache=$this->_useMemcached ? new Memcached : new Memcache; |
|
| 160 | 160 | $this->loadConfig($config); |
| 161 | 161 | if(count($this->_servers)) |
| 162 | 162 | { |
| 163 | 163 | foreach($this->_servers as $server) |
| 164 | 164 | { |
| 165 | 165 | Prado::trace('Adding server '.$server['Host'].' from serverlist', '\Prado\Caching\TMemCache'); |
| 166 | - if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'], |
|
| 167 | - $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false) |
|
| 168 | - throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']); |
|
| 166 | + if($this->_cache->addServer($server['Host'], $server['Port'], $server['Persistent'], |
|
| 167 | + $server['Weight'], $server['Timeout'], $server['RetryInterval'])===false) |
|
| 168 | + throw new TConfigurationException('memcache_connection_failed', $server['Host'], $server['Port']); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | else |
| 172 | 172 | { |
| 173 | 173 | Prado::trace('Adding server '.$this->_host, '\Prado\Caching\TMemCache'); |
| 174 | - if($this->_cache->addServer($this->_host,$this->_port)===false) |
|
| 175 | - throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port); |
|
| 174 | + if($this->_cache->addServer($this->_host, $this->_port)===false) |
|
| 175 | + throw new TConfigurationException('memcache_connection_failed', $this->_host, $this->_port); |
|
| 176 | 176 | } |
| 177 | 177 | if($this->_threshold!==0) |
| 178 | - $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings); |
|
| 178 | + $this->_cache->setCompressThreshold($this->_threshold, $this->_minSavings); |
|
| 179 | 179 | $this->_initialized=true; |
| 180 | 180 | parent::init($config); |
| 181 | 181 | } |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | throw new TConfigurationException('memcache_serverport_required'); |
| 199 | 199 | if(!is_numeric($port)) |
| 200 | 200 | throw new TConfigurationException('memcache_serverport_invalid'); |
| 201 | - $server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true); |
|
| 202 | - $checks = array( |
|
| 201 | + $server=array('Host'=>$host, 'Port'=>$port, 'Weight'=>1, 'Timeout'=>1800, 'RetryInterval'=>15, 'Persistent'=>true); |
|
| 202 | + $checks=array( |
|
| 203 | 203 | 'Weight'=>'memcache_serverweight_invalid', |
| 204 | 204 | 'Timeout'=>'memcache_servertimeout_invalid', |
| 205 | 205 | 'RetryInterval'=>'memcach_serverretryinterval_invalid' |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | else if($value!==null) |
| 213 | 213 | throw new TConfigurationException($exception); |
| 214 | 214 | } |
| 215 | - $server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
| 215 | + $server['Persistent']=TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
| 216 | 216 | $this->_servers[]=$server; |
| 217 | 217 | } |
| 218 | 218 | } |
@@ -338,12 +338,12 @@ discard block |
||
| 338 | 338 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 339 | 339 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 340 | 340 | */ |
| 341 | - protected function setValue($key,$value,$expire) |
|
| 341 | + protected function setValue($key, $value, $expire) |
|
| 342 | 342 | { |
| 343 | 343 | if($this->_useMemcached) { |
| 344 | - return $this->_cache->set($key,$value,$expire); |
|
| 344 | + return $this->_cache->set($key, $value, $expire); |
|
| 345 | 345 | } else { |
| 346 | - return $this->_cache->set($key,$value,0,$expire); |
|
| 346 | + return $this->_cache->set($key, $value, 0, $expire); |
|
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | |
@@ -356,12 +356,12 @@ discard block |
||
| 356 | 356 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 357 | 357 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 358 | 358 | */ |
| 359 | - protected function addValue($key,$value,$expire) |
|
| 359 | + protected function addValue($key, $value, $expire) |
|
| 360 | 360 | { |
| 361 | 361 | if($this->_useMemcached) { |
| 362 | - $this->_cache->add($key,$value,$expire); |
|
| 362 | + $this->_cache->add($key, $value, $expire); |
|
| 363 | 363 | } else { |
| 364 | - return $this->_cache->add($key,$value,0,$expire); |
|
| 364 | + return $this->_cache->add($key, $value, 0, $expire); |
|
| 365 | 365 | } |
| 366 | 366 | } |
| 367 | 367 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * Charset, default is 'UTF-8' |
| 60 | 60 | * @var string |
| 61 | 61 | */ |
| 62 | - private $charset = 'UTF-8'; |
|
| 62 | + private $charset='UTF-8'; |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * Constructor, create a new date time formatter. |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function setPattern($pattern) |
| 87 | 87 | { |
| 88 | - $this->pattern = $pattern; |
|
| 88 | + $this->pattern=$pattern; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function setCharset($charset) |
| 103 | 103 | { |
| 104 | - $this->charset = $charset; |
|
| 104 | + $this->charset=$charset; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -111,17 +111,17 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function format($value) |
| 113 | 113 | { |
| 114 | - $dt = $this->getDate($value); |
|
| 115 | - $bits['yyyy'] = $dt->format('Y'); |
|
| 116 | - $bits['yy'] = $dt->format('y'); |
|
| 114 | + $dt=$this->getDate($value); |
|
| 115 | + $bits['yyyy']=$dt->format('Y'); |
|
| 116 | + $bits['yy']=$dt->format('y'); |
|
| 117 | 117 | |
| 118 | - $bits['MM'] = $dt->format('m'); |
|
| 119 | - $bits['M'] = $dt->format('n'); |
|
| 118 | + $bits['MM']=$dt->format('m'); |
|
| 119 | + $bits['M']=$dt->format('n'); |
|
| 120 | 120 | |
| 121 | - $bits['dd'] = $dt->format('d'); |
|
| 122 | - $bits['d'] = $dt->format('j'); |
|
| 121 | + $bits['dd']=$dt->format('d'); |
|
| 122 | + $bits['d']=$dt->format('j'); |
|
| 123 | 123 | |
| 124 | - $pattern = preg_replace('/M{3,4}/', 'MM', $this->pattern); |
|
| 124 | + $pattern=preg_replace('/M{3,4}/', 'MM', $this->pattern); |
|
| 125 | 125 | return str_replace(array_keys($bits), $bits, $pattern); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | public function getDayMonthYearOrdering() |
| 160 | 160 | { |
| 161 | - $ordering = array(); |
|
| 162 | - if(is_int($day= strpos($this->pattern, 'd'))) |
|
| 163 | - $ordering['day'] = $day; |
|
| 164 | - if(is_int($month= strpos($this->pattern, 'M'))) |
|
| 165 | - $ordering['month'] = $month; |
|
| 166 | - if(is_int($year= strpos($this->pattern, 'yy'))) |
|
| 167 | - $ordering['year'] = $year; |
|
| 161 | + $ordering=array(); |
|
| 162 | + if(is_int($day=strpos($this->pattern, 'd'))) |
|
| 163 | + $ordering['day']=$day; |
|
| 164 | + if(is_int($month=strpos($this->pattern, 'M'))) |
|
| 165 | + $ordering['month']=$month; |
|
| 166 | + if(is_int($year=strpos($this->pattern, 'yy'))) |
|
| 167 | + $ordering['year']=$year; |
|
| 168 | 168 | asort($ordering); |
| 169 | 169 | return array_keys($ordering); |
| 170 | 170 | } |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | { |
| 179 | 179 | if(is_numeric($value)) |
| 180 | 180 | { |
| 181 | - $date = new \DateTime; |
|
| 181 | + $date=new \DateTime; |
|
| 182 | 182 | $date->setTimeStamp($value); |
| 183 | 183 | } else { |
| 184 | - $date = new \DateTime($value); |
|
| 184 | + $date=new \DateTime($value); |
|
| 185 | 185 | } |
| 186 | 186 | return $date; |
| 187 | 187 | } |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | public function isValidDate($value) |
| 193 | 193 | { |
| 194 | - if($value === null) { |
|
| 194 | + if($value===null) { |
|
| 195 | 195 | return false; |
| 196 | 196 | } else { |
| 197 | - return $this->parse($value, false) !== null; |
|
| 197 | + return $this->parse($value, false)!==null; |
|
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @return int date time stamp |
| 205 | 205 | * @throws TInvalidDataValueException if date string is malformed. |
| 206 | 206 | */ |
| 207 | - public function parse($value,$defaultToCurrentTime=true) |
|
| 207 | + public function parse($value, $defaultToCurrentTime=true) |
|
| 208 | 208 | { |
| 209 | 209 | if(is_int($value) || is_float($value)) |
| 210 | 210 | return $value; |
@@ -213,111 +213,111 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | if(empty($this->pattern)) return time(); |
| 215 | 215 | |
| 216 | - $date = time(); |
|
| 216 | + $date=time(); |
|
| 217 | 217 | |
| 218 | 218 | if($this->length(trim($value)) < 1) |
| 219 | 219 | return $defaultToCurrentTime ? $date : null; |
| 220 | 220 | |
| 221 | - $pattern = $this->pattern; |
|
| 221 | + $pattern=$this->pattern; |
|
| 222 | 222 | |
| 223 | - $i_val = 0; |
|
| 224 | - $i_format = 0; |
|
| 225 | - $pattern_length = $this->length($pattern); |
|
| 226 | - $c = ''; |
|
| 223 | + $i_val=0; |
|
| 224 | + $i_format=0; |
|
| 225 | + $pattern_length=$this->length($pattern); |
|
| 226 | + $c=''; |
|
| 227 | 227 | $token=''; |
| 228 | 228 | $x=null; $y=null; |
| 229 | 229 | |
| 230 | 230 | |
| 231 | 231 | if($defaultToCurrentTime) |
| 232 | 232 | { |
| 233 | - $year = "{$date['year']}"; |
|
| 234 | - $month = $date['mon']; |
|
| 235 | - $day = $date['mday']; |
|
| 233 | + $year="{$date['year']}"; |
|
| 234 | + $month=$date['mon']; |
|
| 235 | + $day=$date['mday']; |
|
| 236 | 236 | } |
| 237 | 237 | else |
| 238 | 238 | { |
| 239 | - $year = null; |
|
| 240 | - $month = null; |
|
| 241 | - $day = null; |
|
| 239 | + $year=null; |
|
| 240 | + $month=null; |
|
| 241 | + $day=null; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - while ($i_format < $pattern_length) |
|
| 244 | + while($i_format < $pattern_length) |
|
| 245 | 245 | { |
| 246 | - $c = $this->charAt($pattern,$i_format); |
|
| 246 | + $c=$this->charAt($pattern, $i_format); |
|
| 247 | 247 | $token=''; |
| 248 | - while ($this->charEqual($pattern, $i_format, $c) |
|
| 248 | + while($this->charEqual($pattern, $i_format, $c) |
|
| 249 | 249 | && ($i_format < $pattern_length)) |
| 250 | 250 | { |
| 251 | - $token .= $this->charAt($pattern, $i_format++); |
|
| 251 | + $token.=$this->charAt($pattern, $i_format++); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - if ($token=='yyyy' || $token=='yy' || $token=='y') |
|
| 254 | + if($token=='yyyy' || $token=='yy' || $token=='y') |
|
| 255 | 255 | { |
| 256 | - if ($token=='yyyy') { $x=4;$y=4; } |
|
| 257 | - if ($token=='yy') { $x=2;$y=2; } |
|
| 258 | - if ($token=='y') { $x=2;$y=4; } |
|
| 259 | - $year = $this->getInteger($value,$i_val,$x,$y); |
|
| 260 | - if($year === null) |
|
| 256 | + if($token=='yyyy') { $x=4; $y=4; } |
|
| 257 | + if($token=='yy') { $x=2; $y=2; } |
|
| 258 | + if($token=='y') { $x=2; $y=4; } |
|
| 259 | + $year=$this->getInteger($value, $i_val, $x, $y); |
|
| 260 | + if($year===null) |
|
| 261 | 261 | return null; |
| 262 | 262 | //throw new TInvalidDataValueException('Invalid year', $value); |
| 263 | - $i_val += strlen($year); |
|
| 264 | - if(strlen($year) == 2) |
|
| 263 | + $i_val+=strlen($year); |
|
| 264 | + if(strlen($year)==2) |
|
| 265 | 265 | { |
| 266 | - $iYear = (int)$year; |
|
| 266 | + $iYear=(int) $year; |
|
| 267 | 267 | if($iYear > 70) |
| 268 | - $year = $iYear + 1900; |
|
| 268 | + $year=$iYear + 1900; |
|
| 269 | 269 | else |
| 270 | - $year = $iYear + 2000; |
|
| 270 | + $year=$iYear + 2000; |
|
| 271 | 271 | } |
| 272 | - $year = (int)$year; |
|
| 272 | + $year=(int) $year; |
|
| 273 | 273 | } |
| 274 | 274 | elseif($token=='MM' || $token=='M') |
| 275 | 275 | { |
| 276 | - $month=$this->getInteger($value,$i_val, |
|
| 277 | - $this->length($token),2); |
|
| 278 | - $iMonth = (int)$month; |
|
| 279 | - if($month === null || $iMonth < 1 || $iMonth > 12 ) |
|
| 276 | + $month=$this->getInteger($value, $i_val, |
|
| 277 | + $this->length($token), 2); |
|
| 278 | + $iMonth=(int) $month; |
|
| 279 | + if($month===null || $iMonth < 1 || $iMonth > 12) |
|
| 280 | 280 | return null; |
| 281 | 281 | //throw new TInvalidDataValueException('Invalid month', $value); |
| 282 | - $i_val += strlen($month); |
|
| 283 | - $month = $iMonth; |
|
| 282 | + $i_val+=strlen($month); |
|
| 283 | + $month=$iMonth; |
|
| 284 | 284 | } |
| 285 | - elseif ($token=='dd' || $token=='d') |
|
| 285 | + elseif($token=='dd' || $token=='d') |
|
| 286 | 286 | { |
| 287 | - $day = $this->getInteger($value,$i_val, |
|
| 287 | + $day=$this->getInteger($value, $i_val, |
|
| 288 | 288 | $this->length($token), 2); |
| 289 | - $iDay = (int)$day; |
|
| 290 | - if($day === null || $iDay < 1 || $iDay >31) |
|
| 289 | + $iDay=(int) $day; |
|
| 290 | + if($day===null || $iDay < 1 || $iDay > 31) |
|
| 291 | 291 | return null; |
| 292 | 292 | //throw new TInvalidDataValueException('Invalid day', $value); |
| 293 | - $i_val += strlen($day); |
|
| 294 | - $day = $iDay; |
|
| 293 | + $i_val+=strlen($day); |
|
| 294 | + $day=$iDay; |
|
| 295 | 295 | } |
| 296 | 296 | else |
| 297 | 297 | { |
| 298 | - if($this->substring($value, $i_val, $this->length($token)) != $token) |
|
| 298 | + if($this->substring($value, $i_val, $this->length($token))!=$token) |
|
| 299 | 299 | return null; |
| 300 | 300 | //throw new TInvalidDataValueException("Subpattern '{$this->pattern}' mismatch", $value); |
| 301 | 301 | else |
| 302 | - $i_val += $this->length($token); |
|
| 302 | + $i_val+=$this->length($token); |
|
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | - if ($i_val != $this->length($value)) |
|
| 305 | + if($i_val!=$this->length($value)) |
|
| 306 | 306 | return null; |
| 307 | 307 | //throw new TInvalidDataValueException("Pattern '{$this->pattern}' mismatch", $value); |
| 308 | - if(!$defaultToCurrentTime && ($month === null || $day === null || $year === null)) |
|
| 308 | + if(!$defaultToCurrentTime && ($month===null || $day===null || $year===null)) |
|
| 309 | 309 | return null; |
| 310 | 310 | else |
| 311 | 311 | { |
| 312 | 312 | if(empty($year)) { |
| 313 | - $year = date('Y'); |
|
| 313 | + $year=date('Y'); |
|
| 314 | 314 | } |
| 315 | - $day = (int)$day <= 0 ? 1 : (int)$day; |
|
| 316 | - $month = (int)$month <= 0 ? 1 : (int)$month; |
|
| 315 | + $day=(int) $day <= 0 ? 1 : (int) $day; |
|
| 316 | + $month=(int) $month <= 0 ? 1 : (int) $month; |
|
| 317 | 317 | |
| 318 | - $s = new \DateTime; |
|
| 318 | + $s=new \DateTime; |
|
| 319 | 319 | $s->setDate($year, $month, $day); |
| 320 | - $s->setTime(0, 0 , 0); |
|
| 320 | + $s->setTime(0, 0, 0); |
|
| 321 | 321 | return $s->getTimeStamp(); |
| 322 | 322 | } |
| 323 | 323 | } |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | */ |
| 353 | 353 | private function charEqual($string, $pos, $char) |
| 354 | 354 | { |
| 355 | - return $this->charAt($string, $pos) == $char; |
|
| 355 | + return $this->charAt($string, $pos)==$char; |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -363,15 +363,15 @@ discard block |
||
| 363 | 363 | * @param int maximum integer length |
| 364 | 364 | * @return string integer portion of the string, null otherwise |
| 365 | 365 | */ |
| 366 | - private function getInteger($str,$i,$minlength,$maxlength) |
|
| 366 | + private function getInteger($str, $i, $minlength, $maxlength) |
|
| 367 | 367 | { |
| 368 | 368 | //match for digits backwards |
| 369 | - for ($x = $maxlength; $x >= $minlength; $x--) |
|
| 369 | + for($x=$maxlength; $x >= $minlength; $x--) |
|
| 370 | 370 | { |
| 371 | - $token= $this->substring($str, $i,$x); |
|
| 372 | - if ($this->length($token) < $minlength) |
|
| 371 | + $token=$this->substring($str, $i, $x); |
|
| 372 | + if($this->length($token) < $minlength) |
|
| 373 | 373 | return null; |
| 374 | - if (preg_match('/^\d+$/', $token)) |
|
| 374 | + if(preg_match('/^\d+$/', $token)) |
|
| 375 | 375 | return $token; |
| 376 | 376 | } |
| 377 | 377 | return null; |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | die('Must be run from the command line'); |
| 14 | 14 | |
| 15 | 15 | // Locate composer's autoloader |
| 16 | -if(file_exists($autoloader = realpath(__DIR__ . '/../vendor/autoload.php'))) |
|
| 16 | +if(file_exists($autoloader=realpath(__DIR__.'/../vendor/autoload.php'))) |
|
| 17 | 17 | { |
| 18 | 18 | // if we are running inside a prado repo checkout, get out of bin/ |
| 19 | 19 | include($autoloader); |
| 20 | -} elseif(file_exists($autoloader = realpath(__DIR__ . '/../../../autoload.php'))) { |
|
| 20 | +} elseif(file_exists($autoloader=realpath(__DIR__.'/../../../autoload.php'))) { |
|
| 21 | 21 | // if we are running from inside an application's vendor/ directory, get out of pradosoft/prado/bin/ |
| 22 | 22 | include($autoloader); |
| 23 | 23 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function addActionClass($class) |
| 71 | 71 | { |
| 72 | - $this->_actions[$class] = new $class; |
|
| 72 | + $this->_actions[$class]=new $class; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | public static function getInstance() |
| 79 | 79 | { |
| 80 | 80 | static $instance; |
| 81 | - if($instance === null) |
|
| 82 | - $instance = new self; |
|
| 81 | + if($instance===null) |
|
| 82 | + $instance=new self; |
|
| 83 | 83 | return $instance; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -96,17 +96,17 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | if(count($args) > 1) |
| 98 | 98 | array_shift($args); |
| 99 | - $valid = false; |
|
| 99 | + $valid=false; |
|
| 100 | 100 | foreach($this->_actions as $class => $action) |
| 101 | 101 | { |
| 102 | 102 | if($action->isValidAction($args)) |
| 103 | 103 | { |
| 104 | - $valid |= $action->performAction($args); |
|
| 104 | + $valid|=$action->performAction($args); |
|
| 105 | 105 | break; |
| 106 | 106 | } |
| 107 | 107 | else |
| 108 | 108 | { |
| 109 | - $valid = false; |
|
| 109 | + $valid=false; |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | if(!$valid) |
@@ -165,23 +165,23 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | public function isValidAction($args) |
| 167 | 167 | { |
| 168 | - return 0 == strcasecmp($args[0], $this->action) && |
|
| 169 | - count($args)-1 >= count($this->parameters); |
|
| 168 | + return 0==strcasecmp($args[0], $this->action) && |
|
| 169 | + count($args) - 1 >= count($this->parameters); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | public function renderHelp() |
| 173 | 173 | { |
| 174 | - $params = array(); |
|
| 174 | + $params=array(); |
|
| 175 | 175 | foreach($this->parameters as $v) |
| 176 | - $params[] = '<'.$v.'>'; |
|
| 177 | - $parameters = join($params, ' '); |
|
| 178 | - $options = array(); |
|
| 176 | + $params[]='<'.$v.'>'; |
|
| 177 | + $parameters=join($params, ' '); |
|
| 178 | + $options=array(); |
|
| 179 | 179 | foreach($this->optional as $v) |
| 180 | - $options[] = '['.$v.']'; |
|
| 181 | - $optional = (strlen($parameters) ? ' ' : ''). join($options, ' '); |
|
| 180 | + $options[]='['.$v.']'; |
|
| 181 | + $optional=(strlen($parameters) ? ' ' : '').join($options, ' '); |
|
| 182 | 182 | $description=''; |
| 183 | - foreach(explode("\n", wordwrap($this->description,65)) as $line) |
|
| 184 | - $description .= ' '.$line."\n"; |
|
| 183 | + foreach(explode("\n", wordwrap($this->description, 65)) as $line) |
|
| 184 | + $description.=' '.$line."\n"; |
|
| 185 | 185 | return <<<EOD |
| 186 | 186 | {$this->action} {$parameters}{$optional} |
| 187 | 187 | {$description} |
@@ -191,15 +191,15 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | protected function initializePradoApplication($directory) |
| 193 | 193 | { |
| 194 | - $_SERVER['SCRIPT_FILENAME'] = $directory.'/index.php'; |
|
| 195 | - $app_dir = realpath($directory.'/protected/'); |
|
| 196 | - if($app_dir !== false && is_dir($app_dir)) |
|
| 194 | + $_SERVER['SCRIPT_FILENAME']=$directory.'/index.php'; |
|
| 195 | + $app_dir=realpath($directory.'/protected/'); |
|
| 196 | + if($app_dir!==false && is_dir($app_dir)) |
|
| 197 | 197 | { |
| 198 | 198 | if(Prado::getApplication()===null) |
| 199 | 199 | { |
| 200 | - $app = new PradoShellApplication($app_dir); |
|
| 200 | + $app=new PradoShellApplication($app_dir); |
|
| 201 | 201 | $app->run(); |
| 202 | - $dir = substr(str_replace(realpath('./'),'',$app_dir),1); |
|
| 202 | + $dir=substr(str_replace(realpath('./'), '', $app_dir), 1); |
|
| 203 | 203 | PradoCommandLineInterpreter::printGreeting(); |
| 204 | 204 | echo '** Loaded PRADO appplication in directory "'.$dir."\".\n"; |
| 205 | 205 | } |
@@ -209,9 +209,9 @@ discard block |
||
| 209 | 209 | else |
| 210 | 210 | { |
| 211 | 211 | PradoCommandLineInterpreter::printGreeting(); |
| 212 | - echo '+'.str_repeat('-',77)."+\n"; |
|
| 212 | + echo '+'.str_repeat('-', 77)."+\n"; |
|
| 213 | 213 | echo '** Unable to load PRADO application in directory "'.$directory."\".\n"; |
| 214 | - echo '+'.str_repeat('-',77)."+\n"; |
|
| 214 | + echo '+'.str_repeat('-', 77)."+\n"; |
|
| 215 | 215 | } |
| 216 | 216 | return false; |
| 217 | 217 | } |
@@ -226,10 +226,10 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | class PradoCommandLineCreateProject extends PradoCommandLineAction |
| 228 | 228 | { |
| 229 | - protected $action = '-c'; |
|
| 230 | - protected $parameters = array('directory'); |
|
| 231 | - protected $optional = array(); |
|
| 232 | - protected $description = 'Creates a Prado project skeleton for the given <directory>.'; |
|
| 229 | + protected $action='-c'; |
|
| 230 | + protected $parameters=array('directory'); |
|
| 231 | + protected $optional=array(); |
|
| 232 | + protected $description='Creates a Prado project skeleton for the given <directory>.'; |
|
| 233 | 233 | |
| 234 | 234 | public function performAction($args) |
| 235 | 235 | { |
@@ -243,31 +243,31 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | protected function createNewPradoProject($dir) |
| 245 | 245 | { |
| 246 | - if(strlen(trim($dir)) == 0) |
|
| 246 | + if(strlen(trim($dir))==0) |
|
| 247 | 247 | return; |
| 248 | 248 | |
| 249 | - $rootPath = realpath(dirname(trim($dir))); |
|
| 249 | + $rootPath=realpath(dirname(trim($dir))); |
|
| 250 | 250 | |
| 251 | 251 | if(basename($dir)!=='.') |
| 252 | - $basePath = $rootPath.DIRECTORY_SEPARATOR.basename($dir); |
|
| 252 | + $basePath=$rootPath.DIRECTORY_SEPARATOR.basename($dir); |
|
| 253 | 253 | else |
| 254 | - $basePath = $rootPath; |
|
| 255 | - $appName = basename($basePath); |
|
| 256 | - $assetPath = $basePath.DIRECTORY_SEPARATOR.'assets'; |
|
| 257 | - $protectedPath = $basePath.DIRECTORY_SEPARATOR.'protected'; |
|
| 258 | - $runtimePath = $basePath.DIRECTORY_SEPARATOR.'protected'.DIRECTORY_SEPARATOR.'runtime'; |
|
| 259 | - $pagesPath = $protectedPath.DIRECTORY_SEPARATOR.'pages'; |
|
| 260 | - |
|
| 261 | - $indexFile = $basePath.DIRECTORY_SEPARATOR.'index.php'; |
|
| 262 | - $htaccessFile = $protectedPath.DIRECTORY_SEPARATOR.'.htaccess'; |
|
| 263 | - $configFile = $protectedPath.DIRECTORY_SEPARATOR.'application.xml'; |
|
| 264 | - $defaultPageFile = $pagesPath.DIRECTORY_SEPARATOR.'Home.page'; |
|
| 254 | + $basePath=$rootPath; |
|
| 255 | + $appName=basename($basePath); |
|
| 256 | + $assetPath=$basePath.DIRECTORY_SEPARATOR.'assets'; |
|
| 257 | + $protectedPath=$basePath.DIRECTORY_SEPARATOR.'protected'; |
|
| 258 | + $runtimePath=$basePath.DIRECTORY_SEPARATOR.'protected'.DIRECTORY_SEPARATOR.'runtime'; |
|
| 259 | + $pagesPath=$protectedPath.DIRECTORY_SEPARATOR.'pages'; |
|
| 260 | + |
|
| 261 | + $indexFile=$basePath.DIRECTORY_SEPARATOR.'index.php'; |
|
| 262 | + $htaccessFile=$protectedPath.DIRECTORY_SEPARATOR.'.htaccess'; |
|
| 263 | + $configFile=$protectedPath.DIRECTORY_SEPARATOR.'application.xml'; |
|
| 264 | + $defaultPageFile=$pagesPath.DIRECTORY_SEPARATOR.'Home.page'; |
|
| 265 | 265 | |
| 266 | 266 | $this->createDirectory($basePath, 0755); |
| 267 | - $this->createDirectory($assetPath,0777); |
|
| 268 | - $this->createDirectory($protectedPath,0755); |
|
| 269 | - $this->createDirectory($runtimePath,0777); |
|
| 270 | - $this->createDirectory($pagesPath,0755); |
|
| 267 | + $this->createDirectory($assetPath, 0777); |
|
| 268 | + $this->createDirectory($protectedPath, 0755); |
|
| 269 | + $this->createDirectory($runtimePath, 0777); |
|
| 270 | + $this->createDirectory($pagesPath, 0755); |
|
| 271 | 271 | |
| 272 | 272 | $this->createFile($indexFile, $this->renderIndexFile()); |
| 273 | 273 | $this->createFile($configFile, $this->renderConfigFile($appName)); |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | |
| 278 | 278 | protected function renderIndexFile() |
| 279 | 279 | { |
| 280 | - $framework = realpath(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'framework'.DIRECTORY_SEPARATOR.'prado.php'; |
|
| 280 | + $framework=realpath(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'framework'.DIRECTORY_SEPARATOR.'prado.php'; |
|
| 281 | 281 | return '<?php |
| 282 | 282 | |
| 283 | 283 | $frameworkPath=\''.$framework.'\'; |
@@ -376,10 +376,10 @@ discard block |
||
| 376 | 376 | */ |
| 377 | 377 | class PradoCommandLineCreateTests extends PradoCommandLineAction |
| 378 | 378 | { |
| 379 | - protected $action = '-t'; |
|
| 380 | - protected $parameters = array('directory'); |
|
| 381 | - protected $optional = array(); |
|
| 382 | - protected $description = 'Create test fixtures in the given <directory>.'; |
|
| 379 | + protected $action='-t'; |
|
| 380 | + protected $parameters=array('directory'); |
|
| 381 | + protected $optional=array(); |
|
| 382 | + protected $description='Create test fixtures in the given <directory>.'; |
|
| 383 | 383 | |
| 384 | 384 | public function performAction($args) |
| 385 | 385 | { |
@@ -390,22 +390,22 @@ discard block |
||
| 390 | 390 | |
| 391 | 391 | protected function createTestFixtures($dir) |
| 392 | 392 | { |
| 393 | - if(strlen(trim($dir)) == 0) |
|
| 393 | + if(strlen(trim($dir))==0) |
|
| 394 | 394 | return; |
| 395 | 395 | |
| 396 | - $rootPath = realpath(dirname(trim($dir))); |
|
| 397 | - $basePath = $rootPath.'/'.basename($dir); |
|
| 396 | + $rootPath=realpath(dirname(trim($dir))); |
|
| 397 | + $basePath=$rootPath.'/'.basename($dir); |
|
| 398 | 398 | |
| 399 | - $tests = $basePath.'/tests'; |
|
| 400 | - $unit_tests = $tests.'/unit'; |
|
| 401 | - $functional_tests = $tests.'/functional'; |
|
| 399 | + $tests=$basePath.'/tests'; |
|
| 400 | + $unit_tests=$tests.'/unit'; |
|
| 401 | + $functional_tests=$tests.'/functional'; |
|
| 402 | 402 | |
| 403 | - $this->createDirectory($tests,0755); |
|
| 404 | - $this->createDirectory($unit_tests,0755); |
|
| 405 | - $this->createDirectory($functional_tests,0755); |
|
| 403 | + $this->createDirectory($tests, 0755); |
|
| 404 | + $this->createDirectory($unit_tests, 0755); |
|
| 405 | + $this->createDirectory($functional_tests, 0755); |
|
| 406 | 406 | |
| 407 | - $unit_test_index = $tests.'/unit.php'; |
|
| 408 | - $functional_test_index = $tests.'/functional.php'; |
|
| 407 | + $unit_test_index=$tests.'/unit.php'; |
|
| 408 | + $functional_test_index=$tests.'/functional.php'; |
|
| 409 | 409 | |
| 410 | 410 | $this->createFile($unit_test_index, $this->renderUnitTestFixture()); |
| 411 | 411 | $this->createFile($functional_test_index, $this->renderFunctionalTestFixture()); |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | |
| 414 | 414 | protected function renderUnitTestFixture() |
| 415 | 415 | { |
| 416 | - $tester = realpath(dirname(dirname(__FILE__))).'/tests/test_tools/unit_tests.php'; |
|
| 416 | + $tester=realpath(dirname(dirname(__FILE__))).'/tests/test_tools/unit_tests.php'; |
|
| 417 | 417 | return '<?php |
| 418 | 418 | |
| 419 | 419 | include_once \''.$tester.'\'; |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | |
| 429 | 429 | protected function renderFunctionalTestFixture() |
| 430 | 430 | { |
| 431 | - $tester = realpath(dirname(dirname(__FILE__))).'/tests/test_tools/functional_tests.php'; |
|
| 431 | + $tester=realpath(dirname(dirname(__FILE__))).'/tests/test_tools/functional_tests.php'; |
|
| 432 | 432 | return '<?php |
| 433 | 433 | |
| 434 | 434 | include_once \''.$tester.'\'; |
@@ -450,10 +450,10 @@ discard block |
||
| 450 | 450 | */ |
| 451 | 451 | class PradoCommandLinePhpShell extends PradoCommandLineAction |
| 452 | 452 | { |
| 453 | - protected $action = 'shell'; |
|
| 454 | - protected $parameters = array(); |
|
| 455 | - protected $optional = array('directory'); |
|
| 456 | - protected $description = 'Runs a PHP interactive interpreter. Initializes the Prado application in the given [directory].'; |
|
| 453 | + protected $action='shell'; |
|
| 454 | + protected $parameters=array(); |
|
| 455 | + protected $optional=array('directory'); |
|
| 456 | + protected $description='Runs a PHP interactive interpreter. Initializes the Prado application in the given [directory].'; |
|
| 457 | 457 | |
| 458 | 458 | public function performAction($args) |
| 459 | 459 | { |
@@ -473,23 +473,23 @@ discard block |
||
| 473 | 473 | */ |
| 474 | 474 | class PradoCommandLineActiveRecordGen extends PradoCommandLineAction |
| 475 | 475 | { |
| 476 | - protected $action = 'generate'; |
|
| 477 | - protected $parameters = array('table', 'output'); |
|
| 478 | - protected $optional = array('directory', 'soap'); |
|
| 479 | - protected $description = 'Generate Active Record skeleton for <table> to <output> file using application.xml in [directory]. May also generate [soap] properties.'; |
|
| 476 | + protected $action='generate'; |
|
| 477 | + protected $parameters=array('table', 'output'); |
|
| 478 | + protected $optional=array('directory', 'soap'); |
|
| 479 | + protected $description='Generate Active Record skeleton for <table> to <output> file using application.xml in [directory]. May also generate [soap] properties.'; |
|
| 480 | 480 | private $_soap=false; |
| 481 | 481 | |
| 482 | 482 | public function performAction($args) |
| 483 | 483 | { |
| 484 | - $app_dir = count($args) > 3 ? $this->getAppDir($args[3]) : $this->getAppDir(); |
|
| 485 | - $this->_soap = count($args) > 4; |
|
| 486 | - if($app_dir !== false) |
|
| 484 | + $app_dir=count($args) > 3 ? $this->getAppDir($args[3]) : $this->getAppDir(); |
|
| 485 | + $this->_soap=count($args) > 4; |
|
| 486 | + if($app_dir!==false) |
|
| 487 | 487 | { |
| 488 | - $config = $this->getActiveRecordConfig($app_dir); |
|
| 489 | - $output = $this->getOutputFile($app_dir, $args[2]); |
|
| 488 | + $config=$this->getActiveRecordConfig($app_dir); |
|
| 489 | + $output=$this->getOutputFile($app_dir, $args[2]); |
|
| 490 | 490 | if(is_file($output)) |
| 491 | 491 | echo "** File $output already exists, skiping. \n"; |
| 492 | - else if($config !== false && $output !== false) |
|
| 492 | + else if($config!==false && $output!==false) |
|
| 493 | 493 | $this->generateActiveRecord($config, $args[1], $output); |
| 494 | 494 | } |
| 495 | 495 | return true; |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | { |
| 500 | 500 | if(is_dir($dir)) |
| 501 | 501 | return realpath($dir); |
| 502 | - if(false !== ($app_dir = realpath($dir.'/protected/')) && is_dir($app_dir)) |
|
| 502 | + if(false!==($app_dir=realpath($dir.'/protected/')) && is_dir($app_dir)) |
|
| 503 | 503 | return $app_dir; |
| 504 | 504 | echo '** Unable to find directory "'.$dir."\".\n"; |
| 505 | 505 | return false; |
@@ -507,9 +507,9 @@ discard block |
||
| 507 | 507 | |
| 508 | 508 | protected function getXmlFile($app_dir) |
| 509 | 509 | { |
| 510 | - if(false !== ($xml = realpath($app_dir.'/application.xml')) && is_file($xml)) |
|
| 510 | + if(false!==($xml=realpath($app_dir.'/application.xml')) && is_file($xml)) |
|
| 511 | 511 | return $xml; |
| 512 | - if(false !== ($xml = realpath($app_dir.'/protected/application.xml')) && is_file($xml)) |
|
| 512 | + if(false!==($xml=realpath($app_dir.'/protected/application.xml')) && is_file($xml)) |
|
| 513 | 513 | return $xml; |
| 514 | 514 | echo '** Unable to find application.xml in '.$app_dir."\n"; |
| 515 | 515 | return false; |
@@ -517,9 +517,9 @@ discard block |
||
| 517 | 517 | |
| 518 | 518 | protected function getActiveRecordConfig($app_dir) |
| 519 | 519 | { |
| 520 | - if(false === ($xml=$this->getXmlFile($app_dir))) |
|
| 520 | + if(false===($xml=$this->getXmlFile($app_dir))) |
|
| 521 | 521 | return false; |
| 522 | - if(false !== ($app=$this->initializePradoApplication($app_dir))) |
|
| 522 | + if(false!==($app=$this->initializePradoApplication($app_dir))) |
|
| 523 | 523 | { |
| 524 | 524 | Prado::using('System.Data.ActiveRecord.TActiveRecordConfig'); |
| 525 | 525 | foreach($app->getModules() as $module) |
@@ -534,8 +534,8 @@ discard block |
||
| 534 | 534 | { |
| 535 | 535 | if(is_file($namespace) && strpos($namespace, $app_dir)===0) |
| 536 | 536 | return $namespace; |
| 537 | - $file = Prado::getPathOfNamespace($namespace, ".php"); |
|
| 538 | - if($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) |
|
| 537 | + $file=Prado::getPathOfNamespace($namespace, ".php"); |
|
| 538 | + if($file!==null && false!==($path=realpath(dirname($file))) && is_dir($path)) |
|
| 539 | 539 | { |
| 540 | 540 | if(strpos($path, $app_dir)===0) |
| 541 | 541 | return $file; |
@@ -546,24 +546,24 @@ discard block |
||
| 546 | 546 | |
| 547 | 547 | protected function generateActiveRecord($config, $tablename, $output) |
| 548 | 548 | { |
| 549 | - $manager = TActiveRecordManager::getInstance(); |
|
| 549 | + $manager=TActiveRecordManager::getInstance(); |
|
| 550 | 550 | if($manager->getDbConnection()) { |
| 551 | - $gateway = $manager->getRecordGateway(); |
|
| 552 | - $tableInfo = $gateway->getTableInfo($manager->getDbConnection(), $tablename); |
|
| 553 | - if(count($tableInfo->getColumns()) === 0) |
|
| 551 | + $gateway=$manager->getRecordGateway(); |
|
| 552 | + $tableInfo=$gateway->getTableInfo($manager->getDbConnection(), $tablename); |
|
| 553 | + if(count($tableInfo->getColumns())===0) |
|
| 554 | 554 | { |
| 555 | 555 | echo '** Unable to find table or view "'.$tablename.'" in "'.$manager->getDbConnection()->getConnectionString()."\".\n"; |
| 556 | 556 | return false; |
| 557 | 557 | } |
| 558 | 558 | else |
| 559 | 559 | { |
| 560 | - $properties = array(); |
|
| 560 | + $properties=array(); |
|
| 561 | 561 | foreach($tableInfo->getColumns() as $field=>$column) |
| 562 | - $properties[] = $this->generateProperty($field,$column); |
|
| 562 | + $properties[]=$this->generateProperty($field, $column); |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - $classname = basename($output, '.php'); |
|
| 566 | - $class = $this->generateClass($properties, $tablename, $classname); |
|
| 565 | + $classname=basename($output, '.php'); |
|
| 566 | + $class=$this->generateClass($properties, $tablename, $classname); |
|
| 567 | 567 | echo " Writing class $classname to file $output\n"; |
| 568 | 568 | file_put_contents($output, $class); |
| 569 | 569 | } else { |
@@ -571,14 +571,14 @@ discard block |
||
| 571 | 571 | } |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - protected function generateProperty($field,$column) |
|
| 574 | + protected function generateProperty($field, $column) |
|
| 575 | 575 | { |
| 576 | - $prop = ''; |
|
| 577 | - $name = '$'.$field; |
|
| 578 | - $type = $column->getPHPType(); |
|
| 576 | + $prop=''; |
|
| 577 | + $name='$'.$field; |
|
| 578 | + $type=$column->getPHPType(); |
|
| 579 | 579 | if($this->_soap) |
| 580 | 580 | { |
| 581 | - $prop .= <<<EOD |
|
| 581 | + $prop.=<<<EOD |
|
| 582 | 582 | |
| 583 | 583 | /** |
| 584 | 584 | * @var $type $name |
@@ -587,14 +587,14 @@ discard block |
||
| 587 | 587 | |
| 588 | 588 | EOD; |
| 589 | 589 | } |
| 590 | - $prop .= "\tpublic $name;"; |
|
| 590 | + $prop.="\tpublic $name;"; |
|
| 591 | 591 | return $prop; |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | protected function generateClass($properties, $tablename, $class) |
| 595 | 595 | { |
| 596 | - $props = implode("\n", $properties); |
|
| 597 | - $date = date('Y-m-d h:i:s'); |
|
| 596 | + $props=implode("\n", $properties); |
|
| 597 | + $date=date('Y-m-d h:i:s'); |
|
| 598 | 598 | return <<<EOD |
| 599 | 599 | <?php |
| 600 | 600 | /** |
@@ -625,38 +625,38 @@ discard block |
||
| 625 | 625 | */ |
| 626 | 626 | class PradoCommandLineActiveRecordGenAll extends PradoCommandLineAction |
| 627 | 627 | { |
| 628 | - protected $action = 'generateAll'; |
|
| 629 | - protected $parameters = array('output'); |
|
| 630 | - protected $optional = array('directory', 'soap', 'overwrite', 'prefix', 'postfix'); |
|
| 631 | - protected $description = "Generate Active Record skeleton for all Tables to <output> file using application.xml in [directory]. May also generate [soap] properties.\nGenerated Classes are named like the Table with optional [Prefix] and/or [Postfix]. [Overwrite] is used to overwrite existing Files."; |
|
| 632 | - private $_soap = false; |
|
| 633 | - private $_prefix = ''; |
|
| 634 | - private $_postfix = ''; |
|
| 635 | - private $_overwrite = false; |
|
| 628 | + protected $action='generateAll'; |
|
| 629 | + protected $parameters=array('output'); |
|
| 630 | + protected $optional=array('directory', 'soap', 'overwrite', 'prefix', 'postfix'); |
|
| 631 | + protected $description="Generate Active Record skeleton for all Tables to <output> file using application.xml in [directory]. May also generate [soap] properties.\nGenerated Classes are named like the Table with optional [Prefix] and/or [Postfix]. [Overwrite] is used to overwrite existing Files."; |
|
| 632 | + private $_soap=false; |
|
| 633 | + private $_prefix=''; |
|
| 634 | + private $_postfix=''; |
|
| 635 | + private $_overwrite=false; |
|
| 636 | 636 | |
| 637 | 637 | public function performAction($args) { |
| 638 | - $app_dir = count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir(); |
|
| 639 | - $this->_soap = count($args) > 3 ? ($args[3] == "soap" || $args[3] == "true" ? true : false) : false; |
|
| 640 | - $this->_overwrite = count($args) > 4 ? ($args[4] == "overwrite" || $args[4] == "true" ? true : false) : false; |
|
| 641 | - $this->_prefix = count($args) > 5 ? $args[5] : ''; |
|
| 642 | - $this->_postfix = count($args) > 6 ? $args[6] : ''; |
|
| 638 | + $app_dir=count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir(); |
|
| 639 | + $this->_soap=count($args) > 3 ? ($args[3]=="soap" || $args[3]=="true" ? true : false) : false; |
|
| 640 | + $this->_overwrite=count($args) > 4 ? ($args[4]=="overwrite" || $args[4]=="true" ? true : false) : false; |
|
| 641 | + $this->_prefix=count($args) > 5 ? $args[5] : ''; |
|
| 642 | + $this->_postfix=count($args) > 6 ? $args[6] : ''; |
|
| 643 | 643 | |
| 644 | - if ($app_dir !== false) { |
|
| 645 | - $config = $this->getActiveRecordConfig($app_dir); |
|
| 644 | + if($app_dir!==false) { |
|
| 645 | + $config=$this->getActiveRecordConfig($app_dir); |
|
| 646 | 646 | |
| 647 | - $manager = TActiveRecordManager::getInstance(); |
|
| 648 | - $con = $manager->getDbConnection(); |
|
| 649 | - $con->Active = true; |
|
| 647 | + $manager=TActiveRecordManager::getInstance(); |
|
| 648 | + $con=$manager->getDbConnection(); |
|
| 649 | + $con->Active=true; |
|
| 650 | 650 | |
| 651 | 651 | switch($con->getDriverName()) |
| 652 | 652 | { |
| 653 | 653 | case 'mysqli': |
| 654 | 654 | case 'mysql': |
| 655 | - $command = $con->createCommand("SHOW TABLES"); |
|
| 655 | + $command=$con->createCommand("SHOW TABLES"); |
|
| 656 | 656 | break; |
| 657 | 657 | case 'sqlite': //sqlite 3 |
| 658 | 658 | case 'sqlite2': //sqlite 2 |
| 659 | - $command = $con->createCommand("SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name<>'sqlite_sequence'"); |
|
| 659 | + $command=$con->createCommand("SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name<>'sqlite_sequence'"); |
|
| 660 | 660 | break; |
| 661 | 661 | case 'pgsql': |
| 662 | 662 | case 'mssql': // Mssql driver on windows hosts |
@@ -669,17 +669,17 @@ discard block |
||
| 669 | 669 | |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | - $dataReader = $command->query(); |
|
| 672 | + $dataReader=$command->query(); |
|
| 673 | 673 | $dataReader->bindColumn(1, $table); |
| 674 | - $tables = array(); |
|
| 675 | - while ($dataReader->read() !== false) { |
|
| 676 | - $tables[] = $table; |
|
| 674 | + $tables=array(); |
|
| 675 | + while($dataReader->read()!==false) { |
|
| 676 | + $tables[]=$table; |
|
| 677 | 677 | } |
| 678 | - $con->Active = False; |
|
| 679 | - foreach ($tables as $key => $table) { |
|
| 680 | - $output = $args[1] . "." . $this->_prefix . ucfirst($table) . $this->_postfix; |
|
| 681 | - if ($config !== false && $output !== false) { |
|
| 682 | - $this->generate("generate " . $table . " " . $output . " " . $this->_soap . " " . $this->_overwrite); |
|
| 678 | + $con->Active=False; |
|
| 679 | + foreach($tables as $key => $table) { |
|
| 680 | + $output=$args[1].".".$this->_prefix.ucfirst($table).$this->_postfix; |
|
| 681 | + if($config!==false && $output!==false) { |
|
| 682 | + $this->generate("generate ".$table." ".$output." ".$this->_soap." ".$this->_overwrite); |
|
| 683 | 683 | } |
| 684 | 684 | } |
| 685 | 685 | } |
@@ -688,16 +688,16 @@ discard block |
||
| 688 | 688 | |
| 689 | 689 | public function generate($l) |
| 690 | 690 | { |
| 691 | - $input = explode(" ", trim($l)); |
|
| 691 | + $input=explode(" ", trim($l)); |
|
| 692 | 692 | if(count($input) > 2) |
| 693 | 693 | { |
| 694 | - $app_dir = '.'; |
|
| 694 | + $app_dir='.'; |
|
| 695 | 695 | if(Prado::getApplication()!==null) |
| 696 | - $app_dir = dirname(Prado::getApplication()->getBasePath()); |
|
| 697 | - $args = array($input[0],$input[1], $input[2],$app_dir); |
|
| 698 | - if(count($input)>3) |
|
| 699 | - $args = array($input[0],$input[1], $input[2],$app_dir,'soap'); |
|
| 700 | - $cmd = new PradoCommandLineActiveRecordGen; |
|
| 696 | + $app_dir=dirname(Prado::getApplication()->getBasePath()); |
|
| 697 | + $args=array($input[0], $input[1], $input[2], $app_dir); |
|
| 698 | + if(count($input) > 3) |
|
| 699 | + $args=array($input[0], $input[1], $input[2], $app_dir, 'soap'); |
|
| 700 | + $cmd=new PradoCommandLineActiveRecordGen; |
|
| 701 | 701 | $cmd->performAction($args); |
| 702 | 702 | } |
| 703 | 703 | else |
@@ -707,45 +707,45 @@ discard block |
||
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | protected function getAppDir($dir=".") { |
| 710 | - if (is_dir($dir)) |
|
| 710 | + if(is_dir($dir)) |
|
| 711 | 711 | return realpath($dir); |
| 712 | - if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir)) |
|
| 712 | + if(false!==($app_dir=realpath($dir.'/protected/')) && is_dir($app_dir)) |
|
| 713 | 713 | return $app_dir; |
| 714 | - echo '** Unable to find directory "' . $dir . "\".\n"; |
|
| 714 | + echo '** Unable to find directory "'.$dir."\".\n"; |
|
| 715 | 715 | return false; |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | protected function getXmlFile($app_dir) { |
| 719 | - if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml)) |
|
| 719 | + if(false!==($xml=realpath($app_dir.'/application.xml')) && is_file($xml)) |
|
| 720 | 720 | return $xml; |
| 721 | - if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml)) |
|
| 721 | + if(false!==($xml=realpath($app_dir.'/protected/application.xml')) && is_file($xml)) |
|
| 722 | 722 | return $xml; |
| 723 | - echo '** Unable to find application.xml in ' . $app_dir . "\n"; |
|
| 723 | + echo '** Unable to find application.xml in '.$app_dir."\n"; |
|
| 724 | 724 | return false; |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | protected function getActiveRecordConfig($app_dir) { |
| 728 | - if (false === ($xml = $this->getXmlFile($app_dir))) |
|
| 728 | + if(false===($xml=$this->getXmlFile($app_dir))) |
|
| 729 | 729 | return false; |
| 730 | - if (false !== ($app = $this->initializePradoApplication($app_dir))) { |
|
| 730 | + if(false!==($app=$this->initializePradoApplication($app_dir))) { |
|
| 731 | 731 | Prado::using('System.Data.ActiveRecord.TActiveRecordConfig'); |
| 732 | - foreach ($app->getModules() as $module) |
|
| 733 | - if ($module instanceof TActiveRecordConfig) |
|
| 732 | + foreach($app->getModules() as $module) |
|
| 733 | + if($module instanceof TActiveRecordConfig) |
|
| 734 | 734 | return $module; |
| 735 | - echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n"; |
|
| 735 | + echo '** Unable to find TActiveRecordConfig module in '.$xml."\n"; |
|
| 736 | 736 | } |
| 737 | 737 | return false; |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | protected function getOutputFile($app_dir, $namespace) { |
| 741 | - if (is_file($namespace) && strpos($namespace, $app_dir) === 0) |
|
| 741 | + if(is_file($namespace) && strpos($namespace, $app_dir)===0) |
|
| 742 | 742 | return $namespace; |
| 743 | - $file = Prado::getPathOfNamespace($namespace, ""); |
|
| 744 | - if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) { |
|
| 745 | - if (strpos($path, $app_dir) === 0) |
|
| 743 | + $file=Prado::getPathOfNamespace($namespace, ""); |
|
| 744 | + if($file!==null && false!==($path=realpath(dirname($file))) && is_dir($path)) { |
|
| 745 | + if(strpos($path, $app_dir)===0) |
|
| 746 | 746 | return $file; |
| 747 | 747 | } |
| 748 | - echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n"; |
|
| 748 | + echo '** Output file '.$file.' must be within directory '.$app_dir."\n"; |
|
| 749 | 749 | return false; |
| 750 | 750 | } |
| 751 | 751 | |