Example #1
0
 function _smarty_include($params)
 {
     if ($this->debugging) {
         $_params = array();
         require_once SMARTY_CORE_DIR . 'core.get_microtime.php';
         $debug_start_time = smarty_core_get_microtime($_params, $this);
         $this->_smarty_debug_info[] = array('type' => 'template', 'filename' => $params['smarty_include_tpl_file'], 'depth' => ++$this->_inclusion_depth);
         $included_tpls_idx = count($this->_smarty_debug_info) - 1;
     }
     // Extract array with parameters
     if (!empty($params['smarty_include_vars']['params_array'])) {
         foreach ($params['smarty_include_vars']['params_array'] as $k => $v) {
             $this->_tpl_vars[$k] = $v;
         }
         unset($params['smarty_include_vars']['params_array']);
     }
     // Get customization mode info
     if ($this->customization) {
         $this->_smarty_customization_info[] = array('filename' => $params['smarty_include_tpl_file'], 'depth' => $this->debugging ? $this->_inclusion_depth : ++$this->_inclusion_depth);
     }
     $this->_tpl_vars = array_merge($this->_tpl_vars, $params['smarty_include_vars']);
     // Load addons if necessary
     if (strpos($params['smarty_include_tpl_file'], 'addons/') === 0) {
         $path_array = explode('/', $params['smarty_include_tpl_file']);
         if (fn_load_addon($path_array[1]) == false) {
             return false;
         }
     }
     // Substitute current skin area
     $_skin_name = $this->_tpl_vars['skin_area'] == 'mail' || $this->_tpl_vars['skin_area'] == 'customer' ? Registry::get('settings.skin_name_customer') : Registry::get('config.skin_name');
     $this->template_dir = DIR_ROOT . '/skins/' . $_skin_name . '/' . $this->_tpl_vars['skin_area'];
     $this->_tpl_vars['images_dir'] = Registry::get('config.current_path') . '/skins/' . $_skin_name . '/' . $this->_tpl_vars['skin_area'] . '/images';
     $this->_tpl_vars['skin_dir'] = Registry::get('config.current_path') . '/skins/' . $_skin_name . '/' . $this->_tpl_vars['skin_area'];
     // config vars are treated as local, so push a copy of the
     // current ones onto the front of the stack
     array_unshift($this->_config, $this->_config[0]);
     $_smarty_compile_path = $this->_get_compile_path($params['smarty_include_tpl_file']);
     if ($this->_is_compiled($params['smarty_include_tpl_file'], $_smarty_compile_path) || $this->_compile_resource($params['smarty_include_tpl_file'], $_smarty_compile_path)) {
         include $_smarty_compile_path;
     }
     // pop the local vars off the front of the stack
     array_shift($this->_config);
     if ($this->debugging) {
         // capture time for debugging info
         $_params = array();
         require_once SMARTY_CORE_DIR . 'core.get_microtime.php';
         $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $debug_start_time;
     } else {
         $this->_inclusion_depth--;
     }
     if ($this->caching) {
         $this->_cache_info['template'][$params['smarty_include_tpl_file']] = true;
     }
 }
Example #2
0
function smarty_function_block_output($_block_data, &$smarty)
{
    $_tpl_vars = $smarty->_tpl_vars;
    // save state of original variables
    $display = true;
    if (!empty($_block_data['properties']['wrapper'])) {
        // if block is wrapped, display wrapper
        $display_tpl = $_block_data['properties']['wrapper'];
    }
    if (!empty($_block_data['text_id']) && $_block_data['text_id'] == 'central_content') {
        $block_content = $smarty->display($smarty->get_var('content_tpl'), false);
        if (!empty($display_tpl)) {
            if (!empty($smarty->_smarty_vars['capture']['hide_wrapper'])) {
                $smarty->assign('hide_wrapper', true);
                unset($smarty->_smarty_vars['capture']['hide_wrapper']);
                // remove this flag
            }
            $smarty->assign('title', !empty($smarty->_smarty_vars['capture']['mainbox_title']) ? $smarty->_smarty_vars['capture']['mainbox_title'] : '', false);
            $smarty->assign('content', $block_content, false);
            unset($block_content);
        } else {
            $display_tpl = $smarty->get_var('content_tpl');
        }
    } else {
        $_template = !empty($_block_data['properties']['appearances']) ? $_block_data['properties']['appearances'] : (!empty($_block_data['properties']['list_object']) && strpos($_block_data['properties']['list_object'], '.tpl') !== false ? $_block_data['properties']['list_object'] : '');
        if (empty($_template)) {
            return '';
        }
        // This block is not static, so it is necessary to find its items
        if (strpos($_block_data['properties']['list_object'], '.tpl') === false || !empty($_block_data['properties']['items_function'])) {
            $items = fn_get_block_items($_block_data);
            if (empty($items)) {
                $display = false;
            } else {
                $smarty->assign('items', $items);
            }
        }
        if ($display == true) {
            if ($smarty->template_exists($_template)) {
                if (strpos($_template, 'addons/') !== false) {
                    $a = explode('/', $_template);
                    if (fn_load_addon($a[1]) == false) {
                        // do not display template of disabled addon
                        $display = false;
                    }
                }
            } else {
                $display = false;
            }
            if ($display == true) {
                //unset($blocks[$params['id']], $params['id'], $params['template']);
                $smarty->assign('block', $_block_data, false);
                // Pass extra parameters to smarty
                $block_content = $smarty->display($_template, false);
                if (!empty($display_tpl)) {
                    // if wrapper exists, get block content
                    if (trim($block_content)) {
                        if (!empty($smarty->_smarty_vars['capture']['hide_wrapper'])) {
                            $smarty->assign('hide_wrapper', true);
                            unset($smarty->_smarty_vars['capture']['hide_wrapper']);
                            // remove this flag
                        }
                        $smarty->assign('title', $_block_data['description']);
                        $smarty->assign('content', $block_content, false);
                        unset($block_content);
                    } else {
                        $display = false;
                    }
                } else {
                    $display_tpl = $_template;
                }
            }
        }
    }
    if ($display == true) {
        $block_content = !empty($block_content) ? $block_content : $smarty->display($display_tpl, false);
        $smarty->_tpl_vars = $_tpl_vars;
        // restore original vars again
        return trim($block_content);
    } else {
        return '';
    }
}
/**
 * Generates list of (pre/post)controllers from active addons
 *
 * @param string $controller controller name
 * @param string $type controller type (pre/post)
 * @return array controllers list and active addons
 */
