phpmyadmin/libraries/plugins/export
Michal Čihař 76f51a1ffb Use tryQuery instead of query to handle errors
We really do not want to end up in mysql_die here as we could have sent
some output already.

Fixes #13600

Signed-off-by: Michal Čihař <michal@cihar.com>
2017-08-21 11:20:42 +02:00
..
ExportCodegen.php Use new contructor for Group() objects 2016-01-05 15:26:52 +01:00
ExportCsv.php Use new contructor for Group() objects 2016-01-05 15:26:52 +01:00
ExportExcel.php Use new contructor for Group() objects 2016-01-05 15:26:52 +01:00
ExportHtmlword.php Use new contructor for Group() objects 2016-01-05 15:26:52 +01:00
ExportJson.php Produce valid JSON on export 2016-06-14 09:16:58 +02:00
ExportLatex.php Use https for links to www.phpmyadmin.net 2016-05-17 10:49:21 +02:00
ExportMediawiki.php Merge branch 'master' into master-security 2016-07-28 09:44:08 +02:00
ExportOds.php Fixed OpenDocument exports 2017-02-20 08:44:03 +01:00
ExportOdt.php Fixed OpenDocument exports 2017-02-20 08:44:03 +01:00
ExportPdf.php The class_exists uses autoloading no need to do it 2016-02-22 08:05:49 +01:00
ExportPhparray.php Use secure.php.net for PHP documentation links 2016-10-18 11:13:24 +02:00
ExportSql.php Use tryQuery instead of query to handle errors 2017-08-21 11:20:42 +02:00
ExportTexytext.php Use new contructor for Group() objects 2016-01-05 15:26:52 +01:00
ExportXml.php Merge branch 'QA_4_6' 2016-11-14 11:07:06 +05:30
ExportYaml.php Use new contructor for Group() objects 2016-01-05 15:26:52 +01:00
PMA_ExportPdf.php Do not use global constant with class 2016-01-22 15:24:48 +01:00
README Use new contructor for Group() objects 2016-01-05 15:26:52 +01:00
TableProperty.php Avoid using mb_strlen for checking whether string is empty 2016-09-16 10:29:21 +02:00

This directory holds export plugins for phpMyAdmin. Any new plugin should
basically follow the structure presented here. Official plugins need to
have str* messages with their definition in language files, but if you build
some plugins for your use, you can directly use texts in plugin.

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * [Name] export plugin for phpMyAdmin
 *
 * @package    PhpMyAdmin-Export
 * @subpackage [Name]
 */
if (! defined('PHPMYADMIN')) {
    exit;
}

/**
 * Handles the export for the [Name] format
 *
 * @package PhpMyAdmin-Export
 */
class Export[Name] extends PMA\libraries\plugins\ExportPlugin
{
    /**
     * optional - declare variables and descriptions
     *
     * @var type
     */
    private $_myOptionalVariable;

