[ Pobierz całość w formacie PDF ]
.Although uninstall is most effectively carried out by retrieving theXML packaging file, if that cannot be found then uninstall does its best to remove theextension.This may not achieve the result intended by the extension's designer since,for example, any SQL meant to be run on uninstall will not have been run as it isstored in the XML file.However, the aim is to achieve as clean a situation as possibleand to avoid leaving the administrator in a bind.On install, a new entry is made in the extensions table, with data obtained byvalidating the information given in the XML packaging file.Wherever required, theinstaller contains extension specific code to create a default entry in the appropriatetable, for example, component or module.[ 165 ] Handling ExtensionsKnowing About Extension ClassesBack in Chapter 3, we implemented a smart class loader so as to avoid any need toworry about code loading within the system.The loader has information about thecore of the CMS framework written into it, but it refers to the classmap databasetable to know about extensions.Packaging XML identifies the files of an extension that contain classes, and for eachfile there is a classes attribute that gives the class name.So the installer, as it putsthe files into their correct places, also takes account of the XML to add informationto the classmap table.Naturally, the XML has to contain correct and completeinformation about classes for the system to work! But once this is done, the codeworks without any need to know where the files are or whether they havebeen loaded.SummaryIn the previous chapters, we were building fundamental services that are useful in aCMS.In this chapter, we have thought about a uniform architecture for adding thefunctionality that is actually visible to the user.That visibility is primarily providedby modules creating output within screen areas.Those screen areas are constructedby a template, which has overall control over as many aspects of the visible style ofthe site as can possibly be achieved.Less immediately visible but potentially much larger than either modules ortemplates, components provide specific functionality to deliver the objectives ofthe website.Operating beneath the surface but often having an effect on the visibleresults, plug ins are usually small units of code that give added flexibility.All of the mechanisms are designed to conform to modern design standardsthat separate styling from raw data.Equally important is the aim to have a systemthat is highly "pluggable" so that customization is feasible, even in the face offrequent updating.[ 166 ] Caches and HandlersRunning PHP has quite a high cost, but in return we gain the benefit of a verypowerful and flexible language.The combination of power and high cost suggeststhat for any code that will be executed frequently, we should use the power of PHPto aid efficiency.The greatest efficiency is gained by streamlined design.After all,not doing things at all is always the best way to achieve efficiency.Designing witha broad canvas, so as to solve a number of problems with a single mechanism, alsohelps.Add one particular device the cache provides a way to store data that hasbeen partly or wholly processed and can be used again.This obviates doing theprocessing over again, which can lead to great efficiency gains.The ProblemA CMS framework needs to handle a huge variety of requests efficiently.To enhanceefficiency, we need to think about:" design patterns that improve overall efficiency" situations where data, once processed, can be reused" mechanisms for implementing storage of processed dataDiscussion and ConsiderationsIf everything is considered in isolation, it leads to a design where one issue is solvedat a time.To make that clear, let's take an example from the last chapter, the handlingof a module type of extension. Caches and HandlersEach module requires the calling of a class, but the call has to pass informationspecific to that module.The required information is stored in a database table, withone row for each box created by a module.The data includes vital information suchas the position of the box, and any parameters that affect how it will be presentedon the browser screen.Clearly, one way to process modules is to pick out onlythose boxes that are needed for a particular part of the browser screen, and run themodules that create them.If we were especially inefficient, our implementationmight refer back to the database as it processed each individual box.Looked at in its totality, we see that this mechanism is inefficient.It involves multiplerequests to the database, using SQL that contains conditions.Given that memory isrelatively easily available, with web applications normally allowed many megabytes,we can do better.When the problem involves rows that are limited in number, andeach one requires only a modest amount of data, it makes sense to read the wholetable into memory [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • czarkowski.pev.pl
  •