Location: PHPKode > projects > Batavi > batavi/ext/smarty/plugin/insert.module.php
<?php

/**
 * file smarty_insert_module.php
 *
 * Module plugin implementation
 *
 * @copyright Copyright (c) 2008, ICEshop BV
 *
 * @package classes
 */

  function smarty_insert_module($params, &$smarty) {

    $template     = '';
    $btv_Template = btv_Factory::singleton(TEMPLATE_ENGINE);
    $btv_Database = btv_Factory::singleton('btv_Database_'.DB_DATABASE_CLASS);
    $btv_Language = btv_Factory::singleton('btv_Language');
    $module       = $params['instance'];

    $btv_Template->selectModule($module);

    if((isset($btv_Template->_modules[$module])) && (is_array($btv_Template->_modules[$module]))) {
      foreach($btv_Template->_modules[$module] as $sort_order => $module_container) {
        $modulesList  = array();
        $sortList     = array();

        foreach ($module_container AS $sub_module) {
          if(file_exists($sub_module['file'])) {
            include_once($sub_module['file']);
            $class_name = 'btv_Modules_'. btv_str_to_camel($module, '_') . '_' . btv_str_to_camel($sub_module['code'], '_');
            $class_box  = new $class_name($sub_module['code']);
            if ($class_box->isEnabled()) {
              $sortList[$class_name]    = $class_box->getSortOrder();
              $class_box->template      = $sub_module['template'];
              $modulesList[$class_name] = $class_box;
            }
          }
        }

        asort($sortList);
        $sortedModulesList = array();

        foreach ($sortList AS $key => $value) {
          $sortedModulesList[$key] = $modulesList[$key];
        }

        foreach($sortedModulesList as $class_box) {
          $btv_Template->mergeTokens($class_box->execute(), true);
          $template_file = str_replace(':template:', $btv_Template->_template, $class_box->template);
          if(file_exists($template_file)) {
            $btv_Template->_tokens['selection_size'] = sizeof($module_container);
            if (file_exists(DIR_TEMPLATES . $btv_Template->_template . '/script/modules/' . $class_box->getGroup() . '/' . $class_box->getCode() . '.js')) {
              if(!in_array('modules/' . $class_box->getGroup() . '/' . $class_box->getCode() . '.js', array())) {
                $btv_Template->_tokens['js_codes'][] = 'modules/' . $class_box->getGroup() . '/' . $class_box->getCode() . '.js';
              }
            }
            $template .= $btv_Template->smartyBox($template_file);
          } else {
            $template_file = str_replace(':template:', 'default', $class_box->template);
            if(file_exists($template_file)) {
              $template .= $btv_Template->smartyBox($template_file);
            } else {
              $template .= '<!-- Warning: Template file not found -->';
            }
          }
        }
      }
    } else {
      $template .= '<!-- Warning: No Modules found! -->';
    }
    return $template;
  }

?>
Return current item: Batavi