[geeklog-cvs] geeklog: Improved scripts.class.php for support extra attributes...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Mon Apr 30 14:25:39 EDT 2012
changeset 8657:a0f69563108e
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/a0f69563108e
user: dengen
date: Tue May 01 03:20:03 2012 +0900
description:
Improved scripts.class.php for support extra attributes (such as 'name' and 'media') of <link rel="stylesheet">
diffstat:
public_html/layout/denim/functions.php | 7 ++++++-
public_html/layout/newpro/functions.php | 4 +++-
public_html/layout/professional/functions.php | 4 +++-
public_html/layout/professional_css/functions.php | 4 +++-
public_html/lib-common.php | 8 ++++++--
system/classes/scripts.class.php | 19 ++++++++++++++-----
6 files changed, 35 insertions(+), 11 deletions(-)
diffs (142 lines):
diff -r f935a8bd04dc -r a0f69563108e public_html/layout/denim/functions.php
--- a/public_html/layout/denim/functions.php Mon Apr 30 23:38:03 2012 +0900
+++ b/public_html/layout/denim/functions.php Tue May 01 03:20:03 2012 +0900
@@ -58,7 +58,12 @@
global $_CONF, $LANG_DIRECTION;
$cssfile = ($LANG_DIRECTION == 'rtl') ? '/style_rtl.css' : '/style.css';
- return array('/layout/' . $_CONF['theme'] . $cssfile);
+ return array(
+ array(
+ 'file' => '/layout/' . $_CONF['theme'] . $cssfile,
+ 'attributes' => array('media' => 'screen')
+ )
+ );
}
/**
diff -r f935a8bd04dc -r a0f69563108e public_html/layout/newpro/functions.php
--- a/public_html/layout/newpro/functions.php Mon Apr 30 23:38:03 2012 +0900
+++ b/public_html/layout/newpro/functions.php Tue May 01 03:20:03 2012 +0900
@@ -57,7 +57,9 @@
{
global $_CONF, $LANG_DIRECTION;
return array(
- '/layout/' . $_CONF['theme'] . '/style.css.php?dir=' . $LANG_DIRECTION
+ array(
+ 'file' => '/layout/' . $_CONF['theme'] . '/style.css.php?dir=' . $LANG_DIRECTION
+ )
);
}
diff -r f935a8bd04dc -r a0f69563108e public_html/layout/professional/functions.php
--- a/public_html/layout/professional/functions.php Mon Apr 30 23:38:03 2012 +0900
+++ b/public_html/layout/professional/functions.php Tue May 01 03:20:03 2012 +0900
@@ -57,7 +57,9 @@
{
global $_CONF, $LANG_DIRECTION;
return array(
- '/layout/' . $_CONF['theme'] . '/style.css'
+ array(
+ '/layout/' . $_CONF['theme'] . '/style.css'
+ )
);
}
diff -r f935a8bd04dc -r a0f69563108e public_html/layout/professional_css/functions.php
--- a/public_html/layout/professional_css/functions.php Mon Apr 30 23:38:03 2012 +0900
+++ b/public_html/layout/professional_css/functions.php Tue May 01 03:20:03 2012 +0900
@@ -57,7 +57,9 @@
{
global $_CONF, $LANG_DIRECTION;
return array(
- '/layout/' . $_CONF['theme'] . '/style.css'
+ array(
+ '/layout/' . $_CONF['theme'] . '/style.css'
+ )
);
}
diff -r f935a8bd04dc -r a0f69563108e public_html/lib-common.php
--- a/public_html/lib-common.php Mon Apr 30 23:38:03 2012 +0900
+++ b/public_html/lib-common.php Tue May 01 03:20:03 2012 +0900
@@ -424,8 +424,12 @@
/* Include scripts on behalf of the theme */
$func = "theme_css_" . $_CONF['theme'];
if (function_exists($func)) {
- foreach ($func() as $file) {
- $_SCRIPTS->setCssFile(md5($file), $file);
+ foreach ($func() as $info) {
+ $file = $info['file'];
+ $name = md5($file);
+ $constant = (!empty($info['constant'])) ? $info['constant'] : true;
+ $attributes = (!empty($info['attributes'])) ? $info['attributes'] : array();
+ $_SCRIPTS->setCssFile($name, $file, $constant, $attributes);
}
}
$func = "theme_js_libs_" . $_CONF['theme'];
diff -r f935a8bd04dc -r a0f69563108e system/classes/scripts.class.php
--- a/system/classes/scripts.class.php Mon Apr 30 23:38:03 2012 +0900
+++ b/system/classes/scripts.class.php Tue May 01 03:20:03 2012 +0900
@@ -339,6 +339,7 @@
}
$this->css_files[$name]['file'] = $file;
+ $this->css_files[$name]['extra'] = '';
$this->css_files[$name]['constant'] = false;
$this->css_files[$name]['load'] = $load;
@@ -351,11 +352,12 @@
* @param $name name of CSS file
* @param $file location of file relative to public_html directory. Include '/' at beginning
* @param $constant Future use. Set to true if file is planned to be loaded all the time (Caching/Compression)
+ * @param $attributes (optional) array of extra attributes
* @access public
* @return boolean
*
- */
- public function setCSSFile($name, $file, $constant = true) {
+ */
+ public function setCSSFile($name, $file, $constant = true, $attributes = array()) {
global $_CONF;
@@ -379,13 +381,19 @@
return false;
}
+ $extra = '';
+ foreach ($attributes as $key => $value) {
+ $extra .= " $key=\"$value\"";
+ }
+
$this->css_files[$name]['name'] = $name;
$this->css_files[$name]['file'] = $file;
+ $this->css_files[$name]['extra'] = $extra;
$this->css_files[$name]['constant'] = $constant;
$this->css_files[$name]['load'] = true;
return true;
- }
+ }
/**
* Returns header code (JavaScript and CSS) to include in the Head of the webpage
@@ -405,14 +413,15 @@
// 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'] . '" ' . XHTML . '>' . LB;
+ $csslink = '<link rel="stylesheet" type="text/css" href="'
+ . $_CONF['site_url'] . $file['file'] . '"' . $file['extra'] . XHTML . '>' . LB;
if (isset($file['name']) && $file['name'] == 'theme') { // load theme css first
$headercode = $csslink . $headercode;
} else {
$headercode .= $csslink;
}
}
- }
+ }
// Set JavaScript (do this before file incase variables are needed)
if (isset($this->scripts['header'])) {
More information about the geeklog-cvs
mailing list