/** * @param $url * @param array $params * * @return String */ public function addQueryStringParams($url, $params = array()) { gantry_import('core.utilities.gantryurl'); return GantryUrl::updateParams($url, $params); }
/** * Updates values of existing url params and/or adds (if not set) those specified in $aParams * * @param String $sUrl Url * @param Array $aParams Array of Key-Value pairs to set url params to * @return String Newly compiled url */ function updateParams($sUrl, $aParams) { $aUrl = GantryUrl::explode($sUrl); $aUrl['query'] = ''; $aUrl['query_params'] = array_merge($aUrl['query_params'], $aParams); return GantryUrl::implode($aUrl); }
function addScript($file = '') { if (defined('GANTRY_FINALIZED')) { return; } if (is_array($file)) { return $this->addScripts($file); } //special case for main JS libs if ($file == 'mootools.js') { wp_enqueue_script($file); return; } $type = 'js'; // check to see if this is a full path file $dir = dirname($file); $scripturl = GantryUrl::explode($file); $base = GantryUrl::explode(get_option('siteurl')); $same_domain = $scripturl['host'] == $base['host'] && preg_match('#^' . $base['path'] . '#', $scripturl['path']); if ($dir != ".") { // full url if (($scripturl['scheme'] == 'http' || $scripturl['scheme'] == 'https') && !$same_domain) { $this->_full_scripts[] = $file; return; } if ($same_domain) { $dir = dirname($scripturl['path']); } // For local url path get the local path based on checks $url_path = $dir; $file_path = $this->_getFilePath($file); $url_file_checks = $this->platform->getJSChecks($file_path, true); foreach ($url_file_checks as $url_file) { $full_path = realpath($url_file); if ($full_path !== false && file_exists($full_path)) { $check_url_path = $url_path . '/' . basename($url_file); $this->_scripts[$full_path] = $check_url_path; break; } } return; } $out_files = array(); $paths = array($this->templateUrl => $this->templatePath . DS . $type, $this->gantryUrl => $this->gantryPath . DS . $type); $checks = $this->platform->getJSChecks($file); foreach ($paths as $baseurl => $path) { if (file_exists($path) && is_dir($path)) { foreach ($checks as $check) { $check_path = preg_replace("/\\?(.*)/", '', $path . DS . $check); $check_url_path = $baseurl . "/" . $type . "/" . $check; if (file_exists($check_path) && is_readable($check_path)) { $this->_scripts[$check_path] = $check_url_path; break 2; } } } } }