properties; } /** * Sets the export plugins properties and is implemented by each export * plugin * * @return void */ abstract protected function setProperties(); /** * The following methods are implemented here so that they * can be used by all export plugin without overriding it. * Note: If you are creating a export plugin then don't include * below methods unless you want to override them. */ /** * Initialize aliases * * @param array $aliases Alias information for db/table/column * @param string &$db the database * @param string &$table the table * * @return void */ public function initAlias($aliases, &$db, &$table = null) { if (!empty($aliases[$db]['tables'][$table]['alias'])) { $table = $aliases[$db]['tables'][$table]['alias']; } if (!empty($aliases[$db]['alias'])) { $db = $aliases[$db]['alias']; } } /** * Search for alias of a identifier. * * @param array $aliases Alias information for db/table/column * @param string $id the identifier to be searched * @param string $type db/tbl/col or any combination of them * representing what to be searched * @param string $db the database in which search is to be done * @param string $tbl the table in which search is to be done * * @return string alias of the identifier if found or '' */ public function getAlias($aliases, $id, $type = 'dbtblcol', $db = '', $tbl = '') { if (!empty($db) && isset($aliases[$db])) { $aliases = array( $db => $aliases[$db], ); } // search each database foreach ($aliases as $db_key => $db) { // check if id is database and has alias if (stristr($type, 'db') !== false && $db_key === $id && !empty($db['alias']) ) { return $db['alias']; } if (empty($db['tables'])) { continue; } if (!empty($tbl) && isset($db['tables'][$tbl])) { $db['tables'] = array( $tbl => $db['tables'][$tbl], ); } // search each of its tables foreach ($db['tables'] as $table_key => $table) { // check if id is table and has alias if (stristr($type, 'tbl') !== false && $table_key === $id && !empty($table['alias']) ) { return $table['alias']; } if (empty($table['columns'])) { continue; } // search each of its columns foreach ($table['columns'] as $col_key => $col) { // check if id is column if (stristr($type, 'col') !== false && $col_key === $id && !empty($col) ) { return $col; } } } } return ''; } /** * Gives the relation string and * also substitutes with alias if required * in this format: * [Foreign Table] ([Foreign Field]) * * @param array $res_rel the foreigners array * @param string $field_name the field name * @param string $db the field name * @param array $aliases Alias information for db/table/column * * @return string the Relation string */ public function getRelationString( $res_rel, $field_name, $db, $aliases = array() ) { $relation = ''; $foreigner = PMA_searchColumnInForeigners($res_rel, $field_name); if ($foreigner) { $ftable = $foreigner['foreign_table']; $ffield = $foreigner['foreign_field']; if (!empty($aliases[$db]['tables'][$ftable]['columns'][$ffield])) { $ffield = $aliases[$db]['tables'][$ftable]['columns'][$ffield]; } if (!empty($aliases[$db]['tables'][$ftable]['alias'])) { $ftable = $aliases[$db]['tables'][$ftable]['alias']; } $relation = $ftable . ' (' . $ffield . ')'; } return $relation; } }