コード例 #1
0
ファイル: Core.class.php プロジェクト: nicholasryan/CorePlus
	/**
	 * 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);
	}