[geeklog-hg] geeklog: Improved the flexibility of setting the CSS file
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Fri Dec 19 07:46:15 EST 2014
changeset 9561:a80a0c362bd7
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/a80a0c362bd7
user: dengen <taharaxp at gmail.com>
date: Fri Dec 19 21:46:37 2014 +0900
description:
Improved the flexibility of setting the CSS file
diffstat:
public_html/lib-common.php | 4 ++--
system/classes/scripts.class.php | 32 +++++++++++++++++++++++++++-----
2 files changed, 29 insertions(+), 7 deletions(-)
diffs (70 lines):
diff -r c4a690a690d2 -r a80a0c362bd7 public_html/lib-common.php
--- a/public_html/lib-common.php Fri Dec 19 20:22:16 2014 +0900
+++ b/public_html/lib-common.php Fri Dec 19 21:46:37 2014 +0900
@@ -447,8 +447,8 @@
$func = "theme_css_" . $_CONF['theme'];
if (function_exists($func)) {
foreach ($func() as $info) {
- $file = $info['file'];
- $name = (!empty($info['name'])) ? $info['name'] : md5($file);
+ $file = (!empty($info['file'])) ? $info['file'] : '';
+ $name = (!empty($info['name'])) ? $info['name'] : md5(!empty($file) ? $file : strval(time()));
$constant = (!empty($info['constant'])) ? $info['constant'] : true;
$attributes = (!empty($info['attributes'])) ? $info['attributes'] : array();
$priority = (!empty($info['priority'])) ? $info['priority'] : 100;
diff -r c4a690a690d2 -r a80a0c362bd7 system/classes/scripts.class.php
--- a/system/classes/scripts.class.php Fri Dec 19 20:22:16 2014 +0900
+++ b/system/classes/scripts.class.php Fri Dec 19 21:46:37 2014 +0900
@@ -469,7 +469,11 @@
$extra = '';
foreach ($attributes as $key => $value) {
- $extra .= " $key=\"$value\"";
+ if (in_array($key, array('rel', 'type', 'href'))) {
+ $this->css_files[$name][$key] = $value;
+ } else {
+ $extra .= " $key=\"$value\"";
+ }
}
$this->css_files[$name]['name'] = $name;
@@ -540,9 +544,27 @@
}
// Set CSS Files
foreach ($this->css_files as $file) {
- if ($file['load'] && isset($file['file'])) {
- $csslink = '<link rel="stylesheet" type="text/css" href="'
- . $_CONF['site_url'] . $file['file'] . '"' . $file['extra'] . XHTML . '>' . LB;
+ $rel = 'stylesheet';
+ if (!empty($file['rel'])) {
+ $rel = $file['rel'];
+ }
+ $type = 'text/css';
+ if (!empty($file['type'])) {
+ $type = $file['type'];
+ }
+ $href = '';
+ if (!empty($file['file'])) {
+ $href = $_CONF['site_url'] . $file['file'];
+ }
+ if (!empty($file['href'])) {
+ $href = $file['href'];
+ }
+
+ if ($file['load'] && !empty($href)) {
+ $csslink = '<link rel="' . $rel
+ . '" type="' . $type
+ . '" href="' . $href
+ . '"' . $file['extra'] . XHTML . '>' . LB;
if (isset($file['name']) && $file['name'] == 'theme') { // load theme css first
$headercode = $csslink . $headercode;
@@ -551,7 +573,7 @@
}
}
}
- // Set CSS
+ // Set CSS
if ($this->css_set) {
$headercode .= '<style type="text/css">' . LB;
foreach ($this->css as $css) {
More information about the geeklog-cvs
mailing list