public static function jQueryUI($version = NULL, Staple_Layout $layout = NULL) { if (Staple_Request::isSecure()) { $protocol = 'https://'; } else { $protocol = 'http://'; } if (isset($version)) { $script = $protocol . 'ajax.googleapis.com/ajax/libs/jqueryui/' . basename($version) . '/jquery-ui.min.js'; } else { $script = $protocol . 'ajax.googleapis.com/ajax/libs/jqueryui/' . self::JQUERYUI_CURRENT . '/jquery-ui.min.js'; } if ($layout instanceof Staple_Layout) { $layout->addScript($script); } return $script; }
public function scripts() { $secure = Staple_Request::isSecure(); foreach ($this->scripts as $src) { if ($secure === true) { $src = str_replace('proto://', 'https://', $src); } else { $src = str_replace('proto://', 'http://', $src); } echo "<script src=\"" . htmlentities($src) . "\" type=\"text/javascript\"></script>\n"; } foreach ($this->scriptBlocks as $sBlock) { echo "<script type=\"text/javascript\">\n<!--\n"; echo $sBlock; echo "\n-->\n</script>\n"; } }
/** * Checks the PHP $_SERVER var for the presence of HTTPS. Returns a boolean. * @return boolean */ public static function isSecure() { if (!isset(self::$secure)) { if (array_key_exists('HTTPS', $_SERVER)) { if ($_SERVER['HTTPS'] == 'on') { self::$secure = true; } else { self::$secure = false; } } elseif (array_key_exists('SERVER_PORT', $_SERVER)) { if ($_SERVER['SERVER_PORT'] == '443') { self::$secure = true; } else { self::$secure = false; } } else { self::$secure = false; } } return (bool) self::$secure; }