    /**
     * optional - declare global variables and descriptions
     *
     * @var type
     */
    private $_globalVariableName;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->setProperties();
    }

    // optional - declare global variables and use getters later
    /**
     * Initialize the local variables that are used specific for export SQL
     *
     * @global type $global_variable_name
     * [..]
     *
     * @return void
     */
    protected function initSpecificVariables()
    {
        global $global_variable_name;
        $this->_setGlobalVariableName($global_variable_name);
    }

    /**
     * Sets the export plugin properties.
     * Called in the constructor.
     *
     * @return void
     */
    protected function setProperties()
    {
        $exportPluginProperties = new PMA\libraries\properties\plugins\ExportPluginProperties();
        $exportPluginProperties->setText('[name]');             // the name of your plug-in
        $exportPluginProperties->setExtension('[ext]');         // extension this plug-in can handle
        $exportPluginProperties->setOptionsText(__('Options'));

        // create the root group that will be the options field for
        // $exportPluginProperties
        // this will be shown as "Format specific options"
        $exportSpecificOptions = new PMA\libraries\properties\options\groups\OptionsPropertyRootGroup(
            "Format Specific Options"
        );

        // general options main group
        $generalOptions = new PMA\libraries\properties\options\groups\OptionsPropertyMainGroup(
            "general_opts"
        );

        // optional :
        // create primary items and add them to the group
        // type - one of the classes listed in libraries/properties/options/items/
        // name - form element name
        // text - description in GUI
        // size - size of text element
        // len  - maximal size of input
        // values - possible values of the item
        $leaf = new PMA\libraries\properties\options\items\RadioPropertyItem(
            "structure_or_data"
        );
        $leaf->setValues(
            array(
                'structure' => __('structure'),
                'data' => __('data'),
                'structure_and_data' => __('structure and data')
            )
        );
        $generalOptions->addProperty($leaf);

        // add the main group to the root group
        $exportSpecificOptions->addProperty($generalOptions);

        // set the options for the export plugin property item
        $exportPluginProperties->setOptions($exportSpecificOptions);
        $this->properties = $exportPluginProperties;
    }

    /**
     * Outputs export header
     *
     * @return bool Whether it succeeded
     */
    public function exportHeader ()
    {
        // implementation
        return true;
    }

    /**
     * Outputs export footer
     *
     * @return bool Whether it succeeded
     */
    public function exportFooter ()
    {
        // implementation
        return true;
    }

    /**
     * Outputs database header
     *
     * @param string $db       Database name
     * @param string $db_alias Aliases of db
     *
     * @return bool Whether it succeeded
     */
    public function exportDBHeader ($db, $db_alias = '')
    {
        // implementation
        return true;
    }

    /**
     * Outputs database footer
     *
     * @param string $db Database name
     *
     * @return bool Whether it succeeded
     */
    public function exportDBFooter ($db)
    {
        // implementation
        return true;
    }

    /**
     * Outputs CREATE DATABASE statement
     *
     * @param string $db       Database name
     * @param string $db_alias Aliases of db
     *
     * @return bool Whether it succeeded
     */
    public function exportDBCreate($db, $db_alias = '')
    {
        // implementation
        return true;
    }

    /**
     * Outputs the content of a table in [Name] format
     *
     * @param string $db        database name
     * @param string $table     table name
     * @param string $crlf      the end of line sequence
     * @param string $error_url the url to go back in case of error
     * @param string $sql_query SQL query for obtaining data
     * @param array  $aliases   Aliases of db/table/columns
     *
     * @return bool Whether it succeeded
     */
    public function exportData(
        $db, $table, $crlf, $error_url, $sql_query, $aliases = array()
    ) {
        // implementation;
        return true;
    }

    // optional - implement other methods defined in PMA\libraries\plugins\ExportPlugin.class.php:
    //  - exportRoutines()
    //  - exportStructure()
    //  - getTableDefStandIn()
    //  - getTriggers()

    // optional - implement other private methods in order to avoid
    // having huge methods or avoid duplicate code. Make use of them
    // as well as of the getters and setters declared both here
    // and in the PMA\libraries\plugins\ExportPlugin class


    // optional:
    /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */


    /**
     * Getter description
     *
     * @return type
     */
    private function _getMyOptionalVariable()
    {
        return $this->_myOptionalVariable;
    }

    /**
     * Setter description
     *
     * @param type $my_optional_variable description
     *
     * @return void
     */
    private function _setMyOptionalVariable($my_optional_variable)
    {
        $this->_myOptionalVariable = $my_optional_variable;
    }

    /**
     * Getter description
     *
     * @return type
     */
    private function _getGlobalVariableName()
    {
        return $this->_globalVariableName;
    }

    /**
     * Setter description
     *
     * @param type $global_variable_name description
     *
     * @return void
     */
    private function _setGlobalVariableName($global_variable_name)
    {
        $this->_globalVariableName = $global_variable_name;
    }
}
?>