Wątki

[ Pobierz całość w formacie PDF ]
.The required perform method isthen invoked, passing the standard parameters.For convenience, a triggerOnce method is provided that will trigger only a singleplug in, using the trigger method, and the parameter limiting the number of plugins activated.Installing and Managing ExtensionsIt could certainly be argued that a custom CMS framework for use on a limitednumber of sites does not need an installer for extensions.They can simply be addedto the system by making code changes.But this rapidly becomes onerous, and whenthe number of sites grow or there is a desire to package extensions, an installer is avaluable feature.[ 163 ] Handling ExtensionsThe Aliro installer is constructed out of a built-in application that providesan interface for the administrator and organizes the package to be installed; aframework class does the actual work of taking a package and installing it into theframework.It is called aliroExtensionInstaller and it relies on aliroXML, whichis described in a later chapter to handle the XML file that defines the package to beinstalled.The basic XML handling is carried out using the SimpleXML feature that isincluded by default in PHP5.The installer is too large and complex to show here in its entirety, so only the overallstructure is discussed.Structuring Installer TasksThere are three main aspects to handling extensions:" The files that are provided to make up the new extension have to be movedto suitable locations.Ideally the framework allows for PHP code to be locatedoutside the document root for security, while files such as images or CSSneed to be within the document root so that they can be used by theweb server." Database tables need to be amended so that the framework is aware of thenew extension.Aliro works by having an extensions table that contains onerecord for each and every distinct extension.Then there are separate tablesfor most specific extension types.These tables may contain multiple entriesrelating to a single extension, assuming it is possible for the system to usethe same code for more than one purpose perhaps with different parameters.Modules can obviously be used in this way, but it can also be madeapplicable to components and templates." New classes belonging to the extension need to be tracked so that therelevant file can be automatically loaded when needed.In fact, this is anotherdatabase issue, and involves updating the class map table.Obviously, although the requirements above describe the installation of an extension,the reverse processes must also be available to deal with the removal of extensionsthat are no longer required.A positive feature is to support upgrade as a distinctoperation, rather than removal and re-installation.The requirements for upgradeare generally not well handled by removal and re-installation because in the caseof upgrade it is important to leave the current data in place, whereas true removalinvolves deleting any residual data.Apart from that important functional difference,it is much more convenient to be able to load an upgrade rather than having to carryout two distinct steps.[ 164 ] Chapter 7Putting Extension Files in PlaceThe work of deciding where files belong is done by the extension handlers.Earlierin this chapter, we looked at them and noted that each specific template handlerdeclares the $extensiondir variable, and gives it a value.It is a protected propertythat can be accessed by methods in the base class from which individual handlers aresubclassed.This way, there are only a few lines of code across the whole system fordetermining the directories to be used by an extension type.Although files may be split between those that need to be within the document rootsuch as images and those that for security are better located outside the documentroot such as files containing PHP classes, the same directory structure is used in bothcases, and the handlers provide only relative directory information.The work of aliroInstaller is therefore to take the information about filesgiven in the XML packaging file, and to move the files into places determined bythe extension handlers.So as to have a central point for file system related issues,any file or directory operations are carried out by the aliroFileManager, andaliroDirectory classes.Extensions and the DatabaseThe extensions table is the primary arbiter of whether an extension exists in thesystem or not.When a new extension is to be installed, its formal name is checkedagainst the extensions table, and if found an error is returned, and the installationabandoned.On the other hand, if an extension is to be upgraded it must currentlyexist in the extensions table.When deciding whether an extension can be installed ornot, no account is taken of the existence of any files, since these could be the result ofa failed installation attempt.For either a new or upgraded installation, any existingfiles are removed.Uninstall works in compatible fashion [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • mikr.xlx.pl
  • Powered by MyScript