| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Jaxon\App; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Jaxon\App\Session\SessionInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Jaxon\App\View\ViewRenderer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Jaxon\Exception\SetupException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Jaxon\Plugin\Request\CallableClass\CallableClassHelper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Jaxon\Plugin\Response\DataBag\DataBagContext; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Jaxon\Plugin\Response\JQuery\DomSelector; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Jaxon\Plugin\Response\Pagination\Paginator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Jaxon\Request\Factory\RequestFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Jaxon\Request\TargetInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Jaxon\Response\Response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Psr\Log\LoggerInterface; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  | class CallableClass | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |      * @var Response | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |     protected $response = null; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |      * @var CallableClassHelper | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |     protected $xCallableClassHelper = null; | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |      * Get the Jaxon request target | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |      * @return TargetInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |     protected function target(): TargetInterface | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |         return $this->xCallableClassHelper->xTarget; | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |      * Get an instance of a Jaxon class by name | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |      * @param string $sClassName the class name | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |      * @return mixed | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |      * @throws SetupException | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |     public function cl(string $sClassName) | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |         return $this->xCallableClassHelper->cl($sClassName); | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |      * Get the request factory. | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |      * @param string $sClassName | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |      * @return RequestFactory | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |     public function rq(string $sClassName = ''): RequestFactory | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |         return $this->xCallableClassHelper->rq($sClassName); | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |      * Get the logger | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |      * @return LoggerInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |     public function logger(): LoggerInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |         return $this->xCallableClassHelper->xLogger; | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |      * Get the view renderer | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |      * @return ViewRenderer | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |     public function view(): ViewRenderer | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |         return $this->xCallableClassHelper->xViewRenderer; | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |      * Get the session manager | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |      * @return SessionInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |     public function session(): SessionInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |         return $this->xCallableClassHelper->xSessionManager; | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |      * Get the uploaded files | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |     public function files(): array | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |         return $this->xCallableClassHelper->xUploadHandler->files(); | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  |      * Create a JQuery DomSelector, and link it to the response attribute. | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |      * @param string $sPath    The jQuery selector path | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |      * @param mixed $xContext    A context associated to the selector | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |      * @return DomSelector | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |     public function jq(string $sPath = '', $xContext = null): DomSelector | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |         return $this->response->jq($sPath, $xContext); | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |      * Get a data bag. | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  |      * @param string  $sBagName | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |      * @return DataBagContext | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     public function bag(string $sBagName): DataBagContext | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 126 |  |  |         return $this->response->bag($sBagName); | 
            
                                                                        
                                                                
            
                                    
            
            
                | 127 |  |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                                                                
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                        
                                                                
            
                                    
            
            
                | 129 |  |  |     /** | 
            
                                                                        
                                                                
            
                                    
            
            
                | 130 |  |  |      * Render an HTML pagination control. | 
            
                                                                        
                                                                
            
                                    
            
            
                | 131 |  |  |      * | 
            
                                                                        
                                                                
            
                                    
            
            
                | 132 |  |  |      * @param int $nCurrentPage     The current page number | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                                                                
            
                                    
            
            
                | 133 |  |  |      * @param int $nItemsPerPage    The number of items per page | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                                                                
            
                                    
            
            
                | 134 |  |  |      * @param int $nTotalItems      The total number of items | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  |      * @return Paginator | 
            
                                                                        
                            
            
                                    
            
            
                | 137 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     public function paginator(int $nCurrentPage, int $nItemsPerPage, int $nTotalItems): Paginator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 140 |  |  |         return $this->response->paginator($nCurrentPage, $nItemsPerPage, $nTotalItems); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 142 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 143 |  |  |  |