function fn_init_addon_controllers($controller, $type = GET_CONTROLLERS, $area = AREA)
{
    $controllers = array();
    static $addons = array();
    $prefix = '';
    $area_name = fn_get_area_name($area);
    if ($type == GET_POST_CONTROLLERS) {
        $prefix = '.post';
    } elseif ($type == GET_PRE_CONTROLLERS) {
        $prefix = '.pre';
    }
    foreach ((array) Registry::get('addons') as $addon_name => $data) {
        if (fn_load_addon($addon_name) == true) {
            // try to find area-specific controller
            $dir = Registry::get('config.dir.addons') . $addon_name . '/controllers/' . $area_name . '/';
            if (is_readable($dir . $controller . $prefix . '.php')) {
                $controllers[] = $dir . $controller . $prefix . '.php';
                $addons[$addon_name] = true;
                if (empty($prefix)) {
                    fn_define('LOADED_ADDON_PATH', $addon_name);
                }
            }
            // try to find common controller
            $dir = Registry::get('config.dir.addons') . $addon_name . '/controllers/common/';
            if (is_readable($dir . $controller . $prefix . '.php')) {
                $controllers[] = $dir . $controller . $prefix . '.php';
                $addons[$addon_name] = true;
                if (empty($prefix)) {
                    fn_define('LOADED_ADDON_PATH', $addon_name);
                }
            }
        }
    }
    return array($controllers, $addons);
}
Example #4
0
/**
 * Initialize unmanaged addons
 *
 * @return array INIT_STATUS_OK
 */
function fn_init_unmanaged_addons()
{
    // Do not use cache here, because company ID is not initialized yet
    $addons = db_get_fields("SELECT addon FROM ?:addons WHERE unmanaged = 1 AND status = 'A' ORDER BY priority");
    foreach ($addons as $addon_name) {
        fn_load_addon($addon_name);
    }
    return array(INIT_STATUS_OK);
}
Example #5
0
function fn_check_blocks_availability($blocks, $block_settings)
{
    $block_settings = $block_settings['dynamic'];
    $disabled_blocks = array();
    foreach ($blocks as $k => $v) {
        if (!empty($v['properties']['list_object'])) {
            // First, check addon blocks and remove if addon is disabled
            if (strpos($v['properties']['list_object'], 'addons/') !== false) {
                $a = explode('/', $v['properties']['list_object']);
                if (fn_load_addon($a[1]) == false) {
                    $blocks[$k]['disabled'] = true;
                    if ($v['status'] != 'D') {
                        $disabled_blocks[] = $k;
                    }
                    continue;
                }
            }
            // Now, check schema
            if (strpos($v['properties']['list_object'], '.tpl') === false) {
                if (!isset($block_settings[$v['properties']['list_object']])) {
                    $blocks[$k]['disabled'] = true;
                    if ($v['status'] != 'D') {
                        $disabled_blocks[] = $k;
                    }
                    continue;
                }
                foreach (array('fillings', 'appearances') as $section_name) {
                    if (!empty($v['properties'][$section_name])) {
                        if ((!isset($block_settings[$v['properties']['list_object']][$section_name]) || !isset($block_settings[$v['properties']['list_object']][$section_name][$v['properties'][$section_name]])) && !isset($v['properties']['static_block'])) {
                            $blocks[$k]['disabled'] = true;
                            if ($v['status'] != 'D') {
                                $disabled_blocks[] = $k;
                            }
                            break;
                        }
                    }
                }
            }
        }
    }
    if (!empty($disabled_blocks)) {
        db_query("UPDATE ?:blocks SET status = 'D' WHERE block_id IN (?n)", $disabled_blocks);
    }
    return $blocks;
}