/** * Get CSS file references */ private function initCSSReference() { $cssReference = ""; $regExpForUrlPath = '/(url\\(["\']?)([^\\/\\)][^\\)]*["\']?\\))/'; $plugin_cssFileList = $_SESSION['plugin_cssFileList']; if (count($plugin_cssFileList) > 0) { $mergeCSS = isset($_SESSION['pm_merge_css_plugins_files']) && $_SESSION['pm_merge_css_plugins_files'] == 1; if ($mergeCSS) { $cssReference .= "<style type=\"text/css\">\n"; } foreach ($plugin_cssFileList as $pf) { if (!$mergeCSS) { $cssReference .= " <link rel=\"stylesheet\" href=\"{$pf}\" type=\"text/css\" />\n"; } else { $tmpFile = $_SESSION['PM_BASE_DIR'] . "/{$pf}"; if (file_exists($tmpFile) && is_file($tmpFile)) { ob_start(); include $tmpFile; $cssReferenceTmp = ob_get_contents(); // change path for images: $path = dirname($pf) . '/'; $cssReferenceTmp = preg_replace($regExpForUrlPath, "\$1{$path}\$2", $cssReferenceTmp); $cssReference .= $cssReferenceTmp; $cssReference .= "\n"; ob_end_clean(); } } } if ($mergeCSS) { $cssReference .= "</style>\n"; } } $dirNames = array(); //- from config/common (custom) dir $dirNames[] = PM_CONFIG_LOCATION_COMMON; //- from config dir $dirNames[] = PM_CONFIG_LOCATION; $dirNames = array_unique($dirNames); $mergeCSS = isset($_SESSION['pm_merge_css_config_files']) && $_SESSION['pm_merge_css_config_files'] == 1; $cssReferenceFiles = array(); foreach ($dirNames as $dirName) { $dirTmp = PM_BASECONFIG_DIR . "/{$dirName}"; if (file_exists($dirTmp)) { $cssFiles = PMCommon::scandirByExt($dirTmp, 'css'); $cssFiles = array_unique($cssFiles); foreach ($cssFiles as $cf) { $cssReferenceFiles[] = "config/{$dirName}/{$cf}"; } } } $cssReferenceFiles = array_unique($cssReferenceFiles); if ($mergeCSS && count($cssReferenceFiles) > 0) { $cssReference .= "<style type=\"text/css\">\n"; } foreach ($cssReferenceFiles as $cssReferenceFile) { if ($mergeCSS) { $tmpFile = $_SESSION['PM_BASE_DIR'] . "/{$cssReferenceFile}"; if (file_exists($tmpFile) && is_file($tmpFile)) { ob_start(); include $tmpFile; $cssReferenceTmp = ob_get_contents(); // change path for images: $path = dirname($cssReferenceFile) . '/'; $cssReferenceTmp = preg_replace($regExpForUrlPath, "\$1{$path}\$2", $cssReferenceTmp); $cssReference .= $cssReferenceTmp; $cssReference .= "\n"; ob_end_clean(); } } else { $cssReference .= " <link rel=\"stylesheet\" href=\"{$cssReferenceFile}\" type=\"text/css\" />\n"; } } if ($mergeCSS && count($cssReferenceFiles) > 0) { $cssReference .= "</style>\n"; } return $cssReference; }
/** * Get the CSS include string for HTML files generation (<link ...>) * * This function is used to easy get all the "<link>" elements for CSS * used in the current configuration. So, if called in a plugin, even in * new opening pages you can have the same appearence than in the map.phtml. * * @param string $pmDir: p.mapper main directory URL * @return string containing "<link ..." */ function getCSSReference($pmDir) { $ret = ""; $dirNames = array(); //- from config/common (custom) dir $dirNames[] = PM_CONFIG_LOCATION_COMMON; //- from config dir $dirNames[] = PM_CONFIG_LOCATION; foreach ($dirNames as $dirName) { if (file_exists(PM_BASECONFIG_DIR . "/" . $dirName)) { $cssFiles = PMCommon::scandirByExt(PM_BASECONFIG_DIR . "/" . $dirName, "css"); $cssFiles = array_unique($cssFiles); if (count($cssFiles) > 0) { foreach ($cssFiles as $cf) { $ret .= " <link rel=\"stylesheet\" href=\"config/" . $dirName . "/{$cf}\" type=\"text/css\" />\n"; } } } } return $ret; }