/** * method that will return the absolute path of a mounted resource * @param $name : mount point name * @return mixed|null */ public function toAbsolutePath($name) { $name = str_replace('%', '', $name); $resource = $this->getResource($name, true); if ($resource) { $resource = $this->resolveResource($resource); } else { error_log('couldnt resolve resource : ' . $name); xapp_clog('couldnt resolve resource : ' . $name); return null; } if (xapp_property_exists($resource, XAPP_RESOURCE_PATH_ABSOLUTE)) { return xapp_property_get($resource, XAPP_RESOURCE_PATH_ABSOLUTE); } return null; }
public function resolveResource(&$resource) { if ($resource !== null && is_object($resource)) { if (xapp_property_exists($resource, XAPP_RESOURCE_NAME) && xapp_property_exists($resource, XAPP_RESOURCE_PATH)) { //not resolved yet ? if (!xapp_property_exists($resource, XAPP_RESOURCE_PATH_ABSOLUTE)) { $resource->{XAPP_RESOURCE_PATH_ABSOLUTE} = $this->resolveAbsolute(xapp_property_get($resource, XAPP_RESOURCE_PATH)); } } } else { error_log('resource/Renderer : have no resources!!!'); } return $resource; }
public function addJSIncludes($print = false) { $scriptItems = $this->getResourcesByType(XAPP_RESOURCE_TYPE_JS_INCLUDE, true); if ($scriptItems != null && count($scriptItems)) { $scriptTags = ''; foreach ($scriptItems as $resourceItem) { if (!is_object($resourceItem)) { continue; } if (!xapp_property_exists($resourceItem, XAPP_RESOURCE_URL_RESOLVED)) { $resourceItem = $this->resolveResource($resourceItem); } if (xapp_property_exists($resourceItem, XAPP_RESOURCE_URL_RESOLVED)) { $url = xapp_property_get($resourceItem, XAPP_RESOURCE_URL_RESOLVED); $scriptTag = "<script type='text/javascript' src='" . $url . "'></script>\n"; $scriptTags .= $scriptTag; } } if ($print) { echo $scriptTags; } return $scriptTags; } return ''; }
/** * method that will return the absolute path of a mounted resource * @param $name : mount point name * @return mixed|null */ public function toAbsolutePath($name) { $resource = $this->getResource($name, true); if ($resource) { $resource = $this->resolveResource($resource); } else { /*xapp_dump($this);*/ return null; } if (xapp_property_exists($resource, XAPP_RESOURCE_PATH_ABSOLUTE)) { return xapp_property_get($resource, XAPP_RESOURCE_PATH_ABSOLUTE); } return null; }
public function renderHTML($type = XAPP_RESOURCE_TYPE_HTML) { $html = ''; $cssItems = $this->getResourcesByType($type, true); if ($cssItems != null && count($cssItems)) { foreach ($cssItems as $resourceItem) { if (!xapp_property_exists($resourceItem, XAPP_RESOURCE_URL_RESOLVED)) { $resourceItem = $this->resolveResource($resourceItem); } if (xapp_property_exists($resourceItem, XAPP_RESOURCE_PATH_ABSOLUTE)) { $path = xapp_property_get($resourceItem, XAPP_RESOURCE_PATH_ABSOLUTE); if (file_exists($path)) { $content = file_get_contents($path); if ($content !== false) { $keyValues = $this->registryToKeyValues(xapp_get_option(self::RELATIVE_REGISTRY_NAMESPACE, $this)); $content = $this->resolveRelative($content); $html .= $content; } } else { } } else { } } } else { } return $html; }