Changeset 16743


Ignore:
Timestamp:
Sep 7, 2017, 11:09:21 AM (2 years ago)
Author:
amoreno
Message:

Search command fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • internals/2017/FacebookAppAndFacebookPost/src/Adolfo/Commands/Search.php

    r16741 r16743  
    88  public $isValid = true;
    99  public $receivedMSG;
     10  public $appIndex = 0;
    1011  public $storeIndex = 0;
    11   public $appIndex;
    12   public $app;
    13   public $store;
     12  public $app = array();
     13  public $store = array();
    1414  public $answer = ["attachment"=>[
    1515    "type"=>"template",
     
    2424  public function __construct($receivedMSG = array())
    2525  {
    26     $this->receivedMS = $receivedMSG;
    27     $this->appIndex = array_search('app',$this->receivedMS);
    28     for($i=1;$i<$this->appIndex;$i++){
    29       $this->store[]=$this->receivedMS[$i];
     26    $this->appIndex = array_search('app', $receivedMSG);
     27    $this->storeIndex = array_search('store', $receivedMSG);
     28
     29    if($this->appIndex < $this->storeIndex){
     30             for($i = $this->appIndex+1;$i<$this->storeIndex;$i++){
     31                       $this->app[] = $receivedMSG[$i];
     32             }
     33             for($j = $this->storeIndex+1;$j<count($receivedMSG);$j++){
     34                       $this->store[] = $receivedMSG[$j];
     35             }
     36    }else{
     37             for($i = $this->storeIndex+1;$i<$this->appIndex;$i++){
     38                       $this->store[] = $receivedMSG[$i];
     39             }
     40             for($j = $this->appIndex+1;$j<count($receivedMSG);$j++){
     41                       $this->app[] = $receivedMSG[$j];
     42             }
    3043    }
    31     for($i=$this->appIndex+1;$i<count($this->receivedMS);$i++){
    32       $this->app[]=$this->receivedMS[$i];
    33     }
    34     $aplication = array_shift($this->app);
    35     $this->store = $this->app[1];
    36     $this->app = $aplication;
    37     echo "Store: ";
    38     var_dump($this->store);
    39     echo "App: ";
    40     var_dump($this->app);
     44
     45    $this->app = implode(" ", $this->app);
     46    $this->store = implode(" ", $this->store);
    4147  }
    4248
Note: See TracChangeset for help on using the changeset viewer.