Developer Guide Basic
Im folgenden gibt es eine Kurzübersicht zu Varibalen, Object-Pointern und den wichtigen Methoden für Developer.
PHP Konstante | Beschreibung | Beispiel |
---|---|---|
eCMS_APP_CORE_DIR | Der absolute Pfad zum "core" Verzeichnis in der eCMS-Installation. | "/path/to/ecms/installation/core/" |
eCS_CORE_LIB_DIR | Der absolute Pfad zu den eCommerceSuite Core Libraries. | "/path/to/ecms/installation/core/ecs_v5/lib/" |
eCMS_DB_HOST | Der Datenbank Host der eCMS-Installation. | "mysql://localhost" |
eCMS_DB_USER | Der Datenbank User der eCMS-Installation. | "ecms-user" |
eCMS_DB_PASSWD | Das Datenbank Passwort. | "sicheres-passwort" |
eCMS_USER_DB | Die Datenbank mit der eCMS-Admin Benutzer-Verwaltung ("UAM") | "ecms_v3_appecmsadmin" |
eCMS_ENV_PHP_BIN | Das PHP CLI Binary. | "/usr/bin/php" |
eCMS_ENV_FOP_BIN | Das FOP CLI Binary. | "/usr/local/fop/fop.sh" |
eCMS_ENV_TMP_DIR | Der absolute Pfad zum "tmp" Verzeichnis in der eCMS-Installation. | "/path/to/ecms/installation/tmp/" |
eCMS-Variablen in Formaten und eCMS-Plugins
PHP Variable | Beschreibung | Beispiel |
---|---|---|
$this->eCMS->config | Die Site-Konfiguration aus der DB-Tabelle "ecms_site". | Array('site_label' => 'ecs_5_frontend', ...) |
$this->eCMS->_ENV | Die Umgebungsvariablen des Render-Prozesses. | Array('LANGUAGE' => 'DE', ...) |
$this->eCMS->plugin_ecs | Der Object-Pointer auf die eCommerceSuite-Instance der Site. | Object eCommerceSuite |
$this->eCMS->plugin_ecs->Config | Die Shop-Konfiguration aus der DB-Tabelle "eos_eshop". | Array('shoplabel' => 'ecs_5_frontend', ...) |
$this->eCMS->plugin_ecs->shopid | Die Shop-ID aus der Shop-Konfiguration. | "1" |
$this->eCMS->plugin_ecs->ENV | Die Shop-Umgebungsvariablen. | Array('language' => 'DE', ...) |
eCS-Variablen in eCS-Plugins.
PHP Variable | Beschreibung | Beispiel |
---|---|---|
$this->eCS->Config | Die Shop-Konfiguration aus der DB-Tabelle "eos_eshop". | Array('shoplabel' => 'ecs_5_frontend', ...) |
$this->eCS->shopid | Die Shop-ID aus der Shop-Konfiguration. | "1" |
$this->eCS->ENV | Die Shop-Umgebungsvariablen. | Array('language' => 'DE', ...) |
Datenbank-Inhalte und Benutzereingaben encoden (XSS).
$src = 'Sie suchten nach: '.$this->eCMS->xPage->output_encode($this->eCMS->_ENV['GET']['search']);
i18n Textbausteine in Benutzer-Sprache übersetzen.
$string = $this->eCMS->language->text_translate_quick('<i18n-content-string>');
i18n Textbausteine in Benutzer-Sprache übersetzen und Platzhalter "%...%" mit Daten füllen.
Datenbank Date und Datetime in Benutzer Format ausgeben.
$string = $this->eCMS->ecms_plugin_locale->format_date('2016-05-15 17:45:15'); $string = $this->eCMS->ecms_plugin_locale->format_date_smart('2016-05-15 17:45:15'); $string = $this->eCMS->ecms_plugin_locale->format_dateTime('2016-05-15 17:45:15'); $string = $this->eCMS->ecms_plugin_locale->format_dateTime_smart('2016-05-15 17:45:15');
Ausgabe von Float und Integer in Benutzer Format.
$string = $this->eCMS->ecms_plugin_locale->format_float(29.49); $string = $this->eCMS->ecms_plugin_locale->format_float(45000.1015, array('precision'=>2, 'dec_point_only'=>true)); $string = $this->eCMS->ecms_plugin_locale->format_integer(15000);
URL für eCMS Seite erzeugen.
$this->eCMS->xPage->page_getURL('<page-p_label>');
URL auf eCMS Seite mit GET-Parametern erzeugen.
URL auf Shop-Produkt-Detailseite.
URL auf Shop-Kategorie-Detailseite
URL auf Detailseite für andere eCMS Contenttypes (z.B. Blog, FAQ, etc.).
$this->eCMS->ecms_cdb->record->record_getURL(array('xc__label' => 'record-xc__label', 'contenttype' => 'record-ct_label'));
URL Weiterleitung (302) ausführen.
$this->eCMS->xPage->page_redirect('http://www.example.com/goto');
Permanente Weiterleitung (301) ausführen.
Abfrage der User-Session-Daten.
$array = $this->eCMS->session->data_get('UserData');
Abfrage der Shop-Session-Daten
$array = $this->eCMS->session->data_get('eComSuite');
Custom-Session-Daten speichern und abfragen.
$data = $this->eCMS->session->data_get('<your-name>');
URL für Medibase Image erzeugen
$file = $this->eCMS->ecms_mb->mbContent_relocateFile(array('mb_label'=>'your-mediabase-image', 'resize_width'=>500, 'resize_height'=>250)); $img = '<img src="'.$file['data']['target_url'].'" />';
URL zu allen Produkt-Images erzeugen.
$files = $this->eCMS->ecms_mb->mbContent_relocateMBString(array('mb_string'=>$product['files_img'], 'resize_width'=>150, 'resize_height'=>150)); foreach($files['data'] as $file){ $img .= '<img src="'.$file['target_url'].'" />'; }
CSS-Datei On-Demand einbinden. Relativer Pfad ab "www/files/lib_res".
$this->eCMS->srcx->css_use('css/ecms_lib_base.css');
Javascript-Datei On-Demand einbinden. Relativer Pfad ab "www/files/lib_res".
$this->eCMS->srcx->js_use('js/jquery/jquery.min.js');
Inline-Javascript einfügen.
$this->eCMS->srcx->js_set( 'your-snippetname', 'jQuery(document).ready(function(){ console.log( "ready!" );})' );
HTML direkt im Dokument-Body einfügen.
$this->eCMS->srcx->html_set( 'your-snippetname', '<div id="my-dialog-container"> ... </div>' );
Versenden einer E-Mail über einen E-Mail-Channel.
$this->eCS->email_send( 'email_channel' => '<emailchannel-emc_label', 'to' => 'max-mustermanne@beispiel.de', 'from' => 'info@example.com', 'subject' => 'E-Mail Betreff', 'body_text' => 'E-Mail Plain Text Content', 'body_html' => 'E-Mail HTML Content', ) );
E-Mail-Inhalt über Seite in Shop-Frontend erzeugen.
Daten-Übergabe in eApplication Models (ORM). SQL Injection safe!
Filter-Übergabe in eApplication Models (ORM). SQL Injection safe!
Parameter für Plain SQL Verwendung gegen SQL Injection absichern.
$text = $this->eCS->DB->escapeString('Max Mustermann');
Plain SQL Select-Statements auf der Datenbank durchführen.
$r = $this->eCS->DB->query('SELECT * FROM mein_model_abc WHERE abc_owner="'.$this->eCS->DB->escapeString($owner).'"'); if ($r!==false){ // Query OK while ($rec = $this->eCS->DB->getRowArray($r)){ // process Record } } else { // ERROR }
Erzeugen von i18n Messages.
$R['msg'][] = $this->eCS->msg_error_i18n('<message-i18n-string>'); $R['msg'][] = $this->eCS->msg_warning_i18n('<message-i18n-string>'); $R['msg'][] = $this->eCS->msg_info_i18n('<message-i18n-string>'); $R['msg'][] = $this->eCS->msg_ok_i18n('<message-i18n-string>');
Schreiben von i18n Log-Einträgen.
$this->eCS->log_error_i18n('<log-i18n-string>'); $this->eCS->log_warning_i18n('<log-i18n-string>'); $this->eCS->log_info_i18n('<log-i18n-string>'); $this->eCS->log_ok_i18n('<log-i18n-string>');
Schreiben von Plain-Text Log-Einträgen
$this->eCS->log_error('<log-plain-text>'); $this->eCS->log_warning('<log-plain-text>'); $this->eCS->log_info('<log-plain-text>'); $this->eCS->log_ok('<log-plain-text>');