User Tools

Site Tools


en:dev:284:registry

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:dev:284:registry [16.05.2015 11:46] – created Manuela v.d.Deckenen:dev:284:registry [26.09.2023 07:14] (current) – [Changed identifiers] Manuela v.d.Decken
Line 1: Line 1:
-FIXME **This page is not fully translated, yet. Please help completing the translation.**\\ //(remove this paragraph once the translation is finished)//+====== The Registry (WbAdaptor) ====== 
 +Programming without **global** constants and variables.
  
-====== Die Registry (WbAdaptor) ====== +In the medium term it is planned to build up a 'Registry' in WebsiteBaker. Until this is ready, the class '**WbAdaptor**' will take over this task. First of all, the class provides properties that are more or less identical with the previous constants. At the same time, also the old constants are -still- available unchanged for old code, however they may **no longer** be used for new or revised Code! 
-Programmieren ohne **globale** Konstanten und Variablen.+===== Overview ===== 
 +Global constants show a fundamental characteristic which very much supports 'lazy' programming: Once declared, they are directly available at absolutely any location of the source code requiring no additional expense. Visibility and scope don't play any role for them. Absolutely 'lazy' programmers abuse constants as variables that, eventually set in sequence, and then are available at no extra transfer in the following functions. The apparent advantages, however, also face significant disadvantages. Security-critical data are **never** stored in constants. The best negative example in previous WB versions are the credentials for access to the database, which were available in each droplet, each piece of dynamic code of a template etc., absolutely freely accessible for everyone.
  
-Mittelfristig ist geplantin WebsiteBaker eine 'Registry' aufzubauen. Bis diese endgültig stehtwird die Klasse '**WbAdaptor**' einen Teil deren Aufgaben übernehmenZu allererst stellt die Klasse Eigenschaften bereit, die mit den bisherigen Konstanten mehr oder weniger identisch sind. Parallel dazu stehen auch die alten Konstanten, für alten Code, -noch- unverändert zur Verfügung, jedoch dürfen sie **nicht** mehr für neuen oder überarbeiteten Code benutzt werden! +Global constants (as well as global variables)used within classesbreak up their clear encapsulation and can prevent the reusability of the codeSee 'Basics of object-oriented programming'.
-===== Überblick ===== +
-Globale Konstanten haben eine grundlegende Eigenschaft, die 'fauler' Programmierung sehr entgegen kommt: Einmal deklariert, stehen sie ohne jeglichen Zusatzaufwand an absolut jeder Stelle des Quellcodes direkt zur Verfügung. Sichtbarkeitsund Gültigkeitsbereiche spielen für sie keinerlei Rolle. Ganz 'faule' Programmierer benutzen Konstanten zweckentfremdet als Variablen, die irgendwann im Ablauf gesetzt werden und dann in nachfolgenden Funktionen ohne extra Übergabe verfügbar sind.  +
-Den scheinbaren Vorteilen stehen jedoch auch deutliche Nachteile gegenüber. +
-Sicherheitskritische Daten gehören **niemals** in Konstanten abgelegt. Das schönste Negativbeispiel sind in früheren WB-Versionen die Zugangsdaten zur Datenbank, die dadurch im letzten Droplet, im letzten variablen Codestück eines Templates etc. für jederman absolut frei zugänglich waren.+
  
-Globale Konstanten (ebenso wie globale Variablen)benutzt innerhalb von Klassendurchbrechen deren klare Datenkapselung und können die Wiederverwendbarkeit von Code verhindernSiehe 'Grundlagen der Objektorientierten Programmierung'.+Global constants areas has long been statedfrom this version on deprecated, that is undesirable. See: [[dev:284:deprecated|Deprecated-List Entry 10 from 12.2013]].
  
-Globale Konstanten sind jawie schon seit langem bekannt, ab dieser Version deprecated, sprich unerwünschtSiehe: [[dev:284:deprecated|Deprecated-Liste Eintrag 10 v12.2013]]+Of coursediscarding all previous constants without any replacement is clearly not a feasible approachThat's simply impossibleAt least in the first step, the class '**WbAdaptor**' makes properties available that are similar to the previous constants.
  
-Selbstverständlich funktioniert das jetzt nicht sodass man alle bisherigen Konstanten einfach nur Ersatzlos streicht. Das ist schlichtweg unmöglich. Zumindest im ersten Schritt stellt die Klasse '**WbAdaptor**' jedoch Eigenschaften bereit, die den bisherigen Konstanten ähneln.+A significant change has arisen about the spelling of the identifier:\\ 
 +The identifiers have been written entirely in capital letters and separated several individual words with an underscore **_**the new identifiers however still consist of the same sub strings, but now they are  written in '**//StudlyCaps//**' notation without delimiters between words.
  
