@@ -39,311 +39,311 @@ |
||
| 39 | 39 | * (you can pass the most critical GETs manually if you like) |
| 40 | 40 | */ |
| 41 | 41 | |
| 42 | - //Esta clase fue editada por programadores de Cf con la aprobacion de Ruben Arroyo |
|
| 42 | + //Esta clase fue editada por programadores de Cf con la aprobacion de Ruben Arroyo |
|
| 43 | 43 | |
| 44 | 44 | namespace Sistema\Ayudantes; |
| 45 | 45 | |
| 46 | 46 | class Cf_PHPPaginator { |
| 47 | - /* |
|
| 47 | + /* |
|
| 48 | 48 | * MAIN Settings (required) |
| 49 | 49 | */ |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * |
|
| 53 | - * @total_records string Total of records to paginate (specify manually) |
|
| 54 | - */ |
|
| 55 | - public $total_records = 0; |
|
| 51 | + /** |
|
| 52 | + * |
|
| 53 | + * @total_records string Total of records to paginate (specify manually) |
|
| 54 | + */ |
|
| 55 | + public $total_records = 0; |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | - /* |
|
| 58 | + /* |
|
| 59 | 59 | * MAIN Settings (optional) |
| 60 | 60 | */ |
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @style string Specify Class to define |
|
| 64 | - * @tutorial If is specified, it would create <div class="style"> otherwise it not create div |
|
| 65 | - */ |
|
| 66 | - public $style = ''; |
|
| 62 | + /** |
|
| 63 | + * @style string Specify Class to define |
|
| 64 | + * @tutorial If is specified, it would create <div class="style"> otherwise it not create div |
|
| 65 | + */ |
|
| 66 | + public $style = ''; |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @records number Max records to show on every page |
|
| 70 | - */ |
|
| 71 | - public $records = 20; |
|
| 68 | + /** |
|
| 69 | + * @records number Max records to show on every page |
|
| 70 | + */ |
|
| 71 | + public $records = 20; |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @max_links number Maxium quantity of links to show before and after actual page |
|
| 75 | - * @example If current page is 4 and MAX is 2, it show "2 3 4 5 6" |
|
| 76 | - */ |
|
| 77 | - public $max_links = 3; |
|
| 73 | + /** |
|
| 74 | + * @max_links number Maxium quantity of links to show before and after actual page |
|
| 75 | + * @example If current page is 4 and MAX is 2, it show "2 3 4 5 6" |
|
| 76 | + */ |
|
| 77 | + public $max_links = 3; |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * @get_name string Specify INDEX of GET that is used |
|
| 81 | - * |
|
| 82 | - * It will load automatically the current page. |
|
| 83 | - * If you like, you can specify manually in "$cur_page" |
|
| 84 | - * (if you like filter previously or the script will not load directly from URL) |
|
| 85 | - */ |
|
| 86 | - public $get_name = 'pag'; |
|
| 79 | + /** |
|
| 80 | + * @get_name string Specify INDEX of GET that is used |
|
| 81 | + * |
|
| 82 | + * It will load automatically the current page. |
|
| 83 | + * If you like, you can specify manually in "$cur_page" |
|
| 84 | + * (if you like filter previously or the script will not load directly from URL) |
|
| 85 | + */ |
|
| 86 | + public $get_name = 'pag'; |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * @max_records number Specify maxium quantity of registers will be loaded. "0" disable this |
|
| 90 | - */ |
|
| 91 | - public $max_records = 0; |
|
| 88 | + /** |
|
| 89 | + * @max_records number Specify maxium quantity of registers will be loaded. "0" disable this |
|
| 90 | + */ |
|
| 91 | + public $max_records = 0; |
|
| 92 | 92 | |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @recicle_url boolean If is true, modify directly tue current URL to put the pagination (if not exist any, add &pag= to the end) |
|
| 96 | - * If is true, $url_start and $url_end will be ignored |
|
| 97 | - */ |
|
| 98 | - public $recicle_url = true; |
|
| 94 | + /** |
|
| 95 | + * @recicle_url boolean If is true, modify directly tue current URL to put the pagination (if not exist any, add &pag= to the end) |
|
| 96 | + * If is true, $url_start and $url_end will be ignored |
|
| 97 | + */ |
|
| 98 | + public $recicle_url = true; |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * @specific_get array Specify what GETs (and order) you like recicle. |
|
| 102 | - * Set array() to ALL (not recomended to avoid atacks DoS) |
|
| 103 | - * Set '' for any |
|
| 104 | - * @example array('section', 'pag', 'subsection'); |
|
| 105 | - * If you don't need 'pag' in the midle, you can ignore it. |
|
| 106 | - * WARNING: If the order is very important, use the pag at THE END of url |
|
| 107 | - */ |
|
| 108 | - public $specific_get = ''; |
|
| 100 | + /** |
|
| 101 | + * @specific_get array Specify what GETs (and order) you like recicle. |
|
| 102 | + * Set array() to ALL (not recomended to avoid atacks DoS) |
|
| 103 | + * Set '' for any |
|
| 104 | + * @example array('section', 'pag', 'subsection'); |
|
| 105 | + * If you don't need 'pag' in the midle, you can ignore it. |
|
| 106 | + * WARNING: If the order is very important, use the pag at THE END of url |
|
| 107 | + */ |
|
| 108 | + public $specific_get = ''; |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * @url_start string specify how the URL of every link start. IF $recicle_url is TRUE, this will be ignored |
|
| 112 | - * @example If you use MOD_REWRITE or JAVASCRIPT, you can put "http://mywebsite.com/subdir/pag-" or "javascript:paginate(" |
|
| 113 | - * |
|
| 114 | - * This value will auto completed if you leave empty |
|
| 115 | - */ |
|
| 116 | - public $url_start = ''; |
|
| 110 | + /** |
|
| 111 | + * @url_start string specify how the URL of every link start. IF $recicle_url is TRUE, this will be ignored |
|
| 112 | + * @example If you use MOD_REWRITE or JAVASCRIPT, you can put "http://mywebsite.com/subdir/pag-" or "javascript:paginate(" |
|
| 113 | + * |
|
| 114 | + * This value will auto completed if you leave empty |
|
| 115 | + */ |
|
| 116 | + public $url_start = ''; |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * @url_end string specify how the URL of every link ends. IF $recicle_url is TRUE, this will be ignored |
|
| 120 | - * @example If you use MOD_REWRITE or JAVASCRIPT, you can put "/" or ");" |
|
| 121 | - * |
|
| 122 | - * This value will auto completed if you leave empty |
|
| 123 | - */ |
|
| 124 | - public $url_end = ''; |
|
| 118 | + /** |
|
| 119 | + * @url_end string specify how the URL of every link ends. IF $recicle_url is TRUE, this will be ignored |
|
| 120 | + * @example If you use MOD_REWRITE or JAVASCRIPT, you can put "/" or ");" |
|
| 121 | + * |
|
| 122 | + * This value will auto completed if you leave empty |
|
| 123 | + */ |
|
| 124 | + public $url_end = ''; |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | |
| 128 | - /* |
|
| 128 | + /* |
|
| 129 | 129 | * Design settings |
| 130 | 130 | */ |
| 131 | 131 | |
| 132 | - // Icons to show "First | Previous | Next | Last" |
|
| 133 | - //& laquo; = � | & lt; = < |
|
| 132 | + // Icons to show "First | Previous | Next | Last" |
|
| 133 | + //& laquo; = � | & lt; = < |
|
| 134 | 134 | //& raquo; = � | & gt; = > |
| 135 | 135 | // Leave empty '' to not show or ' ' to show empty |
| 136 | - public $first = '[<<]'; |
|
| 137 | - public $previous = '[<]'; |
|
| 138 | - public $next = '[>]'; |
|
| 139 | - public $last = '[>>]'; |
|
| 136 | + public $first = '[<<]'; |
|
| 137 | + public $previous = '[<]'; |
|
| 138 | + public $next = '[>]'; |
|
| 139 | + public $last = '[>>]'; |
|
| 140 | 140 | |
| 141 | 141 | |
| 142 | - /* |
|
| 142 | + /* |
|
| 143 | 143 | * RETURNS FROM PAGINATOR and internal use |
| 144 | 144 | */ |
| 145 | - // Return current page (auto loaded) |
|
| 146 | - public $cur_page; |
|
| 145 | + // Return current page (auto loaded) |
|
| 146 | + public $cur_page; |
|
| 147 | 147 | |
| 148 | - // original page loaded |
|
| 149 | - // it contains the real value in GET (ex: -1, 5...) to compare later |
|
| 150 | - public $original_page; |
|
| 148 | + // original page loaded |
|
| 149 | + // it contains the real value in GET (ex: -1, 5...) to compare later |
|
| 150 | + public $original_page; |
|
| 151 | 151 | |
| 152 | - // Return total pages |
|
| 153 | - public $total_pages; |
|
| 152 | + // Return total pages |
|
| 153 | + public $total_pages; |
|
| 154 | 154 | |
| 155 | - // LIMIT_START / Specify the first record of the page (ex, in page 3 and 20 records is record num 40) |
|
| 156 | - // Limit max is $records |
|
| 157 | - public $first_record; |
|
| 155 | + // LIMIT_START / Specify the first record of the page (ex, in page 3 and 20 records is record num 40) |
|
| 156 | + // Limit max is $records |
|
| 157 | + public $first_record; |
|
| 158 | 158 | |
| 159 | - // Specify limit to put directly in mysql query ( LIMIT 0,20 ) |
|
| 160 | - public $limit; |
|
| 159 | + // Specify limit to put directly in mysql query ( LIMIT 0,20 ) |
|
| 160 | + public $limit; |
|
| 161 | 161 | |
| 162 | 162 | |
| 163 | 163 | /* |
| 164 | 164 | * Functions |
| 165 | 165 | */ |
| 166 | - /** |
|
| 167 | - * @name paginate |
|
| 168 | - * @tutorial This function is called directly to load all params |
|
| 169 | - * @example $pag->paginate(); |
|
| 170 | - */ |
|
| 171 | - public function paginate() { |
|
| 172 | - $this->get(); // Filtering and obtaining variables |
|
| 173 | - $this->calculate(); // Calc current page |
|
| 174 | - $this->prepareUrl(); // Preparing URL to show |
|
| 175 | - } |
|
| 166 | + /** |
|
| 167 | + * @name paginate |
|
| 168 | + * @tutorial This function is called directly to load all params |
|
| 169 | + * @example $pag->paginate(); |
|
| 170 | + */ |
|
| 171 | + public function paginate() { |
|
| 172 | + $this->get(); // Filtering and obtaining variables |
|
| 173 | + $this->calculate(); // Calc current page |
|
| 174 | + $this->prepareUrl(); // Preparing URL to show |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * @name show |
|
| 179 | - * @tutorial Show links of pagination |
|
| 180 | - * @example $pag->show(); |
|
| 181 | - */ |
|
| 182 | - public function show() { |
|
| 183 | - // Prepare string with links |
|
| 184 | - // Reading here variables is faster than "$this->var" |
|
| 185 | - $cur_page = $this->cur_page; |
|
| 186 | - $url_start = $this->url_start; |
|
| 187 | - $url_end = $this->url_end; |
|
| 177 | + /** |
|
| 178 | + * @name show |
|
| 179 | + * @tutorial Show links of pagination |
|
| 180 | + * @example $pag->show(); |
|
| 181 | + */ |
|
| 182 | + public function show() { |
|
| 183 | + // Prepare string with links |
|
| 184 | + // Reading here variables is faster than "$this->var" |
|
| 185 | + $cur_page = $this->cur_page; |
|
| 186 | + $url_start = $this->url_start; |
|
| 187 | + $url_end = $this->url_end; |
|
| 188 | 188 | |
| 189 | - $start = $cur_page - $this->max_links; |
|
| 190 | - $end = $cur_page + $this->max_links; |
|
| 189 | + $start = $cur_page - $this->max_links; |
|
| 190 | + $end = $cur_page + $this->max_links; |
|
| 191 | 191 | |
| 192 | - if ($start < 1) $start = 1; |
|
| 193 | - if ($end > $this->total_pages) $end = $this->total_pages; |
|
| 192 | + if ($start < 1) $start = 1; |
|
| 193 | + if ($end > $this->total_pages) $end = $this->total_pages; |
|
| 194 | 194 | |
| 195 | - // Showing all clickable pages (create div if class is defined) |
|
| 196 | - if ($this->style != '') $r = '<div class="'.$this->style.'">'; |
|
| 197 | - else $r = ''; |
|
| 195 | + // Showing all clickable pages (create div if class is defined) |
|
| 196 | + if ($this->style != '') $r = '<div class="'.$this->style.'">'; |
|
| 197 | + else $r = ''; |
|
| 198 | 198 | |
| 199 | 199 | |
| 200 | - // First / previous |
|
| 201 | - if ($this->cur_page > 1) { |
|
| 202 | - if ($this->first != '') $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">'.$this->first.'</a> '; |
|
| 203 | - if ($this->previous != '') $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">'.$this->previous.'</a> '; |
|
| 204 | - } |
|
| 200 | + // First / previous |
|
| 201 | + if ($this->cur_page > 1) { |
|
| 202 | + if ($this->first != '') $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">'.$this->first.'</a> '; |
|
| 203 | + if ($this->previous != '') $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">'.$this->previous.'</a> '; |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - // You can optimize this separating BEFORE and AFTER current page in two for (to avoid load "if" in each loop) |
|
| 207 | - // but it would be difficult on changes |
|
| 208 | - for ($n=$start; $n<=$end; $n++) { |
|
| 209 | - if ($n != $cur_page) $r .= '<a class="link" href="'. $url_start . $n . $url_end . '">'.$n.'</a> '; |
|
| 210 | - else $r .= '<a class="current">'.$n.'</a> '; |
|
| 211 | - } |
|
| 206 | + // You can optimize this separating BEFORE and AFTER current page in two for (to avoid load "if" in each loop) |
|
| 207 | + // but it would be difficult on changes |
|
| 208 | + for ($n=$start; $n<=$end; $n++) { |
|
| 209 | + if ($n != $cur_page) $r .= '<a class="link" href="'. $url_start . $n . $url_end . '">'.$n.'</a> '; |
|
| 210 | + else $r .= '<a class="current">'.$n.'</a> '; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - // next / last |
|
| 214 | - if ($this->cur_page < $this->total_pages) { |
|
| 215 | - if ($this->next != '') $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">'.$this->next.'</a> '; |
|
| 216 | - if ($this->last != '') $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end .'">'.$this->last.'</a> '; |
|
| 217 | - } |
|
| 213 | + // next / last |
|
| 214 | + if ($this->cur_page < $this->total_pages) { |
|
| 215 | + if ($this->next != '') $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">'.$this->next.'</a> '; |
|
| 216 | + if ($this->last != '') $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end .'">'.$this->last.'</a> '; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - // End div (if exist) |
|
| 220 | - if ($this->style != '') $r .= '</div>'; |
|
| 219 | + // End div (if exist) |
|
| 220 | + if ($this->style != '') $r .= '</div>'; |
|
| 221 | 221 | |
| 222 | - return $r; |
|
| 223 | - } |
|
| 222 | + return $r; |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * @name get |
|
| 228 | - * @tutorial This function is autoloaded, it get the current page and filter number to avoid hackers |
|
| 229 | - */ |
|
| 230 | - private function get() { |
|
| 231 | - if (!is_numeric($this->cur_page)) { |
|
| 232 | - // First get the actual page, by default 1 |
|
| 233 | - $cur_page = isset($_GET[$this->get_name]) ? $_GET[$this->get_name] : 1; |
|
| 234 | - $this->original_page = $cur_page; |
|
| 226 | + /** |
|
| 227 | + * @name get |
|
| 228 | + * @tutorial This function is autoloaded, it get the current page and filter number to avoid hackers |
|
| 229 | + */ |
|
| 230 | + private function get() { |
|
| 231 | + if (!is_numeric($this->cur_page)) { |
|
| 232 | + // First get the actual page, by default 1 |
|
| 233 | + $cur_page = isset($_GET[$this->get_name]) ? $_GET[$this->get_name] : 1; |
|
| 234 | + $this->original_page = $cur_page; |
|
| 235 | 235 | |
| 236 | - // Filter values |
|
| 237 | - if (!is_numeric($cur_page) or $cur_page < 1) $cur_page = 1; |
|
| 236 | + // Filter values |
|
| 237 | + if (!is_numeric($cur_page) or $cur_page < 1) $cur_page = 1; |
|
| 238 | 238 | |
| 239 | - // Set new filtered values (is faster this method) |
|
| 240 | - $this->cur_page = $cur_page; |
|
| 241 | - } else { |
|
| 242 | - $this->original_page = $cur_page; |
|
| 243 | - } |
|
| 244 | - } |
|
| 239 | + // Set new filtered values (is faster this method) |
|
| 240 | + $this->cur_page = $cur_page; |
|
| 241 | + } else { |
|
| 242 | + $this->original_page = $cur_page; |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - /** |
|
| 247 | - * @name calculate |
|
| 248 | - * @tutorial Do all calcs about current and last page |
|
| 249 | - */ |
|
| 250 | - private function calculate() { |
|
| 251 | - // This vars are very used, so is faster do this |
|
| 252 | - $max_records = $this->max_records; |
|
| 253 | - $records = $this->records; |
|
| 246 | + /** |
|
| 247 | + * @name calculate |
|
| 248 | + * @tutorial Do all calcs about current and last page |
|
| 249 | + */ |
|
| 250 | + private function calculate() { |
|
| 251 | + // This vars are very used, so is faster do this |
|
| 252 | + $max_records = $this->max_records; |
|
| 253 | + $records = $this->records; |
|
| 254 | 254 | |
| 255 | - // Force maxium records loaded (only if is specified by user) |
|
| 256 | - if ($max_records > 0 and $max_records > $total_records) |
|
| 257 | - $this->total_records = $max_records; |
|
| 255 | + // Force maxium records loaded (only if is specified by user) |
|
| 256 | + if ($max_records > 0 and $max_records > $total_records) |
|
| 257 | + $this->total_records = $max_records; |
|
| 258 | 258 | |
| 259 | - // Calculate total pages that have |
|
| 260 | - $total_pages = ceil($this->total_records / $records); |
|
| 259 | + // Calculate total pages that have |
|
| 260 | + $total_pages = ceil($this->total_records / $records); |
|
| 261 | 261 | |
| 262 | - // Is correct current page? |
|
| 263 | - if ($this->cur_page > $total_pages) $this->cur_page = $total_pages; |
|
| 264 | - $this->total_pages = $total_pages; |
|
| 262 | + // Is correct current page? |
|
| 263 | + if ($this->cur_page > $total_pages) $this->cur_page = $total_pages; |
|
| 264 | + $this->total_pages = $total_pages; |
|
| 265 | 265 | |
| 266 | - // Specify LIMIT to do a query |
|
| 267 | - $start = ($this->cur_page - 1) * $records; |
|
| 266 | + // Specify LIMIT to do a query |
|
| 267 | + $start = ($this->cur_page - 1) * $records; |
|
| 268 | 268 | |
| 269 | - // Forcing maixum records to show (only if is specified by user) |
|
| 270 | - if ($max_records > 0 and $records > $max_records) { |
|
| 271 | - $records = $max_records; |
|
| 272 | - $this->records = $records; |
|
| 273 | - } |
|
| 269 | + // Forcing maixum records to show (only if is specified by user) |
|
| 270 | + if ($max_records > 0 and $records > $max_records) { |
|
| 271 | + $records = $max_records; |
|
| 272 | + $this->records = $records; |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | 275 | |
| 276 | - // Saving changes |
|
| 277 | - $this->first_record = $start; |
|
| 278 | - $this->limit = ' LIMIT '.$start.','.$records.' '; |
|
| 279 | - } |
|
| 276 | + // Saving changes |
|
| 277 | + $this->first_record = $start; |
|
| 278 | + $this->limit = ' LIMIT '.$start.','.$records.' '; |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - /** |
|
| 282 | - * @name prepareUrl |
|
| 283 | - * @tutorial It prepare the url to show in each link, specified by user |
|
| 284 | - * If recicle URL is false, it will auto load $url_start and $url_end |
|
| 285 | - */ |
|
| 286 | - private function prepareUrl() { |
|
| 287 | - // This script use three methods to recicle GET depending user selection |
|
| 288 | - if ($this->recicle_url) { |
|
| 289 | - // gonna to recicle the URL |
|
| 290 | - $gets = $this->specific_get; |
|
| 291 | - $get_name = $this->get_name; |
|
| 281 | + /** |
|
| 282 | + * @name prepareUrl |
|
| 283 | + * @tutorial It prepare the url to show in each link, specified by user |
|
| 284 | + * If recicle URL is false, it will auto load $url_start and $url_end |
|
| 285 | + */ |
|
| 286 | + private function prepareUrl() { |
|
| 287 | + // This script use three methods to recicle GET depending user selection |
|
| 288 | + if ($this->recicle_url) { |
|
| 289 | + // gonna to recicle the URL |
|
| 290 | + $gets = $this->specific_get; |
|
| 291 | + $get_name = $this->get_name; |
|
| 292 | 292 | |
| 293 | - // If user specified an array |
|
| 294 | - if (is_array($gets)) { |
|
| 295 | - if (empty($gets)) { |
|
| 296 | - // And is empty, we have to Recicle ALL GET |
|
| 297 | - // To know that page needs to be replaced we will use the "original_page" (the real get) |
|
| 298 | - // Cortamos "pag=2" para obtener lo que va antes y despues, as� poder modificar directamente ese pag=2 por la pagina actual |
|
| 299 | - $query_string = explode($this->get_name.'='.$this->original_page, $_SERVER['QUERY_STRING']); |
|
| 293 | + // If user specified an array |
|
| 294 | + if (is_array($gets)) { |
|
| 295 | + if (empty($gets)) { |
|
| 296 | + // And is empty, we have to Recicle ALL GET |
|
| 297 | + // To know that page needs to be replaced we will use the "original_page" (the real get) |
|
| 298 | + // Cortamos "pag=2" para obtener lo que va antes y despues, as� poder modificar directamente ese pag=2 por la pagina actual |
|
| 299 | + $query_string = explode($this->get_name.'='.$this->original_page, $_SERVER['QUERY_STRING']); |
|
| 300 | 300 | |
| 301 | - // How start the new URL? To know it, we need to see the last character from current string |
|
| 302 | - if (!in_array(substr($query_string[0], -1), array('?', '&'))) { |
|
| 303 | - // Current string haven't any at end and it isn't "&" or "?" ? |
|
| 304 | - // If initial string have one character at least it means that not is the first index |
|
| 305 | - if (isset($query_string[0][0])) $this->url_start = '?'.$query_string[0].'&'; |
|
| 306 | - else $this->url_start = '?'.$query_string[0]; |
|
| 307 | - } else { |
|
| 308 | - // Current string already have ? or &, |
|
| 309 | - $this->url_start = '?'.$query_string[0]; |
|
| 310 | - } |
|
| 301 | + // How start the new URL? To know it, we need to see the last character from current string |
|
| 302 | + if (!in_array(substr($query_string[0], -1), array('?', '&'))) { |
|
| 303 | + // Current string haven't any at end and it isn't "&" or "?" ? |
|
| 304 | + // If initial string have one character at least it means that not is the first index |
|
| 305 | + if (isset($query_string[0][0])) $this->url_start = '?'.$query_string[0].'&'; |
|
| 306 | + else $this->url_start = '?'.$query_string[0]; |
|
| 307 | + } else { |
|
| 308 | + // Current string already have ? or &, |
|
| 309 | + $this->url_start = '?'.$query_string[0]; |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - $this->url_end = isset($query_string[1]) ? $query_string[1] : ''; |
|
| 313 | - } else { |
|
| 314 | - // Only specifics GET, reading all and finally leave in the same order |
|
| 315 | - // With this we can clean all GET that we don't need (like hacker attempts) |
|
| 316 | - $tmp = ''; |
|
| 317 | - $tmp_start = ''; // If we found the current page, we move here all $tmp |
|
| 318 | - foreach ($gets as $get) { |
|
| 319 | - if ($get != $get_name) { |
|
| 320 | - // Trying to get the GET |
|
| 321 | - if (isset($_GET[$get])) $tmp .= $get.'='.$_GET[$get].'&'; |
|
| 322 | - } else { |
|
| 323 | - // Pour the $tmp content to $tmp_start |
|
| 324 | - if ($tmp_start == '') $tmp_start .= '?'; |
|
| 325 | - $tmp_start .= $tmp; |
|
| 326 | - $tmp = ''; |
|
| 327 | - } |
|
| 328 | - } |
|
| 312 | + $this->url_end = isset($query_string[1]) ? $query_string[1] : ''; |
|
| 313 | + } else { |
|
| 314 | + // Only specifics GET, reading all and finally leave in the same order |
|
| 315 | + // With this we can clean all GET that we don't need (like hacker attempts) |
|
| 316 | + $tmp = ''; |
|
| 317 | + $tmp_start = ''; // If we found the current page, we move here all $tmp |
|
| 318 | + foreach ($gets as $get) { |
|
| 319 | + if ($get != $get_name) { |
|
| 320 | + // Trying to get the GET |
|
| 321 | + if (isset($_GET[$get])) $tmp .= $get.'='.$_GET[$get].'&'; |
|
| 322 | + } else { |
|
| 323 | + // Pour the $tmp content to $tmp_start |
|
| 324 | + if ($tmp_start == '') $tmp_start .= '?'; |
|
| 325 | + $tmp_start .= $tmp; |
|
| 326 | + $tmp = ''; |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | - // Finally, write the changes in the object |
|
| 331 | - if ($tmp_start != '') { |
|
| 332 | - // If have start and end |
|
| 333 | - $this->url_start = $tmp_start; |
|
| 334 | - $this->url_end = $tmp; |
|
| 335 | - } |
|
| 336 | - else $this->url_start = '?'.$tmp; |
|
| 337 | - } |
|
| 338 | - } else{ |
|
| 339 | - // Non recicle |
|
| 340 | - $this->url_start = '?'; |
|
| 341 | - $this->url_end = ''; |
|
| 342 | - } |
|
| 330 | + // Finally, write the changes in the object |
|
| 331 | + if ($tmp_start != '') { |
|
| 332 | + // If have start and end |
|
| 333 | + $this->url_start = $tmp_start; |
|
| 334 | + $this->url_end = $tmp; |
|
| 335 | + } |
|
| 336 | + else $this->url_start = '?'.$tmp; |
|
| 337 | + } |
|
| 338 | + } else{ |
|
| 339 | + // Non recicle |
|
| 340 | + $this->url_start = '?'; |
|
| 341 | + $this->url_end = ''; |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - // Add the pagination |
|
| 345 | - $this->url_start .= $this->get_name.'='; |
|
| 346 | - } |
|
| 347 | - } |
|
| 344 | + // Add the pagination |
|
| 345 | + $this->url_start .= $this->get_name.'='; |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | 348 | } |
| 349 | 349 | ?> |
| 350 | 350 | \ No newline at end of file |
@@ -193,27 +193,27 @@ discard block |
||
| 193 | 193 | if ($end > $this->total_pages) $end = $this->total_pages; |
| 194 | 194 | |
| 195 | 195 | // Showing all clickable pages (create div if class is defined) |
| 196 | - if ($this->style != '') $r = '<div class="'.$this->style.'">'; |
|
| 196 | + if ($this->style != '') $r = '<div class="' . $this->style . '">'; |
|
| 197 | 197 | else $r = ''; |
| 198 | 198 | |
| 199 | 199 | |
| 200 | 200 | // First / previous |
| 201 | 201 | if ($this->cur_page > 1) { |
| 202 | - if ($this->first != '') $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">'.$this->first.'</a> '; |
|
| 203 | - if ($this->previous != '') $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">'.$this->previous.'</a> '; |
|
| 202 | + if ($this->first != '') $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">' . $this->first . '</a> '; |
|
| 203 | + if ($this->previous != '') $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">' . $this->previous . '</a> '; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // You can optimize this separating BEFORE and AFTER current page in two for (to avoid load "if" in each loop) |
| 207 | 207 | // but it would be difficult on changes |
| 208 | - for ($n=$start; $n<=$end; $n++) { |
|
| 209 | - if ($n != $cur_page) $r .= '<a class="link" href="'. $url_start . $n . $url_end . '">'.$n.'</a> '; |
|
| 210 | - else $r .= '<a class="current">'.$n.'</a> '; |
|
| 208 | + for ($n = $start; $n <= $end; $n++) { |
|
| 209 | + if ($n != $cur_page) $r .= '<a class="link" href="' . $url_start . $n . $url_end . '">' . $n . '</a> '; |
|
| 210 | + else $r .= '<a class="current">' . $n . '</a> '; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | // next / last |
| 214 | 214 | if ($this->cur_page < $this->total_pages) { |
| 215 | - if ($this->next != '') $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">'.$this->next.'</a> '; |
|
| 216 | - if ($this->last != '') $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end .'">'.$this->last.'</a> '; |
|
| 215 | + if ($this->next != '') $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">' . $this->next . '</a> '; |
|
| 216 | + if ($this->last != '') $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end . '">' . $this->last . '</a> '; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // End div (if exist) |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $records = $this->records; |
| 254 | 254 | |
| 255 | 255 | // Force maxium records loaded (only if is specified by user) |
| 256 | - if ($max_records > 0 and $max_records > $total_records) |
|
| 256 | + if ($max_records > 0 and $max_records > $total_records) |
|
| 257 | 257 | $this->total_records = $max_records; |
| 258 | 258 | |
| 259 | 259 | // Calculate total pages that have |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | |
| 276 | 276 | // Saving changes |
| 277 | 277 | $this->first_record = $start; |
| 278 | - $this->limit = ' LIMIT '.$start.','.$records.' '; |
|
| 278 | + $this->limit = ' LIMIT ' . $start . ',' . $records . ' '; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -296,17 +296,17 @@ discard block |
||
| 296 | 296 | // And is empty, we have to Recicle ALL GET |
| 297 | 297 | // To know that page needs to be replaced we will use the "original_page" (the real get) |
| 298 | 298 | // Cortamos "pag=2" para obtener lo que va antes y despues, as� poder modificar directamente ese pag=2 por la pagina actual |
| 299 | - $query_string = explode($this->get_name.'='.$this->original_page, $_SERVER['QUERY_STRING']); |
|
| 299 | + $query_string = explode($this->get_name . '=' . $this->original_page, $_SERVER['QUERY_STRING']); |
|
| 300 | 300 | |
| 301 | 301 | // How start the new URL? To know it, we need to see the last character from current string |
| 302 | 302 | if (!in_array(substr($query_string[0], -1), array('?', '&'))) { |
| 303 | 303 | // Current string haven't any at end and it isn't "&" or "?" ? |
| 304 | 304 | // If initial string have one character at least it means that not is the first index |
| 305 | - if (isset($query_string[0][0])) $this->url_start = '?'.$query_string[0].'&'; |
|
| 306 | - else $this->url_start = '?'.$query_string[0]; |
|
| 305 | + if (isset($query_string[0][0])) $this->url_start = '?' . $query_string[0] . '&'; |
|
| 306 | + else $this->url_start = '?' . $query_string[0]; |
|
| 307 | 307 | } else { |
| 308 | 308 | // Current string already have ? or &, |
| 309 | - $this->url_start = '?'.$query_string[0]; |
|
| 309 | + $this->url_start = '?' . $query_string[0]; |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | $this->url_end = isset($query_string[1]) ? $query_string[1] : ''; |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | foreach ($gets as $get) { |
| 319 | 319 | if ($get != $get_name) { |
| 320 | 320 | // Trying to get the GET |
| 321 | - if (isset($_GET[$get])) $tmp .= $get.'='.$_GET[$get].'&'; |
|
| 321 | + if (isset($_GET[$get])) $tmp .= $get . '=' . $_GET[$get] . '&'; |
|
| 322 | 322 | } else { |
| 323 | 323 | // Pour the $tmp content to $tmp_start |
| 324 | 324 | if ($tmp_start == '') $tmp_start .= '?'; |
@@ -333,16 +333,16 @@ discard block |
||
| 333 | 333 | $this->url_start = $tmp_start; |
| 334 | 334 | $this->url_end = $tmp; |
| 335 | 335 | } |
| 336 | - else $this->url_start = '?'.$tmp; |
|
| 336 | + else $this->url_start = '?' . $tmp; |
|
| 337 | 337 | } |
| 338 | - } else{ |
|
| 338 | + } else { |
|
| 339 | 339 | // Non recicle |
| 340 | 340 | $this->url_start = '?'; |
| 341 | 341 | $this->url_end = ''; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | // Add the pagination |
| 345 | - $this->url_start .= $this->get_name.'='; |
|
| 345 | + $this->url_start .= $this->get_name . '='; |
|
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | } |
@@ -189,35 +189,55 @@ discard block |
||
| 189 | 189 | $start = $cur_page - $this->max_links; |
| 190 | 190 | $end = $cur_page + $this->max_links; |
| 191 | 191 | |
| 192 | - if ($start < 1) $start = 1; |
|
| 193 | - if ($end > $this->total_pages) $end = $this->total_pages; |
|
| 192 | + if ($start < 1) { |
|
| 193 | + $start = 1; |
|
| 194 | + } |
|
| 195 | + if ($end > $this->total_pages) { |
|
| 196 | + $end = $this->total_pages; |
|
| 197 | + } |
|
| 194 | 198 | |
| 195 | 199 | // Showing all clickable pages (create div if class is defined) |
| 196 | - if ($this->style != '') $r = '<div class="'.$this->style.'">'; |
|
| 197 | - else $r = ''; |
|
| 200 | + if ($this->style != '') { |
|
| 201 | + $r = '<div class="'.$this->style.'">'; |
|
| 202 | + } else { |
|
| 203 | + $r = ''; |
|
| 204 | + } |
|
| 198 | 205 | |
| 199 | 206 | |
| 200 | 207 | // First / previous |
| 201 | 208 | if ($this->cur_page > 1) { |
| 202 | - if ($this->first != '') $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">'.$this->first.'</a> '; |
|
| 203 | - if ($this->previous != '') $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">'.$this->previous.'</a> '; |
|
| 209 | + if ($this->first != '') { |
|
| 210 | + $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">'.$this->first.'</a> '; |
|
| 211 | + } |
|
| 212 | + if ($this->previous != '') { |
|
| 213 | + $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">'.$this->previous.'</a> '; |
|
| 214 | + } |
|
| 204 | 215 | } |
| 205 | 216 | |
| 206 | 217 | // You can optimize this separating BEFORE and AFTER current page in two for (to avoid load "if" in each loop) |
| 207 | 218 | // but it would be difficult on changes |
| 208 | 219 | for ($n=$start; $n<=$end; $n++) { |
| 209 | - if ($n != $cur_page) $r .= '<a class="link" href="'. $url_start . $n . $url_end . '">'.$n.'</a> '; |
|
| 210 | - else $r .= '<a class="current">'.$n.'</a> '; |
|
| 220 | + if ($n != $cur_page) { |
|
| 221 | + $r .= '<a class="link" href="'. $url_start . $n . $url_end . '">'.$n.'</a> '; |
|
| 222 | + } else { |
|
| 223 | + $r .= '<a class="current">'.$n.'</a> '; |
|
| 224 | + } |
|
| 211 | 225 | } |
| 212 | 226 | |
| 213 | 227 | // next / last |
| 214 | 228 | if ($this->cur_page < $this->total_pages) { |
| 215 | - if ($this->next != '') $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">'.$this->next.'</a> '; |
|
| 216 | - if ($this->last != '') $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end .'">'.$this->last.'</a> '; |
|
| 229 | + if ($this->next != '') { |
|
| 230 | + $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">'.$this->next.'</a> '; |
|
| 231 | + } |
|
| 232 | + if ($this->last != '') { |
|
| 233 | + $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end .'">'.$this->last.'</a> '; |
|
| 234 | + } |
|
| 217 | 235 | } |
| 218 | 236 | |
| 219 | 237 | // End div (if exist) |
| 220 | - if ($this->style != '') $r .= '</div>'; |
|
| 238 | + if ($this->style != '') { |
|
| 239 | + $r .= '</div>'; |
|
| 240 | + } |
|
| 221 | 241 | |
| 222 | 242 | return $r; |
| 223 | 243 | } |
@@ -234,7 +254,9 @@ discard block |
||
| 234 | 254 | $this->original_page = $cur_page; |
| 235 | 255 | |
| 236 | 256 | // Filter values |
| 237 | - if (!is_numeric($cur_page) or $cur_page < 1) $cur_page = 1; |
|
| 257 | + if (!is_numeric($cur_page) or $cur_page < 1) { |
|
| 258 | + $cur_page = 1; |
|
| 259 | + } |
|
| 238 | 260 | |
| 239 | 261 | // Set new filtered values (is faster this method) |
| 240 | 262 | $this->cur_page = $cur_page; |
@@ -253,14 +275,17 @@ discard block |
||
| 253 | 275 | $records = $this->records; |
| 254 | 276 | |
| 255 | 277 | // Force maxium records loaded (only if is specified by user) |
| 256 | - if ($max_records > 0 and $max_records > $total_records) |
|
| 257 | - $this->total_records = $max_records; |
|
| 278 | + if ($max_records > 0 and $max_records > $total_records) { |
|
| 279 | + $this->total_records = $max_records; |
|
| 280 | + } |
|
| 258 | 281 | |
| 259 | 282 | // Calculate total pages that have |
| 260 | 283 | $total_pages = ceil($this->total_records / $records); |
| 261 | 284 | |
| 262 | 285 | // Is correct current page? |
| 263 | - if ($this->cur_page > $total_pages) $this->cur_page = $total_pages; |
|
| 286 | + if ($this->cur_page > $total_pages) { |
|
| 287 | + $this->cur_page = $total_pages; |
|
| 288 | + } |
|
| 264 | 289 | $this->total_pages = $total_pages; |
| 265 | 290 | |
| 266 | 291 | // Specify LIMIT to do a query |
@@ -302,8 +327,11 @@ discard block |
||
| 302 | 327 | if (!in_array(substr($query_string[0], -1), array('?', '&'))) { |
| 303 | 328 | // Current string haven't any at end and it isn't "&" or "?" ? |
| 304 | 329 | // If initial string have one character at least it means that not is the first index |
| 305 | - if (isset($query_string[0][0])) $this->url_start = '?'.$query_string[0].'&'; |
|
| 306 | - else $this->url_start = '?'.$query_string[0]; |
|
| 330 | + if (isset($query_string[0][0])) { |
|
| 331 | + $this->url_start = '?'.$query_string[0].'&'; |
|
| 332 | + } else { |
|
| 333 | + $this->url_start = '?'.$query_string[0]; |
|
| 334 | + } |
|
| 307 | 335 | } else { |
| 308 | 336 | // Current string already have ? or &, |
| 309 | 337 | $this->url_start = '?'.$query_string[0]; |
@@ -318,10 +346,14 @@ discard block |
||
| 318 | 346 | foreach ($gets as $get) { |
| 319 | 347 | if ($get != $get_name) { |
| 320 | 348 | // Trying to get the GET |
| 321 | - if (isset($_GET[$get])) $tmp .= $get.'='.$_GET[$get].'&'; |
|
| 349 | + if (isset($_GET[$get])) { |
|
| 350 | + $tmp .= $get.'='.$_GET[$get].'&'; |
|
| 351 | + } |
|
| 322 | 352 | } else { |
| 323 | 353 | // Pour the $tmp content to $tmp_start |
| 324 | - if ($tmp_start == '') $tmp_start .= '?'; |
|
| 354 | + if ($tmp_start == '') { |
|
| 355 | + $tmp_start .= '?'; |
|
| 356 | + } |
|
| 325 | 357 | $tmp_start .= $tmp; |
| 326 | 358 | $tmp = ''; |
| 327 | 359 | } |
@@ -332,8 +364,9 @@ discard block |
||
| 332 | 364 | // If have start and end |
| 333 | 365 | $this->url_start = $tmp_start; |
| 334 | 366 | $this->url_end = $tmp; |
| 367 | + } else { |
|
| 368 | + $this->url_start = '?'.$tmp; |
|
| 335 | 369 | } |
| 336 | - else $this->url_start = '?'.$tmp; |
|
| 337 | 370 | } |
| 338 | 371 | } else{ |
| 339 | 372 | // Non recicle |
@@ -31,5 +31,5 @@ |
||
| 31 | 31 | |
| 32 | 32 | $dominio = "http://www.my-site-domain.com/"; |
| 33 | 33 | return $dominio; |
| 34 | - } |
|
| 34 | + } |
|
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | |
| 28 | 28 | class CFPHPVinculos { |
| 29 | 29 | |
| 30 | - function get_dominio(){ |
|
| 30 | + function get_dominio() { |
|
| 31 | 31 | |
| 32 | 32 | $dominio = "http://www.my-site-domain.com/"; |
| 33 | 33 | return $dominio; |
@@ -32,31 +32,31 @@ |
||
| 32 | 32 | { |
| 33 | 33 | $controlador = $peticion->getControlador() . 'Controlador'; |
| 34 | 34 | //definimos la ruta al controlador |
| 35 | - $rutaControlador = SITE_ROOT . 'mvc' . DS .'controladores' . DS . $controlador . '.php'; |
|
| 35 | + $rutaControlador = SITE_ROOT . 'mvc' . DS . 'controladores' . DS . $controlador . '.php'; |
|
| 36 | 36 | $metodo = $peticion->getMetodo(); |
| 37 | 37 | $args = $peticion->getArgumentos(); |
| 38 | 38 | |
| 39 | 39 | //verifcamos que el archivo existe con la funcion de PHP is_readable |
| 40 | - if(is_readable($rutaControlador)){ |
|
| 40 | + if (is_readable($rutaControlador)) { |
|
| 41 | 41 | require_once $rutaControlador; |
| 42 | 42 | $controlador = new $controlador; |
| 43 | 43 | |
| 44 | - if(is_callable(array($controlador, $metodo))){ |
|
| 44 | + if (is_callable(array($controlador, $metodo))) { |
|
| 45 | 45 | $metodo = $peticion->getMetodo(); |
| 46 | 46 | } |
| 47 | - else{ |
|
| 47 | + else { |
|
| 48 | 48 | $metodo = 'index'; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if(isset($args)){ |
|
| 51 | + if (isset($args)) { |
|
| 52 | 52 | call_user_func_array(array($controlador, $metodo), $args); |
| 53 | 53 | } |
| 54 | - else{ |
|
| 54 | + else { |
|
| 55 | 55 | call_user_func(array($controlador, $metodo)); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | } else { |
| 59 | - header('Location: '. Cf_BASE_URL.'error/'); |
|
| 59 | + header('Location: ' . Cf_BASE_URL . 'error/'); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | \ No newline at end of file |
@@ -43,15 +43,13 @@ |
||
| 43 | 43 | |
| 44 | 44 | if(is_callable(array($controlador, $metodo))){ |
| 45 | 45 | $metodo = $peticion->getMetodo(); |
| 46 | - } |
|
| 47 | - else{ |
|
| 46 | + } else{ |
|
| 48 | 47 | $metodo = 'index'; |
| 49 | 48 | } |
| 50 | 49 | |
| 51 | 50 | if(isset($args)){ |
| 52 | 51 | call_user_func_array(array($controlador, $metodo), $args); |
| 53 | - } |
|
| 54 | - else{ |
|
| 52 | + } else{ |
|
| 55 | 53 | call_user_func(array($controlador, $metodo)); |
| 56 | 54 | } |
| 57 | 55 | |
@@ -91,7 +91,7 @@ |
||
| 91 | 91 | define('Cf_KEY_MD5', 'P0L1'); |
| 92 | 92 | |
| 93 | 93 | /* en el controlador concatena la constante con el llamado a la funcion generarCadenaAleatoria() de Cf_PHPSeguridad */ |
| 94 | -define('Cf_CSRF_SECRET','Cfbeta'); |
|
| 94 | +define('Cf_CSRF_SECRET', 'Cfbeta'); |
|
| 95 | 95 | |
| 96 | 96 | /* #base de datos */ |
| 97 | 97 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $rutaLib = RUTA_LIBS . $libreria . '.php'; |
| 39 | 39 | if(is_readable($rutaLib)){ |
| 40 | 40 | require_once $rutaLib; |
| 41 | - //echo 'libreria cargada'; |
|
| 41 | + //echo 'libreria cargada'; |
|
| 42 | 42 | } |
| 43 | 43 | else { |
| 44 | 44 | throw new Exception("houston tenemos un problema! al cargar libreria"); |
@@ -47,12 +47,12 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | protected function cargaModelo($modelo){ |
| 49 | 49 | $modelo=$modelo.'Modelo'; |
| 50 | - $rutaMod = RUTA_MOD . $modelo . '.php'; |
|
| 50 | + $rutaMod = RUTA_MOD . $modelo . '.php'; |
|
| 51 | 51 | if(is_readable($rutaMod)){ |
| 52 | 52 | require_once $rutaMod; |
| 53 | 53 | $modelo = new $modelo; |
| 54 | 54 | return $modelo; |
| 55 | - //echo 'modelo cargado'; |
|
| 55 | + //echo 'modelo cargado'; |
|
| 56 | 56 | } |
| 57 | 57 | else { |
| 58 | 58 | //echo $rutaMod; |
@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | protected function cargaAyudante($ayudante){ |
| 67 | - $rutaAyudante = RUTA_AYUDANTES . $ayudante . '.php'; |
|
| 67 | + $rutaAyudante = RUTA_AYUDANTES . $ayudante . '.php'; |
|
| 68 | 68 | if(is_readable($rutaAyudante)){ |
| 69 | 69 | require_once $rutaAyudante; |
| 70 | - //echo 'libreria cargada'; |
|
| 70 | + //echo 'libreria cargada'; |
|
| 71 | 71 | } |
| 72 | 72 | else { |
| 73 | 73 | throw new Exception("houston tenemos un problema! al cargar ayudante"); |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | $this->_vista = new CFVista(new CFSolicitud); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - protected function cargaLib($libreria){ |
|
| 37 | + protected function cargaLib($libreria) { |
|
| 38 | 38 | $rutaLib = RUTA_LIBS . $libreria . '.php'; |
| 39 | - if(is_readable($rutaLib)){ |
|
| 39 | + if (is_readable($rutaLib)) { |
|
| 40 | 40 | require_once $rutaLib; |
| 41 | 41 | //echo 'libreria cargada'; |
| 42 | 42 | } |
@@ -45,10 +45,10 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - protected function cargaModelo($modelo){ |
|
| 49 | - $modelo=$modelo.'Modelo'; |
|
| 48 | + protected function cargaModelo($modelo) { |
|
| 49 | + $modelo = $modelo . 'Modelo'; |
|
| 50 | 50 | $rutaMod = RUTA_MOD . $modelo . '.php'; |
| 51 | - if(is_readable($rutaMod)){ |
|
| 51 | + if (is_readable($rutaMod)) { |
|
| 52 | 52 | require_once $rutaMod; |
| 53 | 53 | $modelo = new $modelo; |
| 54 | 54 | return $modelo; |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - protected function cargaAyudante($ayudante){ |
|
| 66 | + protected function cargaAyudante($ayudante) { |
|
| 67 | 67 | $rutaAyudante = RUTA_AYUDANTES . $ayudante . '.php'; |
| 68 | - if(is_readable($rutaAyudante)){ |
|
| 68 | + if (is_readable($rutaAyudante)) { |
|
| 69 | 69 | require_once $rutaAyudante; |
| 70 | 70 | //echo 'libreria cargada'; |
| 71 | 71 | } |
@@ -39,8 +39,7 @@ discard block |
||
| 39 | 39 | if(is_readable($rutaLib)){ |
| 40 | 40 | require_once $rutaLib; |
| 41 | 41 | //echo 'libreria cargada'; |
| 42 | - } |
|
| 43 | - else { |
|
| 42 | + } else { |
|
| 44 | 43 | throw new Exception("houston tenemos un problema! al cargar libreria"); |
| 45 | 44 | } |
| 46 | 45 | } |
@@ -53,8 +52,7 @@ discard block |
||
| 53 | 52 | $modelo = new $modelo; |
| 54 | 53 | return $modelo; |
| 55 | 54 | //echo 'modelo cargado'; |
| 56 | - } |
|
| 57 | - else { |
|
| 55 | + } else { |
|
| 58 | 56 | //echo $rutaMod; |
| 59 | 57 | |
| 60 | 58 | |
@@ -68,8 +66,7 @@ discard block |
||
| 68 | 66 | if(is_readable($rutaAyudante)){ |
| 69 | 67 | require_once $rutaAyudante; |
| 70 | 68 | //echo 'libreria cargada'; |
| 71 | - } |
|
| 72 | - else { |
|
| 69 | + } else { |
|
| 73 | 70 | throw new Exception("houston tenemos un problema! al cargar ayudante"); |
| 74 | 71 | } |
| 75 | 72 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | private $_argumentos; |
| 33 | 33 | |
| 34 | 34 | public function __construct() { |
| 35 | - if(isset($_GET['url'])){ |
|
| 35 | + if (isset($_GET['url'])) { |
|
| 36 | 36 | $url = filter_input(INPUT_GET, 'url', FILTER_SANITIZE_URL); |
| 37 | 37 | $url = explode('/', $url); |
| 38 | 38 | $url = array_filter($url); |
@@ -42,15 +42,15 @@ discard block |
||
| 42 | 42 | $this->_argumentos = $url; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if(!$this->_controlador){ |
|
| 45 | + if (!$this->_controlador) { |
|
| 46 | 46 | $this->_controlador = CONTROLADOR_INICIAL; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if(!$this->_metodo){ |
|
| 49 | + if (!$this->_metodo) { |
|
| 50 | 50 | $this->_metodo = 'index'; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if(!isset($this->_argumentos)){ |
|
| 53 | + if (!isset($this->_argumentos)) { |
|
| 54 | 54 | $this->_argumentos = array(); |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -38,14 +38,14 @@ |
||
| 38 | 38 | |
| 39 | 39 | $ver_ruta = VIEW_PATH . $this->_controlador . DS . $vista . '.phtml'; |
| 40 | 40 | |
| 41 | - if(is_readable($ver_ruta)){ |
|
| 41 | + if (is_readable($ver_ruta)) { |
|
| 42 | 42 | include_once SITE_ROOT . 'mvc/vistas' . DS . ADICIONALES_VISTA . DS . 'encabezado.php'; |
| 43 | 43 | include_once $ver_ruta; |
| 44 | 44 | include_once SITE_ROOT . 'mvc/vistas' . DS . ADICIONALES_VISTA . DS . 'pie_de_pagina.php'; |
| 45 | 45 | } |
| 46 | 46 | else { |
| 47 | 47 | |
| 48 | - header('Location: '. Cf_BASE_URL.'error/index'.'?error='.'vista' ); |
|
| 48 | + header('Location: ' . Cf_BASE_URL . 'error/index' . '?error=' . 'vista'); |
|
| 49 | 49 | |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -42,8 +42,7 @@ |
||
| 42 | 42 | include_once SITE_ROOT . 'mvc/vistas' . DS . ADICIONALES_VISTA . DS . 'encabezado.php'; |
| 43 | 43 | include_once $ver_ruta; |
| 44 | 44 | include_once SITE_ROOT . 'mvc/vistas' . DS . ADICIONALES_VISTA . DS . 'pie_de_pagina.php'; |
| 45 | - } |
|
| 46 | - else { |
|
| 45 | + } else { |
|
| 47 | 46 | |
| 48 | 47 | header('Location: '. Cf_BASE_URL.'error/index'.'?error='.'vista' ); |
| 49 | 48 | |
@@ -102,31 +102,31 @@ |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | switch ($lang) { |
| 105 | - case 'en': |
|
| 105 | + case 'en': |
|
| 106 | 106 | $lang_file = 'lang.en.php'; |
| 107 | - break; |
|
| 107 | + break; |
|
| 108 | 108 | |
| 109 | - case 'de': |
|
| 109 | + case 'de': |
|
| 110 | 110 | $lang_file = 'lang.de.php'; |
| 111 | - break; |
|
| 111 | + break; |
|
| 112 | 112 | |
| 113 | - case 'zh': |
|
| 113 | + case 'zh': |
|
| 114 | 114 | $lang_file = 'lang.zh.php'; |
| 115 | - break; |
|
| 115 | + break; |
|
| 116 | 116 | |
| 117 | - case 'pt': |
|
| 117 | + case 'pt': |
|
| 118 | 118 | $lang_file = 'lang.pt.php'; |
| 119 | - break; |
|
| 119 | + break; |
|
| 120 | 120 | |
| 121 | - case 'pt': |
|
| 121 | + case 'pt': |
|
| 122 | 122 | $lang_file = 'lang.pt.php'; |
| 123 | - break; |
|
| 123 | + break; |
|
| 124 | 124 | |
| 125 | - case 'es': |
|
| 125 | + case 'es': |
|
| 126 | 126 | $lang_file = 'lang.es.php'; |
| 127 | - break; |
|
| 127 | + break; |
|
| 128 | 128 | |
| 129 | - default: |
|
| 129 | + default: |
|
| 130 | 130 | $lang_file = 'lang.en.php'; |
| 131 | 131 | |
| 132 | 132 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * <http://www.calimaframework.com>. |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -require_once __DIR__.'/vendor/autoload.php'; |
|
| 26 | +require_once __DIR__ . '/vendor/autoload.php'; |
|
| 27 | 27 | |
| 28 | 28 | use Sistema\Nucleo; |
| 29 | 29 | use Sistema\Ayudantes; |
@@ -42,44 +42,44 @@ discard block |
||
| 42 | 42 | /** Cf directorio separador */ |
| 43 | 43 | defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); |
| 44 | 44 | /** Cf raiz del sitio */ |
| 45 | -defined('SITE_ROOT')? null: define('SITE_ROOT', realpath(dirname(__FILE__)).DS); |
|
| 45 | +defined('SITE_ROOT') ? null : define('SITE_ROOT', realpath(dirname(__FILE__)) . DS); |
|
| 46 | 46 | /** Cf PATH del sitio */ |
| 47 | -defined('SITE_PATH') ? NULL : define ('SITE_PATH', realpath(dirname(__FILE__) . DS . '..' . DS) . DS); |
|
| 47 | +defined('SITE_PATH') ? NULL : define('SITE_PATH', realpath(dirname(__FILE__) . DS . '..' . DS) . DS); |
|
| 48 | 48 | |
| 49 | 49 | /** Cf definimos constante Ruta directa al nucleo de framework */ |
| 50 | -define('RUTA_NUCLEO', SITE_ROOT . 'Sistema'.DS.'Nucleo' . DS); |
|
| 50 | +define('RUTA_NUCLEO', SITE_ROOT . 'Sistema' . DS . 'Nucleo' . DS); |
|
| 51 | 51 | |
| 52 | 52 | # define para mvc erp |
| 53 | 53 | |
| 54 | 54 | /** Cf definimos constante directa a la vista del framework */ |
| 55 | -define('VIEW_PATH', SITE_ROOT . 'mvc'.DS.'vistas' . DS); |
|
| 55 | +define('VIEW_PATH', SITE_ROOT . 'mvc' . DS . 'vistas' . DS); |
|
| 56 | 56 | /** Cf definimos constante directa a los controladores del framework */ |
| 57 | -define('CONTR_PATH', SITE_ROOT . 'mvc'.DS.'controladores' . DS); |
|
| 57 | +define('CONTR_PATH', SITE_ROOT . 'mvc' . DS . 'controladores' . DS); |
|
| 58 | 58 | /** Cf definimos constante directa a los modelos del framework */ |
| 59 | -define('RUTA_MOD', SITE_ROOT . 'mvc'.DS.'modelos' . DS); |
|
| 59 | +define('RUTA_MOD', SITE_ROOT . 'mvc' . DS . 'modelos' . DS); |
|
| 60 | 60 | |
| 61 | 61 | # define ruta a los stilos del public |
| 62 | 62 | |
| 63 | 63 | /** Cf definimos constante directa a los css dentro del directorio public_ del framework */ |
| 64 | -define('CSS_PATH', SITE_ROOT . 'public_'.DS.'css' . DS); |
|
| 64 | +define('CSS_PATH', SITE_ROOT . 'public_' . DS . 'css' . DS); |
|
| 65 | 65 | /** Cf definimos constante directa a los css dentro del directorio public_ del framework */ |
| 66 | -define('IMG_PATH', SITE_ROOT . 'public_'.DS.'img' . DS); |
|
| 66 | +define('IMG_PATH', SITE_ROOT . 'public_' . DS . 'img' . DS); |
|
| 67 | 67 | /** Cf definimos constante directa a los js dentro del directorio public_ del framework */ |
| 68 | -define('JS_PATH', SITE_ROOT . 'public_'.DS.'js' . DS); |
|
| 68 | +define('JS_PATH', SITE_ROOT . 'public_' . DS . 'js' . DS); |
|
| 69 | 69 | /** Cf definimos constante directa a las librerias dentro del framework */ |
| 70 | -define('RUTA_LIBS', SITE_ROOT . 'Sistema'.DS.'librerias' . DS); |
|
| 70 | +define('RUTA_LIBS', SITE_ROOT . 'Sistema' . DS . 'librerias' . DS); |
|
| 71 | 71 | /** Cf definimos constante directa a los ayudantes del framework */ |
| 72 | -define('RUTA_AYUDANTES', SITE_ROOT . 'Sistema'.DS.'ayudantes' . DS); |
|
| 72 | +define('RUTA_AYUDANTES', SITE_ROOT . 'Sistema' . DS . 'ayudantes' . DS); |
|
| 73 | 73 | |
| 74 | 74 | /** Cf definimos constante directa a los lenguajes del framework */ |
| 75 | -define('RUTA_LENGUAJES', SITE_ROOT . 'Sistema'.DS.'lenguajes' . DS); |
|
| 75 | +define('RUTA_LENGUAJES', SITE_ROOT . 'Sistema' . DS . 'lenguajes' . DS); |
|
| 76 | 76 | |
| 77 | 77 | |
| 78 | 78 | //LENGUAJES |
| 79 | 79 | //En el directorio sistema lenguajes hay varios archivos php cada uno para crear las constantes en el idioma especifico |
| 80 | 80 | //luego por get capturamos la variable lan al inicio de la aplicacion asi: www.tuapp.com/?lang=de |
| 81 | 81 | |
| 82 | -if(isSet($_GET['lang'])) |
|
| 82 | +if (isSet($_GET['lang'])) |
|
| 83 | 83 | { |
| 84 | 84 | $lang = $_GET['lang']; |
| 85 | 85 | |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | setcookie('lang', $lang, time() + (3600 * 24 * 30)); |
| 90 | 90 | } |
| 91 | -else if(isSet($_SESSION['lang'])) |
|
| 91 | +else if (isSet($_SESSION['lang'])) |
|
| 92 | 92 | { |
| 93 | 93 | $lang = $_SESSION['lang']; |
| 94 | 94 | } |
| 95 | -else if(isSet($_COOKIE['lang'])) |
|
| 95 | +else if (isSet($_COOKIE['lang'])) |
|
| 96 | 96 | { |
| 97 | 97 | $lang = $_COOKIE['lang']; |
| 98 | 98 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | //require_once RUTA_NUCLEO . 'Cf_Autocarga.php'; |
| 149 | 149 | require_once RUTA_NUCLEO . 'CFConfiguracion.php'; |
| 150 | 150 | |
| 151 | -try{ |
|
| 151 | +try { |
|
| 152 | 152 | |
| 153 | 153 | Nucleo\CFBootstrap::actuar(new Nucleo\CFSolicitud); |
| 154 | 154 | //CFBootstrap::actuar(new CFSolicitud); |
@@ -87,16 +87,13 @@ |
||
| 87 | 87 | $_SESSION['lang'] = $lang; |
| 88 | 88 | |
| 89 | 89 | setcookie('lang', $lang, time() + (3600 * 24 * 30)); |
| 90 | -} |
|
| 91 | -else if(isSet($_SESSION['lang'])) |
|
| 90 | +} else if(isSet($_SESSION['lang'])) |
|
| 92 | 91 | { |
| 93 | 92 | $lang = $_SESSION['lang']; |
| 94 | -} |
|
| 95 | -else if(isSet($_COOKIE['lang'])) |
|
| 93 | +} else if(isSet($_COOKIE['lang'])) |
|
| 96 | 94 | { |
| 97 | 95 | $lang = $_COOKIE['lang']; |
| 98 | -} |
|
| 99 | -else |
|
| 96 | +} else |
|
| 100 | 97 | { |
| 101 | 98 | $lang = 'es'; // por defecto el idioma para el app es español puede ser en, bt, de, zh |
| 102 | 99 | } |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | if (isset($_POST['enviar'])&& isset($_POST['option1']) ) { |
| 62 | 62 | |
| 63 | 63 | $datas->insertarDatos( |
| 64 | - $this->_ayuda->filtrarEntero($_POST['id']), |
|
| 65 | - $this->_ayuda->filtrarTexto($_POST['nombre']), |
|
| 66 | - $this->_ayuda->filtrarTexto($_POST['email']), |
|
| 67 | - $this->_ayuda->filtrarTexto($_POST['comentario']) |
|
| 64 | + $this->_ayuda->filtrarEntero($_POST['id']), |
|
| 65 | + $this->_ayuda->filtrarTexto($_POST['nombre']), |
|
| 66 | + $this->_ayuda->filtrarTexto($_POST['email']), |
|
| 67 | + $this->_ayuda->filtrarTexto($_POST['comentario']) |
|
| 68 | 68 | ); |
| 69 | 69 | echo $this->_ayuda->filtrarEntero('id'); |
| 70 | 70 | $_POST['option1']=false; |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | public function insertarComentario(){ |
| 77 | 77 | |
| 78 | - /*$this->_vista->titulo = 'Registro CalimaFramework'; |
|
| 78 | + /*$this->_vista->titulo = 'Registro CalimaFramework'; |
|
| 79 | 79 | if(isset($_GET['titulo'])){ |
| 80 | 80 | $this->_vista->salida_campo = $_GET['titulo']; |
| 81 | 81 | } |
@@ -19,46 +19,46 @@ discard block |
||
| 19 | 19 | $this->_ayuda = new Sistema\Ayudantes\CFPHPAyuda(); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public function index(){ |
|
| 22 | + public function index() { |
|
| 23 | 23 | $datas = $this->cargaModelo('blog'); |
| 24 | 24 | |
| 25 | - $this->_vista->postear= $datas->llamarDatosBlog(); |
|
| 26 | - $this->_vista->categorias= $datas->llamarDatosCategoria(); |
|
| 27 | - $this->_vista->tags= $datas->llamarDatosTags(); |
|
| 25 | + $this->_vista->postear = $datas->llamarDatosBlog(); |
|
| 26 | + $this->_vista->categorias = $datas->llamarDatosCategoria(); |
|
| 27 | + $this->_vista->tags = $datas->llamarDatosTags(); |
|
| 28 | 28 | $this->_vista->titulo = 'Blog Calima Framework'; |
| 29 | 29 | $this->_vista->imprimirVista('index', 'blog'); |
| 30 | 30 | |
| 31 | 31 | } |
| 32 | - public function crearpost(){ |
|
| 32 | + public function crearpost() { |
|
| 33 | 33 | $datas = $this->cargaModelo('blog'); |
| 34 | 34 | |
| 35 | - $this->_vista->postear= $datas->llamarDatosBlog(); |
|
| 35 | + $this->_vista->postear = $datas->llamarDatosBlog(); |
|
| 36 | 36 | $this->_vista->titulo = 'Blog Calima Framework crear post'; |
| 37 | 37 | $this->_vista->imprimirVista('crearpost', 'blog'); |
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function wikipost(){ |
|
| 41 | + public function wikipost() { |
|
| 42 | 42 | $datas = $this->cargaModelo('blog'); |
| 43 | 43 | |
| 44 | - $this->_vista->postear= $datas->llamarDatosBlog(); |
|
| 45 | - $this->_vista->tags= $datas->llamarDatosTags(); |
|
| 46 | - $this->_vista->comentarios= $datas->llamarComentarios(); |
|
| 47 | - $this->_vista->categorias= $datas->llamarDatosCategoria(); |
|
| 48 | - $this->_vista->contar= $datas->contarComentarios($_GET['id']); |
|
| 49 | - $this->_vista->video= $datas->llamarDatosBlogId($_GET['id']); |
|
| 44 | + $this->_vista->postear = $datas->llamarDatosBlog(); |
|
| 45 | + $this->_vista->tags = $datas->llamarDatosTags(); |
|
| 46 | + $this->_vista->comentarios = $datas->llamarComentarios(); |
|
| 47 | + $this->_vista->categorias = $datas->llamarDatosCategoria(); |
|
| 48 | + $this->_vista->contar = $datas->contarComentarios($_GET['id']); |
|
| 49 | + $this->_vista->video = $datas->llamarDatosBlogId($_GET['id']); |
|
| 50 | 50 | $this->_vista->titulo = 'Blog 1 Calima Framework'; |
| 51 | 51 | $this->_vista->imprimirVista('wikipost', 'blog'); |
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | $this->_vista->titulo = 'Registro CalimaFramework'; |
| 55 | - if(isset($_GET['titulo'])){ |
|
| 55 | + if (isset($_GET['titulo'])) { |
|
| 56 | 56 | $this->_vista->salida_campo = $_GET['titulo']; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $this->_vista->imprimirVista('wikipost', 'blog'); |
| 60 | 60 | //$datas = $this->cargaModelo('blog'); |
| 61 | - if (isset($_POST['enviar'])&& isset($_POST['option1']) ) { |
|
| 61 | + if (isset($_POST['enviar']) && isset($_POST['option1'])) { |
|
| 62 | 62 | |
| 63 | 63 | $datas->insertarDatos( |
| 64 | 64 | $this->_ayuda->filtrarEntero($_POST['id']), |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | $this->_ayuda->filtrarTexto($_POST['comentario']) |
| 68 | 68 | ); |
| 69 | 69 | echo $this->_ayuda->filtrarEntero('id'); |
| 70 | - $_POST['option1']=false; |
|
| 70 | + $_POST['option1'] = false; |
|
| 71 | 71 | |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function insertarComentario(){ |
|
| 76 | + public function insertarComentario() { |
|
| 77 | 77 | |
| 78 | 78 | /*$this->_vista->titulo = 'Registro CalimaFramework'; |
| 79 | 79 | if(isset($_GET['titulo'])){ |