Exemple #1
0
function tpl_head($array = array())
{
    $app = $GLOBALS['app'];
    if ($array['html5'] == 'true') {
        $html = '<!DOCTYPE html>' . "\n";
        if ($array['manifest']) {
            $html .= '<html manifest="' . $app->url . 'data/' . $array['manifest'] . '.manifest">' . "\n";
        } else {
            $html .= '<html>' . "\n";
        }
        $html .= '<head>' . "\n\t" . '<meta charset="utf-8" />' . "\n\t";
    } else {
        $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
        $html .= '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
        $html .= '<head>' . "\n\t" . '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\n\t";
    }
    $html .= '<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />' . "\n\t";
    $html .= '<meta http-equiv="Pragma" content="no-cache" />' . "\n\t";
    $html .= '<meta http-equiv="Cache-control" content="no-cache,no-store,must-revalidate,max-age=3" />' . "\n\t";
    $html .= '<meta http-equiv="Expires" content="Mon, 26 Jul 1997 05:00:00 GMT" />' . "\n\t";
    $html .= '<meta name="renderer" content="webkit">' . "\n\t";
    if ($app->license == 'LGPL') {
        $html .= '<meta name="author" content="phpok,admin@phpok.com" />' . "\n\t";
    }
    $html .= '<meta name="license" content="' . $app->license . '" />' . "\n\t";
    $seo = $app->site['seo'];
    if ($seo['keywords']) {
        $html .= '<meta name="keywords" content="' . $seo['keywords'] . '" />' . "\n\t";
    }
    if ($seo['description']) {
        $html .= '<meta name="description" content="' . $seo['description'] . '" />' . "\n\t";
    }
    if ($app->site['meta']) {
        $app->site['meta'] = trim(str_replace(array("\t", "\r"), "", $app->site['meta']));
        if ($app->site['meta']) {
            $t = explode("\n", $app->site['meta']);
            foreach ($t as $key => $value) {
                $html .= $value . "\n\t";
            }
        }
    }
    $headtitle = $app->config['seo']['format'] ? $app->config['seo']['format'] : '{title}-{seo}-{sitename}';
    $headtitle = explode("-", $headtitle);
    foreach ($headtitle as $key => $value) {
        if ($value == '{seo}') {
            if ($seo['title']) {
                $headtitle[$key] = $seo['title'];
            } else {
                unset($headtitle[$key]);
            }
        } elseif ($value == '{sitename}') {
            if ($app->site['title']) {
                $headtitle[$key] = $app->site['title'];
            } else {
                unset($headtitle[$key]);
            }
        } elseif ($value == '{title}') {
            if ($array['title']) {
                $headtitle[$key] = $array['title'];
            } else {
                unset($headtitle[$key]);
            }
        }
    }
    $headtitle = implode($app->config['seo']['line'], $headtitle);
    $html .= '<title>' . trim($headtitle) . '</title>' . "\n\t";
    if (substr($app->url, -1) != '/') {
        $app->url .= "/";
    }
    $html .= '<base href="' . $app->url . '" />' . "\n\t";
    $ico = $array['ico'] ? $array['ico'] : 'favicon.ico';
    if (file_exists($app->dir_root . $ico)) {
        $html .= '<link rel="icon" href="' . $ico . '" />' . "\n\t";
    }
    if ($array["css"]) {
        $tmp = explode(",", $array['css']);
        foreach ($tmp as $key => $value) {
            $value = trim($value);
            if (!$value) {
                continue;
            }
            if ($value == basename($value)) {
                $html .= '<link rel="stylesheet" type="text/css" href="' . $app->url . "css/" . $value . '" />' . "\n\t";
            } else {
                $html .= '<link rel="stylesheet" type="text/css" href="' . $app->url . $value . '" />' . "\n\t";
            }
        }
    }
    $html .= phpok_head_css();
    $jsurl = $app->url('js');
    $include_js = $app->is_mobile ? $app->config['mobile']['includejs'] : $app->config['pc']['includejs'];
    if ($array['extjs']) {
        $include_js = $include_js ? $include_js . ',' . $array['extjs'] : $array['extjs'];
    }
    if ($array['includejs']) {
        $include_js = $include_js ? $include_js . ',' . $array['includejs'] : $array['includejs'];
    }
    if ($array['incjs']) {
        $include_js = $include_js ? $include_js . ',' . $array['incjs'] : $array['incjs'];
    }
    if ($include_js) {
        $jsurl .= "&ext=" . rawurlencode($include_js);
    }
    $exclude_js = $app->is_mobile ? $app->config['mobile']['excludejs'] : $app->config['pc']['excludejs'];
    if ($array['excludejs']) {
        $exclude_js = $exclude_js ? $exclude_js . ',' . $array['excludejs'] : $array['excludejs'];
    }
    if ($exclude_js) {
        $jsurl .= "&_ext=" . rawurlencode($exclude_js);
    }
    $html .= '<script type="text/javascript" src="' . $jsurl . '" charset="utf-8"></script>' . "\n\t";
    if ($array['js']) {
        $tmp = explode(",", $array['js']);
        $tpldir = $app->tpl->dir_tpl;
        $tpldir_length = strlen($tpldir);
        foreach ($tmp as $key => $value) {
            $value = trim($value);
            if (!$value) {
                continue;
            }
            if (substr($value, 0, $tpldir_length) == $tpldir) {
                $html .= '<script type="text/javascript" src="' . $app->url . $value . '" charset="utf-8"></script>' . "\n\t";
            } else {
                $html .= '<script type="text/javascript" src="' . $app->url . 'js/' . $value . '" charset="utf-8"></script>' . "\n\t";
            }
        }
    }
    $html .= phpok_head_js();
    if ($array['html5'] == 'true') {
        $html .= '<!--[if IE]>' . "\n\t";
        $html .= '<script type="text/javascript" src="' . $app->url . 'js/html5.js" charset="utf-8"></script>' . "\n\t";
        $html .= '<![endif]-->' . "\n\t";
    }
    if (!$array['close'] || $array["close"] != 'false') {
        $html .= $app->plugin_html_ap("phpokhead");
        $html .= "\n" . '</head>';
    }
    $html .= "\n";
    return $html;
}
Exemple #2
0
function tpl_head($array = array())
{
    if ($array['html5'] == 'true') {
        $html = '<!DOCTYPE html>' . "\n";
        if ($array['manifest']) {
            $html .= '<html manifest="' . $GLOBALS['app']->url . 'data/' . $array['manifest'] . '.manifest">' . "\n";
        } else {
            $html .= '<html>' . "\n";
        }
        $html .= '<head>' . "\n\t" . '<meta charset="utf-8" />' . "\n\t";
    } else {
        $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
        $html .= '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
        $html .= '<head>' . "\n\t" . '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\n\t";
    }
    $html .= '<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />' . "\n\t";
    $html .= '<meta http-equiv="Pragma" content="no-cache" />' . "\n\t";
    $html .= '<meta http-equiv="Cache-control" content="no-cache,no-store,must-revalidate,max-age=3" />' . "\n\t";
    $html .= '<meta http-equiv="Expires" content="Mon, 26 Jul 1997 05:00:00 GMT" />' . "\n\t";
    $html .= '<meta name="renderer" content="webkit">' . "\n\t";
    $html .= '<meta name="author" content="RenLong" />' . "\n\t";
    $html .= '<meta name="license" content="' . $GLOBALS['app']->license . '" />' . "\n\t";
    $seo = $GLOBALS['app']->site['seo'];
    if ($seo['keywords']) {
        $html .= '<meta name="keywords" content="' . $seo['keywords'] . '" />' . "\n\t";
    }
    if ($seo['description']) {
        $html .= '<meta name="description" content="' . $seo['description'] . '" />' . "\n\t";
    }
    if ($GLOBALS['app']->site['meta']) {
        $GLOBALS['app']->site['meta'] = trim(str_replace(array("\t", "\r"), "", $GLOBALS['app']->site['meta']));
        if ($GLOBALS['app']->site['meta']) {
            $t = explode("\n", $GLOBALS['app']->site['meta']);
            foreach ($t as $key => $value) {
                $html .= $value . "\n\t";
            }
        }
    }
    $html .= '<title>';
    if ($array['title']) {
        $html .= $array['title'] . ' - ';
    }
    $seo = $GLOBALS['app']->tpl->tpl_value['seo'];
    if ($seo['title']) {
        $html .= $seo['title'] . ' - ';
    }
    $html .= $GLOBALS['app']->site['title'];
    $html .= '</title>' . "\n\t";
    $html .= '<base href="' . $GLOBALS['app']->url . '" />' . "\n\t";
    $jsurl = $GLOBALS['app']->url . $GLOBALS['app']->config["www_file"] . "?" . $GLOBALS['app']->config['ctrl_id'] . "=js";
    //包含JS
    $include_js = $GLOBALS['app']->is_mobile ? $GLOBALS['app']->config['mobile']['includejs'] : '';
    if ($array['extjs']) {
        $include_js = $include_js ? $include_js . ',' . $array['extjs'] : $array['extjs'];
    }
    if ($array['includejs']) {
        $include_js = $include_js ? $include_js . ',' . $array['includejs'] : $array['includejs'];
    }
    if ($array['incjs']) {
        $include_js = $include_js ? $include_js . ',' . $array['incjs'] : $array['incjs'];
    }
    if ($include_js) {
        $jsurl .= "&ext=" . rawurlencode($include_js);
    }
    $exclude_js = $GLOBALS['app']->is_mobile ? $GLOBALS['app']->config['mobile']['excludejs'] : '';
    if ($array['excludejs']) {
        $exclude_js = $exclude_js ? $exclude_js . ',' . $array['excludejs'] : $array['excludejs'];
    }
    if ($exclude_js) {
        $jsurl .= "&_ext=" . rawurlencode($exclude_js);
    }
    $html .= '<script type="text/javascript" src="' . $jsurl . '" charset="utf-8"></script>';
    if ($array["css"]) {
        $tmp = explode(",", $array['css']);
        foreach ($tmp as $key => $value) {
            $value = trim($value);
            if ($value) {
                if (is_file($GLOBALS['app']->dir_root . $value)) {
                    $html .= "\n\t" . '<link rel="stylesheet" type="text/css" href="' . $GLOBALS['app']->url . $value . '" />';
                } else {
                    $value = basename($value);
                    if (is_file($GLOBALS['app']->dir_root . "css/" . $value)) {
                        $html .= "\n\t" . '<link rel="stylesheet" type="text/css" href="' . $GLOBALS['app']->url . "css/" . $value . '" />';
                    }
                }
            }
        }
    }
    $html .= phpok_head_css();
    if ($array['js']) {
        $tmp = explode(",", $array['js']);
        foreach ($tmp as $key => $value) {
            $value = trim($value);
            if ($value) {
                if (is_file($GLOBALS['app']->dir_root . $value)) {
                    $html .= "\n\t" . '<script type="text/javascript" src="' . $GLOBALS['app']->url . $value . '" charset="UTF-8"></script>';
                } else {
                    if (is_file($GLOBALS['app']->dir_root . "js/" . $value)) {
                        $html .= "\n\t" . '<script type="text/javascript" src="' . $GLOBALS['app']->url . "js/" . $value . '" charset="UTF-8"></script>';
                    }
                }
            }
        }
    }
    $html .= phpok_head_js();
    if (!$array['close'] || $array["close"] != 'false') {
        $html .= "\n" . '</head>';
    }
    $html .= "\n";
    return $html;
}