-Eine wesentliche Änderung hat sich bei der Schreibweise der Bezeichner ergeben:\\ +__Example:__ **DEFAULT_TEMPLATE** becomes **DefaultTemplate** now
-Wurden die Bezeichner bisher ausschließlich in Großbuchstaben geschrieben und mehrere Einzelworte durch einen Unterstrich **_** getrennt, so bestehen die neuen Bezeichner zwar weiterhin aus der selben Zeichenfolge, jedoch in '**//StudlyCaps//**'-Schreibweise ohne Trennzeichen zwischen einzelnen Wörtern.+
  
-__Beispiel:__ aus **DEFAULT_TEMPLATE** wird jetzt **DefaultTemplate**+The transformation of the identifier is performed automatically when reading in the class WbAdaptor.
  
-Die Transformation der Bezeichner erfolgt automatisch beim Einlesen in die Klasse WbAdaptor.+So far so goodTo make it not too simple, for about a dozen former constants the identifier (key) and also partially the content has completely changed!!
  
-Soweit so gut. Damit es nicht ganz so einfach wird, hat sich bei einem runden Dutzend ehemaliger Konstanten der Bezeichner(Schlüssel) komplett verändert und auch teilweise der Inhalt!!+===== Changed identifiers =====
  
 +List of new identifiers and examples of the current contents.\\
 +FIXME (note: this list is not complete!)
  
-===== Geänderte Bezeichner ===== +^old constant   ^new key    ^content (example)  ^ 
-  +|NEW               |getDatabase()   |the current object for accessing the database  
-Liste mit neuen Bezeichnern und Beispielen des jetzigen Inhaltes.\\ +|NEW               |getTranslate()  |the current translation object                 
-FIXME (Achtung: diese Liste ist nicht vollständig!) +|NEW               |getApplication() |the current application/core object ($wb or $admin) |  
- +|NEW               |getRequester()  |the current requester Objekt                  | 
-^alte Konstante   ^neuer Schlüssel    ^Inhalt (Beispielhaft)  ^ +|NEW               |PageId          |the ID of the current page                     | 
-|{neu eingeführt}  |Db              |das aktuelle Datenbankzugriffsobjekt           +|NEW               |BlockId         |the ID of the current block                    
-|{neu eingeführt}  |Trans           |das aktuelle Translation-Objekt                +|NEW               |SectionId       |the ID of the current section                  |
-|{neu eingeführt}  |App             |das aktuelle Applikations-/Core-Objekt         |  +
-|{neu eingeführt}  |PageId          |die ID der aktuellen Seite                     | +
-|{neu eingeführt}  |BlockId         |die ID des aktuellen Blockes                   +
-|{neu eingeführt}  |SectionId       |die ID der aktuellen Section                   |+
 |WB_URL            |AppUrl          |http: ⁄⁄ example.com/wb/                                                     | |WB_URL            |AppUrl          |http: ⁄⁄ example.com/wb/                                                     |
