  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: template.php 353 2005-12-19 11:59:56Z hpdl $ |
| |
| 3 | + | $Id: template.php 356 2005-12-20 04:13:12Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
|
|
 |
… |
|
306 | 306 | | } |
| |
307 | 307 | | |
| |
308 | 308 | | /** |
  |
| 309 | + | * Return all templates in an array |
| |
| 310 | + | * |
| |
| 311 | + | * @access public |
| |
| 312 | + | * @return array |
| |
| 313 | + | */ |
| |
| 314 | + | |
| |
| 315 | + | function &getTemplates() { |
| |
| 316 | + | global $osC_Database; |
| |
| 317 | + | |
| |
| 318 | + | $templates = array(); |
| |
| 319 | + | |
| |
| 320 | + | $Qtemplates = $osC_Database->query('select id, code, title from :table_templates'); |
| |
| 321 | + | $Qtemplates->bindTable(':table_templates', TABLE_TEMPLATES); |
| |
| 322 | + | $Qtemplates->setCache('templates'); |
| |
| 323 | + | $Qtemplates->execute(); |
| |
| 324 | + | |
| |
| 325 | + | while ($Qtemplates->next()) { |
| |
| 326 | + | $templates [] = $Qtemplates->toArray(); |
| |
| 327 | + | } |
| |
| 328 | + | |
| |
| 329 | + | $Qtemplates->freeResult(); |
| |
| 330 | + | |
| |
| 331 | + | return $templates; |
| |
| 332 | + | } |
| |
| 333 | + | |
| |
| 334 | + | /** |
|
309 | 335 | | * Checks to see if the page has a title set |
| |
310 | 336 | | * |
| |
311 | 337 | | * @access public |
| |
|
|
 |
… |
|
348 | 374 | | global $osC_Database; |
| |
349 | 375 | | |
| |
350 | 376 | | if ( (isset($_SESSION['template']) === false) || (isset($_GET['template']) && !empty($_GET['template'])) ) { |
  |
351 | | - | $Qtemplates = $osC_Database->query('select id, code from :table_templates'); |
| |
352 | | - | $Qtemplates->bindTable(':table_templates', TABLE_TEMPLATES); |
| |
353 | | - | $Qtemplates->setCache('templates'); |
| |
354 | | - | $Qtemplates->execute(); |
| |
| 377 | + | $set_template = (isset($_GET['template']) && !empty($_GET['template'])) ? $_GET['template'] : DEFAULT_TEMPLATE; |
|
355 | 378 | | |
  |
356 | | - | $template = (isset($_GET['template']) && !empty($_GET['template'])) ? $_GET['template'] : DEFAULT_TEMPLATE; |
| |
357 | | - | |
|
358 | 379 | | $data = array(); |
| |
359 | 380 | | $data_default = array(); |
| |
360 | 381 | | |
  |
361 | | - | while ($Qtemplates->next()) { |
| |
362 | | - | if ($Qtemplates->value('code') == DEFAULT_TEMPLATE) { |
| |
363 | | - | $data_default = array('id' => $Qtemplates->valueInt('id'), 'code' => $Qtemplates->value('code')); |
| |
364 | | - | } elseif ($Qtemplates->value('code') == $template) { |
| |
365 | | - | $data = array('id' => $Qtemplates->valueInt('id'), 'code' => $Qtemplates->value('code')); |
| |
| 382 | + | foreach ($this->getTemplates() as $template) { |
| |
| 383 | + | if ($template['code'] == DEFAULT_TEMPLATE) { |
| |
| 384 | + | $data_default = array('id' => $template['id'], 'code' => $template['code']); |
| |
| 385 | + | } elseif ($template['code'] == $set_template) { |
| |
| 386 | + | $data = array('id' => $template['id'], 'code' => $template['code']); |
|
366 | 387 | | } |
| |
367 | 388 | | } |
| |
368 | 389 | | |
  |
369 | | - | $Qtemplates->freeResult(); |
| |
370 | | - | |
  |
371 | 390 | | if (empty($data)) { |
| |
372 | 391 | | $data =& $data_default; |
| |
373 | 392 | | } |