/** * Set this packagexml with data from the component. * This is useful in the packager. * * WARNING, this will revert any modifications done to the package.xml file! * * @param Component_2_1 $component * * @return string */ public function setFromComponent(Component_2_1 $component){ // Populate the root attributes for this component package. $this->setType('component'); $this->setName($component->getName()); $this->setVersion($component->getVersion()); $this->setPackager(Core::GetComponent()->getVersion()); // Copy over any provide directives. foreach ($component->getRootDOM()->getElementsByTagName('provide') as $u) { $this->getRootDOM()->appendChild($this->getDOM()->importNode($u)); } $this->setProvide('component', $component->getName(), $component->getVersion()); // Copy over any requires directives. foreach ($component->getRootDOM()->getElementsByTagName('require') as $u) { $this->getRootDOM()->appendChild($this->getDOM()->importNode($u)); } // Copy over any upgrade directives. // This one can be useful for an existing installation to see if this // package can provide a valid upgrade path. foreach ($component->getRootDOM()->getElementsByTagName('upgrade') as $u) { // In this case, I just need the definition itself, I don't also need the contents of that upgrade. $this->setUpgrade($u->getAttribute('from'), $u->getAttribute('to')); } // Tack on description $desc = $component->getRootDOM()->getElementsByTagName('description')->item(0); if ($desc) { $this->setDescription($desc->nodeValue); } }
/** * Internally used method to notify the rest of the system that a given * component has been loaded and is available. * * Expects all checks to be done already. */ public function _registerComponent(Component_2_1 $c) { $name = str_replace(' ', '-', strtolower($c->getName())); if ($c->hasLibrary()) { $liblist = $c->getLibraryList(); $this->_libraries = array_merge($this->_libraries, $liblist); // Register the include paths if set. foreach ($c->getIncludePaths() as $path) { set_include_path(get_include_path() . PATH_SEPARATOR . $path); } } $this->_scriptlibraries = array_merge($this->_scriptlibraries, $c->getScriptLibraryList()); if ($c->hasModule()) $this->_modules[$name] = $c->getVersionInstalled(); $this->_classes = array_merge($this->_classes, $c->getClassList()); $this->_viewClasses = array_merge($this->_viewClasses, $c->getViewClassList()); $this->_widgets = array_merge($this->_widgets, $c->getWidgetList()); $this->_components[$name] = $c; // Permissions were not enabled prior to 2.1, so the legacy components do not have the function. if($c instanceof Component_2_1){ $this->_permissions = array_merge($this->_permissions, $c->getPermissions()); ksort($this->_permissions); // Register this component's user authdrivers, if any. $auths = $c->getUserAuthDrivers(); foreach($auths as $name => $class){ \Core\User\Helper::$AuthDrivers[$name] = $class; } } // All models get a control link registered automatically :) $models = $c->getModelList(); foreach($models as $class => $file){ if(!HookHandler::GetHook('/core/controllinks/' . $class)){ $h = new Hook('/core/controllinks/' . $class); $h->returnType = Hook::RETURN_TYPE_ARRAY; $h->description = 'Automatic hook for control links on the ' . $class . ' object. Attach onto this hook if you want to add a custom link anytime this object\'s control is displayed.'; } } $licenser = $c->getLicenseData(); if($licenser && defined('SERVER_ID') && class_exists('\\Core\\Licenser')){ // This will contain a url key and the features. $url = $licenser['url']; $comp = $c->getKeyName(); foreach($licenser['features'] as $key){ \Core\Licenser::RegisterFeature($key, $url, $comp); } } // Lastly, mark this component as available! $c->_setReady(true); }