-|WB_REL            |AppRel          |/wb/                                                                         +|WB_REL            |AppRel          |/wb/  (absolute path from DOCUMENT_ROOT, for use as a relative URL)                                                                      
-|WB_PATH           |AppPath         |/var/www/httpdocs/wb/ \\ in Windows alternativ  ('c:/var/www/httpdocs/wb/' |+|WB_PATH           |AppPath         |/var/www/httpdocs/wb/ \\ alternatively, in Windows  ('c:/var/www/httpdocs/wb/' |
 |ADMIN_URL         |AcpUrl          |http: ⁄⁄ example.com/wb/admin/                                               | |ADMIN_URL         |AcpUrl          |http: ⁄⁄ example.com/wb/admin/                                               |
 |ADMIN_REL         |AcpRel          |/wb/admin/                                                                   | |ADMIN_REL         |AcpRel          |/wb/admin/                                                                   |
Line 47: Line 43:
 |TEMPLATE          |Template        |MyTemplate             | |TEMPLATE          |Template        |MyTemplate             |
 |TEMPLATE_DIR      |TemplateDir     |templates/MyTemplate/  | |TEMPLATE_DIR      |TemplateDir     |templates/MyTemplate/  |
-|{neu eingeführt}  |TemplateUrl     |http: ⁄⁄ example.com/wb/templates/MyTemplate/ +|NEW               |TemplateUrl     |http: ⁄⁄ example.com/wb/templates/MyTemplate/ 
-|{neu eingeführt}  |TemplateRel     |/wb/templates/MyTemplate/ +|NEW               |TemplateRel     |/wb/templates/MyTemplate/ 
-|{neu eingeführt}  |TemplatePath    |/var/www/httpdocs/wb/templates/MyTemplate/  |+|NEW               |TemplatePath    |/var/www/httpdocs/wb/templates/MyTemplate/  |
 |ADMIN_DIRECTORY   |AcpDir          |admin/                                                                       | |ADMIN_DIRECTORY   |AcpDir          |admin/                                                                       |
 |PAGES_DIRECTORY   |PagesDir        |pages/                                                                       | |PAGES_DIRECTORY   |PagesDir        |pages/                                                                       |
Line 56: Line 52:
 |WB_REVISION       |AppRevision     |2060                                                                         | |WB_REVISION       |AppRevision     |2060                                                                         |
 |WB_SP             |AppServicePack  |SP1                                                                          | |WB_SP             |AppServicePack  |SP1                                                                          |
-|{neu eingeführt}  |AppName         |WebsiteBaker                                                                 | +|NEW               |AppName         |WebsiteBaker                                                                 | 
-|STRING_DIR_MODE   |DirModeString   | %%rwxrwxr-x%%   (textuelle Darstellungentspricht 0775 Oktal)                                                           | +|STRING_DIR_MODE   |DirModeString   | %%rwxrwxr-x%%   (textual representationcorresponds to 0775 octal)                                                           | 
-|OCTAL_DIR_MODE    |DirModeOctal    | %%509%% (gespeicherter Integerentspricht 0775 Oktal)  | +|OCTAL_DIR_MODE    |DirModeOctal    | %%509%% (stored integercorresponds to 0775 written in octal)  | 
-|STRING_FILE_MODE  |FileModeString  | %%rw-rw-r--%%   (textuelle Darstellungentspricht 0664 Oktal)                                                           | +|STRING_FILE_MODE  |FileModeString  | %%rw-rw-r--%%   (textual representationcorresponds to 0664 octal)                                                           | 
-|OCTAL_FILE_MODE   |FileModeOctal   | %%436%% (gespeicherter Integerentspricht 0664 Oktal)  |+|OCTAL_FILE_MODE   |FileModeOctal   | %%436%% (stored integercorresponds to 0664 written in octal)  |
  
-Wer die Liste aufmerksam durchschautwird ein paar neue Gesetzmäßigkeiten erkennen:+Who looks attentively at the listwill recognize a few new laws:
  
-Die Zeichenfolge **WB_** wurde zu **App** (hat nichts mit irgendwelchen APP-Stores zu tun!!), es ist einfach nur die ursprüngliche Abkürzung für Applikation => Anwendung => Programm.\\ +The string **WB**_ became **App** (has nothing to do with any of these App Stores !!), it's just the original abbreviation for application =>  program.\\ 
-Die Zeichenfolge **ADMIN_** wurde zu **Acp** was **A**dmin**C**ontrol**P**anel bedeutetda die Funktionen und Bezeichnungen 'Backendund 'Admin-Tools' in einer der Folgeversionen abgeschafft bzw. ersetzt werden.\\+The string **ADMIN_** became **Acp** which is the abbreviation for **A**dmin **C**ontrol **P**anel, because the functions and names 'backendand 'admin toolswill be abolished or replaced in one of the subsequent versions.\\
  
-Unabhängig von den geänderten Präfixes gelten folgende Regeln für Endungen+Regardless of the changed prefixes, the following rules apply for extensions
-  * xxx**Url** beinhaltet grundsätzlich eine vollwertige URL mit Protokollangabe +   * xxx**Url** basically includes a full URL with protocol specification 
-  * xxx**Path** beinhaltet einen vollwertigen Pfad ausgehend vom Wurzelverzeichnis des physikalischen Dateisystems und beginnt **immer** mit einem Slash** / ** bzw. **c:/** unter Windows. +   * xxx**Path** includes a full path starting from the root directory of the physical file system and **always** begins with a slash ** / ** and **c:/** for Windows. 
-  * xxx**Rel** beinhaltet einen absoluten Pfadausgehend von DOCUMENT_ROOT und beginnt **immer** mit einem Slash** / ** +   * xxx**Rel** includes an absolute pathstarting from DOCUMENT_ROOT and **always** begins with a slash ** / ** 
-  * xxx**Dir** beinhaltet ein oder mehrere aufeinanderfolgende Verzeichnisnamenund darf **nicht** mit einem Slash** / ** beginnen. +   * xxx**Dir** contains one or more successive directory namesand **must not** start with a slash ** / **.
-__Für alle Angaben gemeinsam gilt:__ +
-  * Als PATH_SEPERATOR ist ausschließlich der Slash** / ** zugelassen. Anpassungen können problemlos erfolgen mit\\ <php> $sPath = str_replace('\\', '/', $sPath); </php> +
-  * Ist das letzte Element einer URL-,Rel-, Path-, oder Dir-Angabe ein Verzeichnis, so **muss** die Angabe mit einem Slash** / ** enden.\\ +
-  * Um sicher zu stellen, dass ein Verzeichnis mit einem einzelnen Slash** / **abgeschlossen wird genügt die kurze Sequenz\\ <php> $sPath = rtrim($sPath, '/').'/'; </php> +
-  * Führende Slashes** / **werden entfernt mit\\ <php>  $sPath = ltrim($sPath, '/');  </php>+
  
-ALT => NEU Beispiele+__for all statements in common the following rules apply:__ 
-|     ^ Schlüssel        ^ Wert                     ^ +  * As PATH_SEPERATOR only the slash** ** is allowedAdjustments can be made easily with\\ <code> $sPath = str_replace('\\', '/', $sPath); </code> 
-^alt  | WB_URL           | http: ⁄⁄ example.com/wb  | +  * If the last element of a URL, Rel, Path-, or Dir-specified directory, the indication must terminate on a slash** **.\\ 
-^neu  | AppUrl           | http: ⁄⁄ example.com/wb| +  * To ensure that a directory path is terminated with a single slash** **the short sequence is sufficient\\ <code> $sPath = rtrim($sPath, '/').'/'; </code> 
-^alt  | ADMIN_REL        | /wb/admin                | +   Leading slashes** **are removed by\\ <code>  $sPath = ltrim($sPath, '/');  </code>
-^neu  | AcpRel           /wb/admin              |  +
-^alt  | PAGES_DIRECTORY  /pages                   | +
-^neu  | PagesDir         | pages                  | +
-^alt  | TEMPLATE_DIR     | http: ⁄⁄ example.com/wb/templates/MyTemplate +
-^neu  | TemplateDir      | templates/MyTemplate/    |+
  
 +OLD => NEW example:
 +|     ^ key        ^ value                     ^
 +^old  | WB_URL           | http: ⁄⁄ example.com/wb  |
 +^new  | AppUrl           | http: ⁄⁄ example.com/wb/ |
 +^old  | ADMIN_REL        | /wb/admin                |
 +^new  | AcpRel           | /wb/admin/               
 +^old  | PAGES_DIRECTORY  | /pages                   |
 +^new  | PagesDir         | pages/                   |
 +^old  | TEMPLATE_DIR     | http: ⁄⁄ example.com/wb/templates/MyTemplate  |
 +^new  | TemplateDir      | templates/MyTemplate/    |
  
-===== Anwendung von WbAdaptor ===== +===== Application of WbAdaptor ===== 
-Diese Klasse ist von überall zu erreichenEs genügt völlig, die einzig existierende, aktive Instanz der Klasse mit\\ <php> $oReg = WbAdaptor::getInstance(); </phpin den aktuellen Sichtbarkeitsbereich zu importierenNoch besser ist jedoch die Nutzung von Dependency-Injectionalso die Übergabe der Instanz von außen an die Funktion oder Klasse.+This class can be reached from anywhereIt is sufficient to import that only existing active instance of the class with\\ <code> $oReg = \bin\WbAdaptor::getInstance(); </codeto import into the current scope 
 +But even better is the use of dependency injectioni.e. the transfer of the instance from outside to the function or class.
  
-:!: Es wird dringend empfohlen, den Bezeichner //**$oReg**// für die Instanz des WbAdaptor-Objektes zu verwenden um eine leichtere und über alle Programmteile durchgängige Lesbarkeit zu erreichen.+:!: It is strongly recommended that the identifier //**$oReg**// is used for the instance of the WbAdaptor object in order to achieve a better and consistent readability of all program components.
  
-Auch der Abruf der einzelnen Werte ist recht unproblematisch:\\ +Also the request of the individual values quite straightforward:\\ 
-<php> echo $oReg->TemplateDir.'images/logo.png'; </php> \\ +<code> echo $oReg->TemplateDir.'images/logo.png'; </code> \\ 
-Ausgabe:  ''templates/myTemplate/images/logo.png''+Output:  ''templates/myTemplate/images/logo.png''
  
-Was nach außen nicht sichtbar istist der Umstand dass alle abrufbaren Werte in zwei Basis-Gruppen abgelegt sind+What is not visible from the outsidethe fact is that all retrievable values are stored in two basic groups
-  * //System//  ⇒ das sind alle Werte, die bei unveränderten Grundeinstellungen bei jedem Scriptaufruf **immer** gleich sind+  * //System// -> these are all values that are **always** the same at constant, for basic settings constant for each script call
-  * //Request// ⇒ alle anderen Wertedie je nach SeiteBenutzerRequestmodus oder sonstigen Kriterien unterschiedliche Werte haben können+  * //Request// -> all other valueswhich candepending on the pageusers who request mode or other criteria have different values
-Die //System//-Werte sind geschützt und können **nicht** durch //Request//-Werte oder anderes überschrieben werden.+The system values are protected and can **not** be overridden by //Request// values or anything else.
  
  
en/dev/284/registry.1431776778.txt.gz · Last modified: 03.06.2015 15:55 (external edit)