Benutzer-Werkzeuge

Webseiten-Werkzeuge


Seitenleiste

3D

INTERN

ADOBE

ARDUINO

BITBUCKET

DOCKER

C4D

GIT

HTML

IPHONE

JAVASCRIPT

JTL-SHOP

LARAVEL

MAGENTO2

MYSQL

PHP

PLESK

PROCESSING

PYTHON

SUITECRM

SEO

TRYTON

THUNDERBIRD / ICEDOVE / FossaMail

TYPO3

TYPO3: BACKEND

TYPO3: TYPOSCRIPT

UNIX

VLC

VVVV

WINDOWS

WINDOWS 10

WORDPRESS

XAMPP

XT:C 4 (Veyton)

veyton:ein-plugin-schreiben

xt:commerce Veyton: Ein Plugin schreiben

Admin Optionen

Admin Class (bare) [tested in xt:commerce 4.20]

file: plugins/degl_new_plugin/classes/degl_new_plugin.php

<?php
defined( '_VALID_CALL' ) OR die( 'Direct Access is not allowed.' );
require_once _SRV_WEBROOT . _SRV_WEB_PLUGINS . 'degl_new_plugin/classes/constants.php';
 
class degl_new_plugin {
 
	protected $_table = TABLE_DEGL_NEW_PLUGIN;
	protected $_table_lang = NULL;
	protected $_table_seo = NULL;
	protected $_master_key = 'id';
	protected $data = array();
	protected $position;
 
	function setPosition( $position ) {
		$this->position = $position;
	}
 
 
	/*
	 * _getParams is for displaying options in the backend
	 * one can define options like textfield, dropdown etc and the display status for every item
	 * furthermore one can define the usage and display of 'NEW', 'EDIT', 'STATUS', 'SEARCH'
	 *
	 * one can look at xtFramework/classes/class.email-manager.php
	 */
	function _getParams() {
 
		global $xtPlugin;
 
		$params = array();
 
		$header = array(
			'id'          => array( 'type' => 'hidden' ),
			'description' => array( 'type' => 'text' )
 
		);
 
		$params['header']         = $header;
		$params['master_key']     = $this->_master_key;
		$params['default_sort']   = $this->_master_key;
		$params['display_newBtn'] = TRUE;
 
		return $params;
	}
 
	/*
	 * _get function reads data
	 * it is responsible to retrieve data in admin list view and as in
	 * admin detail view (edit function)
	 *
	 * the function gets called by clicking the menu item (of the plugin) in the backend
	 */
	function _get( $id = 0 ) {
		global $xtPlugin, $db, $language;
 
		$obj = new stdClass;
 
		if ( $this->position != 'admin' ) {
			return FALSE;
		}
 
 
		if ( 'new' === $id ) {
			$obj = $this->_set( array(), 'new' );
			$id  = $obj->new_id;
		}
 
		$where = "";
		if ( ! $id && ! isset( $this->sql_limit ) ) {
			$this->sql_limit = "0.25";
		}
 
		$table_data = new adminDB_DataRead(
			$this->_table,
			$this->_table_lang,
			$this->_table_seo,
			$this->_master_key,
			$where,
			$this->sql_limit
		);
 
		/*
		 * populate the admin list
		 */
		if ( $this->url_data['get_data'] ) {
			$data = $table_data->getData();
		} elseif ( $id ) {
			$data = $table_data->getData( $id );
		} else {
			// if there is no data get the db header
			$data = $table_data->getHeader();
		}
 
		$obj->data = $data;
 
		return $obj;
 
	}
 
	/*
	 * _set gets called when a dataset is being saved
	 * the whole backend form will be passed as $data array
	 */
	function _set( $data, $set_type = 'edit' ) {
		global $db, $xtPlugin;
 
		$obj = new StdClass;
		$o   = new adminDB_DataSave( $this->_table, $data, FALSE, __CLASS__ );
 
		$obj = $o->saveDataSet();
 
		return $obj;
 
	}
 
	// delete data
	function _unset( $id = 0 ) {
		global $db;
 
		if ( 0 === $id ) {
			return FALSE;
		}
 
		if ( 'admin' != $this->position ) {
			return FALSE;
		}
 
		$id = (int) $id;
		if ( ! is_int( $id ) ) {
			return FALSE;
		}
 
		$db->Execute( "DELETE FROM " . $this->_table . " WHERE " . $this->_master_key . " = '" . $id . "'" );
	}
}

Ins Template rein

veyton/ein-plugin-schreiben.txt · Zuletzt geändert: 2016/09/05 20:14 von admin