Microweber\Providers\Modules::templates PHP Метод

templates() публичный Метод

Gets all templates for a module
public templates ( $module_name, $template_name = false, $get_settings_file = false )
    public function templates($module_name, $template_name = false, $get_settings_file = false)
    {
        $module_name = str_replace('admin', '', $module_name);
        $module_name_l = $this->locate($module_name);
        if ($module_name_l == false) {
            $module_name_l = modules_path() . DS . $module_name . DS;
            $module_name_l = normalize_path($module_name_l, 1);
        } else {
            $module_name_l = dirname($module_name_l) . DS . 'templates' . DS;
            $module_name_l = normalize_path($module_name_l, 1);
        }
        $module_name_l_theme = ACTIVE_TEMPLATE_DIR . 'modules' . DS . $module_name . DS . 'templates' . DS;
        $module_name_l_theme = normalize_path($module_name_l_theme, 1);
        if (!is_dir($module_name_l) and !is_dir($module_name_l_theme)) {
            return false;
        } else {
            if ($template_name == false) {
                $options = array();
                $options['for_modules'] = 1;
                $options['no_cache'] = 1;
                $options['path'] = $module_name_l;
                $module_name_l = $this->app->layouts_manager->scan($options);
                if (is_dir($module_name_l_theme)) {
                    $options['path'] = $module_name_l_theme;
                    $module_skins_from_theme = $this->app->layouts_manager->scan($options);
                    if (is_array($module_skins_from_theme)) {
                        if (!is_array($module_name_l)) {
                            $module_name_l = array();
                        }
                        $file_names_found = array();
                        if (is_array($module_skins_from_theme)) {
                            $comb = array_merge($module_skins_from_theme, $module_name_l);
                            if (is_array($comb) and !empty($comb)) {
                                foreach ($comb as $k1 => $itm) {
                                    if (!in_array($itm['layout_file'], $file_names_found)) {
                                        if (isset($itm['visible'])) {
                                            if ($itm['visible'] == 'false' or $itm['visible'] == 'no' or $itm['visible'] == 'n') {
                                                // skip
                                            } else {
                                                $file_names_found[] = $itm['layout_file'];
                                            }
                                        } else {
                                            $file_names_found[] = $itm['layout_file'];
                                        }
                                    } else {
                                        unset($comb[$k1]);
                                    }
                                }
                            }
                            $module_name_l = $comb;
                        }
                    }
                }
                return $module_name_l;
            } else {
                $template_name = str_replace('..', '', $template_name);
                $template_name_orig = $template_name;
                if ($get_settings_file == true) {
                    $is_dot_php = get_file_extension($template_name);
                    if ($is_dot_php != false and $is_dot_php == 'php') {
                        $template_name = str_ireplace('.php', '', $template_name);
                    }
                    $template_name = $template_name . '_settings';
                }
                $is_dot_php = get_file_extension($template_name);
                if ($is_dot_php != false and $is_dot_php != 'php') {
                    $template_name = $template_name . '.php';
                }
                $tf = $module_name_l . $template_name;
                $tf_theme = $module_name_l_theme . $template_name;
                $tf_from_other_theme = templates_path() . $template_name;
                $tf_from_other_theme = normalize_path($tf_from_other_theme, false);
                $tf_other_module = modules_path() . $template_name;
                $tf_other_module = normalize_path($tf_other_module, false);
                if (strstr($tf_from_other_theme, 'modules') and is_file($tf_from_other_theme)) {
                    return $tf_from_other_theme;
                } elseif (is_file($tf_theme)) {
                    return $tf_theme;
                } elseif (is_file($tf)) {
                    return $tf;
                } elseif (strtolower($template_name_orig) != 'default' and is_file($tf_other_module)) {
                    return $tf_other_module;
                } else {
                    return false;
                }
            }
        }
    }