Developer Guide Basic

Schnellübersicht für Entwickler.

Anleitung

Im folgenden gibt es eine Kurzübersicht zu Varibalen, Object-Pointern und den wichtigen Methoden für Developer.

 

Konstanten

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/"

 

Variablen & Object-Pointer

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', ...)

 

Ausgaben

Datenbank-Inhalte und Benutzereingaben encoden (XSS).

  1. $src = 'Sie suchten nach: '.$this->eCMS->xPage->output_encode($this->eCMS->_ENV['GET']['search']);

i18n Textbausteine in Benutzer-Sprache übersetzen.

  1. $string = $this->eCMS->language->text_translate_quick('<i18n-content-string>');

i18n Textbausteine in Benutzer-Sprache übersetzen und Platzhalter "%...%" mit Daten füllen.

  1. $array = $this->eCMS->language->text_translate(array('string' => '<i18n-content-string>', array('search' => $this->eCMS->_ENV['GET']['search']);

Datenbank Date und Datetime in Benutzer Format ausgeben.

  1. $string = $this->eCMS->ecms_plugin_locale->format_date('2016-05-15 17:45:15');
  2. $string = $this->eCMS->ecms_plugin_locale->format_date_smart('2016-05-15 17:45:15');
  3. $string = $this->eCMS->ecms_plugin_locale->format_dateTime('2016-05-15 17:45:15');
  4. $string = $this->eCMS->ecms_plugin_locale->format_dateTime_smart('2016-05-15 17:45:15');

Ausgabe von Float und Integer in Benutzer Format.

  1. $string = $this->eCMS->ecms_plugin_locale->format_float(29.49);
  2. $string = $this->eCMS->ecms_plugin_locale->format_float(45000.1015, array('precision'=>2, 'dec_point_only'=>true));
  3. $string = $this->eCMS->ecms_plugin_locale->format_float(29.00, array('trunc_zero'=>true));
  4. $string = $this->eCMS->ecms_plugin_locale->format_integer(15000);

 

Site URL

URL für eCMS Seite erzeugen.

  1. $this->eCMS->xPage->page_getURL('<page-p_label>');

URL auf eCMS Seite mit GET-Parametern erzeugen.

  1. $this->eCMS->xPage->page_getURL('<page-p_label>', array('pagevars' => array('var1'=> 'val1', ...)));

URL auf Shop-Produkt-Detailseite.

  1. $this->eCMS->plugin_ecs->ecs_product->product_getURL(array('filter'=>array('xc__label' => 'product-pcode')));

URL auf Shop-Kategorie-Detailseite

  1. $this->eCMS->plugin_ecs->ecs_product->productGroup_getURL(array('filter'=>array('node_code' => 'category-node_code')));

URL auf Detailseite für andere eCMS Contenttypes (z.B. Blog, FAQ, etc.).

  1. $this->eCMS->ecms_cdb->record->record_getURL(array('xc__label' => 'record-xc__label', 'contenttype' => 'record-ct_label'));

URL Weiterleitung (302) ausführen.

  1. $this->eCMS->xPage->page_redirect('http://www.example.com/goto');

Permanente Weiterleitung (301) ausführen.

  1. $this->eCMS->xPage->page_redirect('http://www.example.com/goto', array('movePerma'=>true));

 

Session

Abfrage der User-Session-Daten.

  1. $array = $this->eCMS->session->data_get('UserData');

Abfrage der Shop-Session-Daten

  1. $array = $this->eCMS->session->data_get('eComSuite');

Custom-Session-Daten speichern und abfragen.

  1. $this->eCMS->session->data_set('<your-name>', array('variable'=>'value', ...));
  2. $data = $this->eCMS->session->data_get('<your-name>');

 

Images

URL für Medibase Image erzeugen

  1. $file = $this->eCMS->ecms_mb->mbContent_relocateFile(array('mb_label'=>'your-mediabase-image', 'resize_width'=>500, 'resize_height'=>250));
  2. $img = '<img src="'.$file['data']['target_url'].'" />';

URL zu allen Produkt-Images erzeugen.

  1. $files = $this->eCMS->ecms_mb->mbContent_relocateMBString(array('mb_string'=>$product['files_img'], 'resize_width'=>150, 'resize_height'=>150));
  2.  
  3. foreach($files['data'] as $file){
  4.     $img .= '<img src="'.$file['target_url'].'" />';
  5. }

 

CSS & Javascript

CSS-Datei On-Demand einbinden. Relativer Pfad ab "www/files/lib_res".

  1. $this->eCMS->srcx->css_use('css/ecms_lib_base.css');

Javascript-Datei On-Demand einbinden. Relativer Pfad ab "www/files/lib_res".

  1. $this->eCMS->srcx->js_use('js/jquery/jquery.min.js');

Inline-Javascript einfügen.

  1. $this->eCMS->srcx->js_set(
  2.   'your-snippetname',
  3.   'jQuery(document).ready(function(){ console.log( "ready!" );})'
  4. );

HTML direkt im Dokument-Body einfügen.

  1. $this->eCMS->srcx->html_set(
  2.   'your-snippetname',
  3.   '<div id="my-dialog-container"> ... </div>'
  4. );

 

E-Mail

Versenden einer E-Mail über einen E-Mail-Channel.

  1. $this->eCS->email_send(
  2.     array(
  3.         'email_channel' => '<emailchannel-emc_label',
  4.         'to' => 'max-mustermanne@beispiel.de',
  5.         'from' => 'info@example.com',
  6.         'subject' => 'E-Mail Betreff',
  7.         'body_text' => 'E-Mail Plain Text Content',
  8.         'body_html' => 'E-Mail HTML Content',
  9.     )
  10. );

E-Mail-Inhalt über Seite in Shop-Frontend erzeugen.

  1. $pc = $this->eCS->ecs_shopfrontend->xPage->page_renderSubprocess(
  2.     array(
  3.         'p_label' => 'page-p_label',
  4.         'get' => array('page-get-var1' => 123, ... ),
  5.     )    
  6. );
  7.  
  8. $this->eCS->email_send(
  9.     array(
  10.         'body_html' => $pc['data']['src'],
  11.         ...
  12.     )
  13. );

 

Datenbank

Daten-Übergabe in eApplication Models (ORM). SQL Injection safe!

  1. $this->eCS->ecs_person->person_create(
  2.     array(
  3.         'fields' => array(
  4.             'gender' => 'male',
  5.             'firstname' => 'Max',
  6.             'lastname' => 'Mustermann',
  7.             ...    
  8.         )        
  9.     )    
  10. );

Filter-Übergabe in eApplication Models (ORM). SQL Injection safe!

  1. $this->eCS->ecs_person->person_get(
  2.     array(
  3.         'filter' => array('firstname' => 'Max'),
  4.         )        
  5.     )    
  6. );

Parameter für Plain SQL Verwendung gegen SQL Injection absichern.

  1. $text = $this->eCS->DB->escapeString('Max Mustermann');

Plain SQL Select-Statements auf der Datenbank durchführen.

  1. $r = $this->eCS->DB->query('SELECT * FROM mein_model_abc WHERE abc_owner="'.$this->eCS->DB->escapeString($owner).'"');
  2.  
  3. if ($r!==false){
  4.     // Query OK
  5.     while ($rec = $this->eCS->DB->getRowArray($r)){
  6.         // process Record
  7.     }
  8.  
  9. } else {
  10.     // ERROR
  11. }

 

Message & Logging

Erzeugen von i18n Messages.

  1. $R['msg'][] = $this->eCS->msg_error_i18n('<message-i18n-string>');
  2. $R['msg'][] = $this->eCS->msg_warning_i18n('<message-i18n-string>');
  3. $R['msg'][] = $this->eCS->msg_info_i18n('<message-i18n-string>');
  4. $R['msg'][] = $this->eCS->msg_ok_i18n('<message-i18n-string>');

Schreiben von i18n Log-Einträgen.

  1. $this->eCS->log_error_i18n('<log-i18n-string>');
  2. $this->eCS->log_warning_i18n('<log-i18n-string>');
  3. $this->eCS->log_info_i18n('<log-i18n-string>');
  4. $this->eCS->log_ok_i18n('<log-i18n-string>');

Schreiben von Plain-Text Log-Einträgen

  1. $this->eCS->log_error('<log-plain-text>');
  2. $this->eCS->log_warning('<log-plain-text>');
  3. $this->eCS->log_info('<log-plain-text>');
  4. $this->eCS->log_ok('<log-plain-text>');