Skip to content

Commit

Permalink
add dataobjects links.ini export
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/Gtk_MDB_Designer/trunk@121546 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
roojs committed Mar 29, 2003
1 parent 5d0790e commit 56228bd
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 4 deletions.
15 changes: 15 additions & 0 deletions Designer.php
Expand Up @@ -114,6 +114,8 @@ function loadInterface() {
array('menu_new', 'activate','showNewDialog'),
array('menu_open', 'activate','showFileDialog'),
array('menu_save', 'activate','callbackSave'),
array('menu_links_ini_write', 'activate','callbackWriteLinksIni'),

array('menu_quit', 'activate','callbackShutdown'),
//array('menu_export', 'activate','callbackSaveSQL'),
array('menu_zoomOut', 'activate','callbackShrink'),
Expand Down Expand Up @@ -417,6 +419,19 @@ function callbackShutdown()
gtk::main_quit();
exit;
}
/**
* call back for writing a dataobjects links.ini config file.
*
* @access public
*/

function callbackWriteLinksIni()
{
$this->database->saveLinksIni();
}



/* these could probably be removed by connect_object('...',$this->glade->get_widget('dialog_new'),'hide') */

function hideNewDialog()
Expand Down
45 changes: 45 additions & 0 deletions Designer/Database.php
Expand Up @@ -200,8 +200,53 @@ function saveSQL($dbtype) {
fclose($fh);

$this->dirty = false;
}
/**
* relay to links to write the links.ini file.
*
* @return string - the links.ini file contents.
* @access public
*/



function toLinksIni() {
$ret = '';

foreach($this->tables as $k=>$v) {
$ret .= "\n\n[{$v->name}]\n";
foreach($this->links as $kk=>$vv) {
$ret .= $vv->toLinksIni($v->name);
}
}

return $ret;
}

/**
* save to links.ini
*
* @access public
*/


function saveLinksIni() {
$this->save(''); // save it first and get a filename?

if (!$this->file) {
return;
}

$data = $this->toLinksIni();

// ?? check?
//echo dirname(realpath($this->file)).'/'.$this->name.'.links.ini' . "\n";
$fh = fopen(dirname(realpath($this->file)).'/'.$this->name.'.links.ini','w');
fwrite($fh,$data);
fclose($fh);


}



Expand Down
193 changes: 189 additions & 4 deletions Designer/Designer.glade
Expand Up @@ -423,6 +423,36 @@
<right_justify>False</right_justify>
</widget>

<widget>
<class>GtkMenuItem</class>
<name>menu_links_ini_write</name>
<signal>
<name>activate</name>
<handler>on_menu_links_ini_write_activate</handler>
<last_modification_time>Sat, 29 Mar 2003 13:59:45 GMT</last_modification_time>
</signal>
<label>Write Dataobjects links.ini</label>
<right_justify>False</right_justify>
</widget>

<widget>
<class>GtkMenuItem</class>
<name>menu_dataobjects_generate</name>
<signal>
<name>activate</name>
<handler>on_menu_dataobjects_generate_activate</handler>
<last_modification_time>Sat, 29 Mar 2003 14:00:24 GMT</last_modification_time>
</signal>
<label>Full DataObjects Generation</label>
<right_justify>False</right_justify>
</widget>

<widget>
<class>GtkMenuItem</class>
<name>separator8</name>
<right_justify>False</right_justify>
</widget>

<widget>
<class>GtkMenuItem</class>
<name>menu_quit</name>
Expand Down Expand Up @@ -546,14 +576,97 @@
</child>
</widget>

<widget>
<class>GtkCombo</class>
<name>database_type</name>
<width>50</width>
<value_in_list>True</value_in_list>
<ok_if_empty>True</ok_if_empty>
<case_sensitive>False</case_sensitive>
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items>mysql
psql
fb
oci8
</items>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>

<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>databaseType</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text>psql</text>
</widget>
</widget>

<widget>
<class>GtkLabel</class>
<name>label4</name>
<label>://</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>

<widget>
<class>GtkEntry</class>
<name>databaseName</name>
<name>databaseUsername</name>
<width>60</width>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<text>username</text>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>

<widget>
<class>GtkLabel</class>
<name>label5</name>
<label>:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>

<widget>
<class>GtkEntry</class>
<name>databasePassword</name>
<width>60</width>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>False</text_visible>
<text_max_length>0</text_max_length>
<text>password</text>
<child>
<padding>0</padding>
<expand>True</expand>
Expand All @@ -562,11 +675,83 @@
</widget>

<widget>
<class>Placeholder</class>
<class>GtkLabel</class>
<name>label3</name>
<label>@</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>

<widget>
<class>Placeholder</class>
<class>GtkEntry</class>
<name>databaseHhost</name>
<width>60</width>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text>localhost</text>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>

<widget>
<class>GtkLabel</class>
<name>label6</name>
<label>/</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>

<widget>
<class>GtkEntry</class>
<name>databaseName</name>
<width>60</width>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>

<widget>
<class>GtkToggleButton</class>
<name>databaseConnected</name>
<can_focus>True</can_focus>
<label>Connect</label>
<relief>GTK_RELIEF_NORMAL</relief>
<active>False</active>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>

Expand Down
14 changes: 14 additions & 0 deletions Designer/Interface/Link.php
Expand Up @@ -224,6 +224,20 @@ function toXml($array=array()) {
$ret .= " </link>\n";
return $ret;
}
/**
* output links.ini
*
* @param name of table = only output matching from links
* @return string the ini data
*/
function toLinksIni($tableName) {
if ($this->from->table->name != $tableName) {
return;
}

return "{$this->from->name} = {$this->to->table->name}:{$this->to->name}\n";
}




Expand Down

0 comments on commit 56228bd

Please sign in to comment.