NvUpdate::template PHP Method

template() public method

NvUpdate::template()
public template ( mixed $contents )
$contents mixed
    public function template($contents)
    {
        global $language_array;
        $xtpl = new XTemplate('updatetheme.tpl', NV_ROOTDIR . '/install/tpl');
        $xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL);
        $xtpl->assign('LANG_VARIABLE', NV_LANG_VARIABLE);
        $xtpl->assign('NV_LANG_UPDATE', NV_LANG_UPDATE);
        $xtpl->assign('LANG', $this->lang);
        $xtpl->assign('CONFIG', $this->config);
        if (!empty($this->config['formodule'])) {
            // Lay module_file lam tieu de luon
            $xtpl->assign('SITE_TITLE', $this->config['type'] == 1 ? sprintf($this->lang['updatemod_title_update'], $this->config['formodule']) : sprintf($this->lang['updatemod_title_upgrade'], $this->config['formodule']));
        } else {
            $xtpl->assign('SITE_TITLE', $this->config['type'] == 1 ? $this->lang['update_site_title_update'] : $this->lang['update_site_title_upgrade']);
        }
        $xtpl->assign('CONTENT_TITLE', $this->lang['update_step_title_' . $this->config['step']]);
        $xtpl->assign('MODULE_CONTENT', $contents);
        $xtpl->assign('LANGTYPESL', NV_LANG_UPDATE);
        $langname = $language_array[NV_LANG_UPDATE]['name'];
        $xtpl->assign('LANGNAMESL', $langname);
        foreach ($this->config['allow_lang'] as $languageslist_i) {
            if (!empty($languageslist_i) and NV_LANG_UPDATE != $languageslist_i) {
                $xtpl->assign('LANGTYPE', $languageslist_i);
                $langname = $language_array[$languageslist_i]['name'];
                $xtpl->assign('LANGNAME', $langname);
                $xtpl->parse('main.looplang');
            }
        }
        $step_bar = array($this->lang['update_step_1'], $this->lang['update_step_2'], $this->lang['update_step_3']);
        foreach ($step_bar as $i => $step_bar_i) {
            $n = $i + 1;
            $class = '';
            if ($this->config['step'] >= $n) {
                $class = " class=\"";
                $class .= $this->config['step'] > $n ? 'passed_step' : '';
                $class .= $this->config['step'] == $n ? 'current_step' : '';
                $class .= "\"";
            }
            $xtpl->assign('CLASS_STEP', $class);
            $xtpl->assign('STEP_BAR', $step_bar_i);
            $xtpl->assign('NUM', $n);
            $xtpl->parse('main.step_bar.loop');
        }
        $xtpl->parse('main.step_bar');
        $xtpl->parse('main');
        return $xtpl->text('main');
    }

Usage Example

Esempio n. 1
0
                    $v = '';
                    $p = 0;
                    if (preg_match("/^([^\\s]+)\\s+([\\d]+)\$/", $row['version'], $matches)) {
                        $v = (string) $matches[1];
                        $p = (int) $matches[2];
                    }
                    $userModules[$row['basename']] = array('basename' => $row['basename'], 'version' => $v, 'mode' => isset($onlineModules[$row['basename']]['mode']) ? $onlineModules[$row['basename']]['mode'] : false, 'time' => $p, 'author' => $row['author']);
                }
            }
            $NvUpdate->module_info($onlineModules, $userModules);
        } elseif ($type == 'module') {
            $_modules = nv_getExtVersion(0);
            $_modules = nv_object2array($_modules);
            $_modules = $_modules['module'];
            $onlineModules = array();
            foreach ($_modules as $m) {
                $name = array_shift($m);
                $onlineModules[$name] = $m;
                unset($onlineModules[$name]['date']);
                $onlineModules[$name]['pubtime'] = strtotime($m['date']);
            }
            $NvUpdate->module_com_info($onlineModules);
        } else {
            die(' ');
        }
    }
    $contents = $NvUpdate->step3($array);
}
include NV_ROOTDIR . '/includes/header.php';
echo $NvUpdate->template($contents);
include NV_ROOTDIR . '/includes/footer.php';