[geeklog-hg] geeklog: Added setCSS() function to scripts class to allow css t...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Sep 22 17:40:37 EDT 2013
changeset 9309:291e34871eba
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/291e34871eba
user: Tom <websitemaster at cogeco.net>
date: Sun Sep 22 17:40:12 2013 -0400
description:
Added setCSS() function to scripts class to allow css to be set in head with the style tag (feature request #0001687)
diffstat:
system/classes/scripts.class.php | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diffs (64 lines):
diff -r d2f68d44c971 -r 291e34871eba system/classes/scripts.class.php
--- a/system/classes/scripts.class.php Sat Sep 21 22:53:45 2013 -0400
+++ b/system/classes/scripts.class.php Sun Sep 22 17:40:12 2013 -0400
@@ -57,6 +57,7 @@
private $header_set; // Flag to know if Header Code already has been retrieved
private $javascript_set; // Flag to know if ANY JavaScript has been set yet
+ private $css_set; // Flag to know if ANY css has been set yet
/**
* Constructor
@@ -74,6 +75,7 @@
$this->script_files = array();
$this->css_files = array();
$this->scripts = array();
+ $this->css = array();
$this->restricted_names = array();
$this->header_set = false;
@@ -461,6 +463,29 @@
return true;
}
+
+
+ /**
+ * Set CSS in header using style tag
+ *
+ * @param $css css to include in head
+ * @access public
+ * @return boolean
+ *
+ */
+ public function setCSS($css) {
+
+ // If header code make sure header not already set
+ if ($this->header_set) {
+ return false;
+ }
+
+ $this->css[] = $css;
+
+ $this->css_set = true;
+
+ return true;
+ }
/**
* Returns header code (JavaScript and CSS) to include in the Head of the webpage
@@ -503,6 +528,14 @@
}
}
}
+ // Set CSS
+ if ($this->css_set) {
+ $headercode .= '<style type="text/css">' . LB;
+ foreach ($this->css as $css) {
+ $headercode .= $css . LB;
+ }
+ $headercode .= '</style>' . LB;
+ }
// Set JavaScript Library files first incase other scripts need them
if (!$this->library_files_footer) { // // Do we load jQuery now?
More information about the geeklog-cvs
mailing list