Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / plugins / import / README
blob76d2b07ccb958a8a75fe0d66f0212ec0f7140594
1 This directory holds import plugins for phpMyAdmin. Any new plugin should
2 basically follow the structure presented here. Official plugins need to
3 have str* messages with their definition in language files, but if you build
4 some plugins for your use, you can directly use texts in plugin.
6 <?php
7 /* vim: set expandtab sw=4 ts=4 sts=4: */
8 /**
9  * [Name] import plugin for phpMyAdmin
10  *
11  * @package    PhpMyAdmin-Import
12  * @subpackage [Name]
13  */
14 if (! defined('PHPMYADMIN')) {
15     exit;
18 /* Get the import interface */
19 require_once 'libraries/plugins/ImportPlugin.class.php';
21 /**
22  * Handles the import for the [Name] format
23  *
24  * @package PhpMyAdmin-Import
25  */
26 class Import[Name] extends ImportPlugin
28     /**
29      * optional - declare variables and descriptions
30      *
31      * @var type
32      */
33     private $_myOptionalVariable;
35     /**
36      * Constructor
37      */
38     public function __construct()
39     {
40         $this->setProperties();
41     }
43     /**
44      * Sets the import plugin properties.
45      * Called in the constructor.
46      *
47      * @return void
48      */
49     protected function setProperties()
50     {
51         // set properties
52         $props = 'libraries/properties/';
53         // include the main class for properties for the import plug-ins
54         include_once "$props/plugins/ImportPluginProperties.class.php";
55         // include the group properties classes
56         include_once "$props/options/groups/OptionsPropertyRootGroup.class.php";
57         include_once "$props/options/groups/OptionsPropertyMainGroup.class.php";
58         // include the needed single property items
59         include_once "$props/options/items/RadioPropertyItem.class.php";
61         $importPluginProperties = new ImportPluginProperties();
62         $importPluginProperties->setText('[name]');             // the name of your plug-in
63         $importPluginProperties->setExtension('[ext]');         // extension this plug-in can handle
64         $importPluginProperties->setOptionsText(__('Options'));
66         // create the root group that will be the options field for
67         // $importPluginProperties
68         // this will be shown as "Format specific options"
69         $importSpecificOptions = new OptionsPropertyRootGroup();
70         $importSpecificOptions->setName("Format Specific Options");
72         // general options main group
73         $generalOptions = new OptionsPropertyMainGroup();
74         $generalOptions->setName("general_opts");
76         // optional :
77         // create primary items and add them to the group
78         // type - one of the classes listed in libraries/properties/options/items/
79         // name - form element name
80         // text - description in GUI
81         // size - size of text element
82         // len  - maximal size of input
83         // values - possible values of the item
84         $leaf = new RadioPropertyItem();
85         $leaf->setName("structure_or_data");
86         $leaf->setValues(
87             array(
88                 'structure' => __('structure'),
89                 'data' => __('data'),
90                 'structure_and_data' => __('structure and data')
91             )
92         );
93         $generalOptions->addProperty($leaf);
95         // add the main group to the root group
96         $importSpecificOptions->addProperty($generalOptions);
98         // set the options for the import plugin property item
99         $importPluginProperties->setOptions($importSpecificOptions);
100         $this->properties = $importPluginProperties;
101     }
103     /**
104      * This method is called when any PluginManager to which the observer
105      * is attached calls PluginManager::notify()
106      *
107      * @param SplSubject $subject The PluginManager notifying the observer
108      *                            of an update.
109      *
110      * @return void
111      */
112     public function update (SplSubject $subject)
113     {
114     }
116     /**
117      * Handles the whole import logic
118      *
119      * @return void
120      */
121     public function doImport()
122     {
123         // get globals (others are optional)
124         global $error, $timeout_passed, $finished;
126         $buffer = '';
127         while (! ($finished && $i >= $len) && ! $error && ! $timeout_passed) {
128             $data = PMA_importGetNextChunk();
129             if ($data === false) {
130                 // subtract data we didn't handle yet and stop processing
131                 $offset -= strlen($buffer);
132                 break;
133             } elseif ($data === true) {
134                 // Handle rest of buffer
135             } else {
136                 // Append new data to buffer
137                 $buffer .= $data;
138             }
139             // PARSE $buffer here, post sql queries using:
140             PMA_importRunQuery($sql, $verbose_sql_with_comments);
141         } // End of import loop
142         // Commit any possible data in buffers
143         PMA_importRunQuery();
144     }
147     // optional:
148     /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
151     /**
152      * Getter description
153      *
154      * @return type
155      */
156     private function _getMyOptionalVariable()
157     {
158         return $this->_myOptionalVariable;
159     }
161     /**
162      * Setter description
163      *
164      * @param type $my_optional_variable description
165      *
166      * @return void
167      */
168     private function _setMyOptionalVariable($my_optional_variable)
169     {
170         $this->_myOptionalVariable = $my_optional_variable;
171     }