"Fossies" - the Fresh Open Source Software Archive

Member "phpMyAdmin-5.0.1-all-languages/libraries/classes/Plugins/Import/AbstractImportCsv.php" (7 Jan 2020, 2929 Bytes) of package /linux/www/phpMyAdmin-5.0.1-all-languages.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "AbstractImportCsv.php": 4.9.2_vs_5.0.0.

    1 <?php
    2 /* vim: set expandtab sw=4 ts=4 sts=4: */
    3 /**
    4  * Super class of CSV import plugins for phpMyAdmin
    5  *
    6  * @package    PhpMyAdmin-Import
    7  * @subpackage CSV
    8  */
    9 declare(strict_types=1);
   10 
   11 namespace PhpMyAdmin\Plugins\Import;
   12 
   13 use PhpMyAdmin\Plugins\ImportPlugin;
   14 use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
   15 use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
   16 use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
   17 use PhpMyAdmin\Properties\Options\Items\TextPropertyItem;
   18 use PhpMyAdmin\Properties\Plugins\ImportPluginProperties;
   19 
   20 /**
   21  * Super class of the import plugins for the CSV format
   22  *
   23  * @package    PhpMyAdmin-Import
   24  * @subpackage CSV
   25  */
   26 abstract class AbstractImportCsv extends ImportPlugin
   27 {
   28     /**
   29      * Sets the import plugin properties.
   30      * Called in the constructor.
   31      *
   32      * @return OptionsPropertyMainGroup|void object of the plugin
   33      */
   34     protected function setProperties()
   35     {
   36         $importPluginProperties = new ImportPluginProperties();
   37         $importPluginProperties->setOptionsText(__('Options'));
   38 
   39         // create the root group that will be the options field for
   40         // $importPluginProperties
   41         // this will be shown as "Format specific options"
   42         $importSpecificOptions = new OptionsPropertyRootGroup(
   43             "Format Specific Options"
   44         );
   45 
   46         // general options main group
   47         $generalOptions = new OptionsPropertyMainGroup("general_opts");
   48 
   49         // create common items and add them to the group
   50         $leaf = new BoolPropertyItem(
   51             "replace",
   52             __(
   53                 'Update data when duplicate keys found on import (add ON DUPLICATE '
   54                 . 'KEY UPDATE)'
   55             )
   56         );
   57         $generalOptions->addProperty($leaf);
   58         $leaf = new TextPropertyItem(
   59             "terminated",
   60             __('Columns separated with:')
   61         );
   62         $leaf->setSize(2);
   63         $generalOptions->addProperty($leaf);
   64         $leaf = new TextPropertyItem(
   65             "enclosed",
   66             __('Columns enclosed with:')
   67         );
   68         $leaf->setSize(2);
   69         $leaf->setLen(2);
   70         $generalOptions->addProperty($leaf);
   71         $leaf = new TextPropertyItem(
   72             "escaped",
   73             __('Columns escaped with:')
   74         );
   75         $leaf->setSize(2);
   76         $leaf->setLen(2);
   77         $generalOptions->addProperty($leaf);
   78         $leaf = new TextPropertyItem(
   79             "new_line",
   80             __('Lines terminated with:')
   81         );
   82         $leaf->setSize(2);
   83         $generalOptions->addProperty($leaf);
   84 
   85         // add the main group to the root group
   86         $importSpecificOptions->addProperty($generalOptions);
   87 
   88         // set the options for the import plugin property item
   89         $importPluginProperties->setOptions($importSpecificOptions);
   90         $this->properties = $importPluginProperties;
   91 
   92         return $generalOptions;
   93     }
   94 }