DOCUMENTAÇÃO FABULA FRAMEWORK Site: http://fabula.scorninpc.com Forum: http://fabula.scorninpc.com/forum Documentação Online: http://fabula.scorninpc.com/documentacao Download Fabula Framework: http://fabula.scorninpc.com/download/viewcategory/3 Copyright 2010 Bruno Pitteli Gonçalves. All Rights Reserved Banco de Dados MySQL Cria a conexão com o banco de dados resource Fabula::MySQL( $server, $username, $password, $database, $logfile = NULL $server $username $password $database $logfile String Endereço do servidor MySQL String Usuário do servidor MySQL String Senha do usuário do servidor MySQL String Base de dados à selecionar MySQL String Caminho+nome do arquivo de log de bad queryes $objdb = Fabula::MySQL("localhost", "root", "", "meusistema" echo $objdb->getone("select email FROM colaboradores LIMIT 5, 1" SQLite Cria a conexão com o banco de dados SQLite resource Fabula::SQLite( $file, $logfile = NULL
$file String Caminho para o arquivo do banco de dados $logfile String Caminho+nome do arquivo de log de bad queryes $objdb = Fabula::SQLite("database.sqlite", "sqlite.log" echo $objdb->getone("select nome FROM usuarios LIMIT 1" AutoExecute Executa insert e update no banco de dados Requisitos: MySQL, SQLite bool DataBase->AutoExecute( $table, $record, $method, $where = NULL $table String Tabela que se aplica a mudança $record Array Vetor com as informações a serem inseridas ou atualizadas $method String Modo [insert, update] $where String Condição que se aplica o metodo update $objdb = Fabula::MySQL("localhost", "root", "", "meusistema" $info['nome'] = "Meu usuario"; $info['email'] = "meuusuario @ meuemail.com"; $result = $objdb->autoexecute("colaboradores", $info, "insert" unset($info $info['nome'] = "Outro nome"; $result = $objdb->autoexecute("colaboradores", $info, "update", "email = 'meuusuario @ meuemail.com'" Execute Executa uma query no banco de dados Requisitos:
MySQL, SQLite resource DataBase->Execute( $sql $sql String Query à ser executada $objdb = Fabula::MySQL("localhost", "root", "", "meusistema" $result = $objdb->execute("select nome, email FROM colaboradores" while($result->eof) echo $result->fields["nome"]. "\t\t". $result->fields[1]. "\n"; $result->movenext( GetOne Busca o valor da primeira coluna, primeira linha de uma query Requisitos: MySQL, SQLite string DataBase->GetOne( $sql $sql String Query à executar $objdb = Fabula::MySQL("localhost", "root", "", "meusistema" echo $objdb->getone("select Count(*) FROM colaboradores" InsertID Busca o ultimo valor inserido em uma chave primaria Requisitos: MySQL, SQLite
int DataBase->InsertID( $objdb = Fabula::MySQL("localhost", "root", "", "meusistema" MultipleExecute $info['nome'] = "Meu usuario"; $info['email'] = "meuusuario @ meuemail.com"; $return = $objdb->autoexecute("colaboradores", $infos, "insert" echo $objdb->insertid( Executa varias queries no banco de dados Requisitos: MySQL, SQLite bool DataBase->MultipleExecute( $sql $sql String Queries à serem executadas, separadas por ; e/ou \n $objdb = Fabula::MySQL("localhost", "root", "", "meusistema" $sql = file_get_contents("arquivo.sql" $result = $objdb->multipleexecute($sql DIALOGS Alert Mostra alertas void Fabula::Alert( $strmessage, $strtitle, $stockimage = Gtk::STOCK_DIALOG_WARNING $strmessage String Mensagem do box $strtitle String Titulo do box $stockimage Contant Opcional Constante GTK da imagem do box
Fabula::Alert( "Não foi possivel encontrar o arquivo!", "Erro!", Gtk::STOCK_DIALOG_ERROR ChooseFile Cria dialogos para seleção de diretório ou arquivos string Fabula::ChooseFile( $splashscreen, $filters = NULL, $type = Gtk::FILE_CHOOSER_ACTION_OPEN $strtitle String Titulo do box $filters Array Conteúdo do filtro $type GtkFileChooser Tipo do box $folder = Fabula::ChooseFile("Selecione um diretório", NULL, Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER $file = Fabula::ChooseFile("Selecione uma imagem", array("*.jpg", "*.bmp") MsgBox Mostra e obtem retorno de alertas int constant Fabula::MsgBox( $strmessage, $strtitle, $buttons = array(gtk::stock_ok, Gtk::RESPONSE_OK), $stockimage = Gtk::STOCK_DIALOG_WARNING $strmessage String Mensagem do box $strtitle String Titulo do box $buttons Array Opcional Botões do box $stockimage Contant Opcional Constante GTK da imagem do box $res = Fabula::MsgBox( "Deseja remover o aquivo?", "Confirmação!",
array(gtk::stock_yes, Gtk::RESPONSE_YES, Gtk::STOCK_NO, Gtk::RESPONSE_NO),Gtk::STOCK_DIALOG_QUEST if($res == Gtk::RESPONSE_YES) unlink($file splashcreate Cria diálogos de splash GtkWindow Fabula::splashCreate( $imagepath $imagepath String Caminho para a imagem do splash $splash = Fabula::splashCreate("images/splash.png" for($i=0; $i<=9999999; $i++) // TESTE PARA O SPLASH PERMANECER EM TELA while(gtk::events_pending()) gtk::main_iteration( Fabula::splashHide($splash splashhide Esconde diálogos de splash http://fabula.scorninpc.com/administrator/index.php?option=com_content# void Fabula::splashHide( $splashscreen $splashscreen GtkWindow SplashScreen criado com splashcreate() $splash = Fabula::splashCreate("images/splash.png" for($i=0; $i<=9999999; $i++) // TESTE PARA O SPLASH PERMANECER EM TELA while(gtk::events_pending()) gtk::main_iteration( Fabula::splashHide($splash
MENUS menuloadxml Cria menus a partir de um XML void Fabula::menuLoadXML( $file, $mainobject = NULL $file String Caminho do arquivo XML $mainobject Object Opcional Objeto onde esta os métodos do XML <?xml version="1.0" encoding="iso-8859-1"?> <menubar name="mnubar"> <menu name="file" title="arquivo"> <menuitem name="mnuopen" title="abrir" onclick="mnuopen_onclick" /> <menuitem name="mnuexit" title="sair" onclick="mnuexit_onclick" /> </menu> </menubar> require_once("trunk/fabula.class.php" // Classe de testes class Teste // Armazena os widgets da classe public $widgets = array( // Construtor public function construct() // Cria a janela $this->widgets['frmmain'] = new GtkWindow( $this->widgets['frmmain']->set_size_request(200, 200 $this->widgets['frmmain']->add($vbox = new GtkVBox()
"frmmain_unload") $this->widgets['frmmain']->connect_simple("destroy", array($this, // Cria o menu $this->widgets['mnubar'] = Fabula::menuLoadXML("mainmenu.xml", $this $vbox->pack_start($this->widgets['mnubar']['object'], FALSE, FALSE // Adiciona qualquer coisa na segunda parte $vbox->pack_start(new GtkFixed(), TRUE, TRUE $this->widgets['frmmain']->show_all( Gtk::main( // Encerra a aplicação public function frmmain_unload() Gtk::main_quit( exit(0 // Menu mnuopen public function mnuopen_onclick() echo Fabula::ChooseFile("Abrir" // Menu mnuexit public function mnuexit_onclick() $this->frmmain_unload( new Teste(
METODOS loadxmlconfig Carrega configurações de um XML void Fabula::loadXMLConfig( $file $file String Caminho do arquivo XML <?xml version="1.0" encoding="iso-8859-1"?> <config> <session name="database"> <option name="host" value="192.168.1.1" /> <option name="username" value="root" /> <option name="password" value="" /> <option name="name" value="mydb" /> </session> <session name="containers"> <option name="debug" value="false" /> <option name="console" value="false" /> <option name="explorer" value="true" /> </session> </config> require_once("/home/scorninpc/projetos/projetos/fabula/trunk/fabula.class.php" // Carrega as configurações $config = Fabula::loadXMLConfig("config.xml" // Classe de testes class Teste public function construct()
// Mostra var_dump($globals['config'] new Teste( TREEVIEW treeviewhighlight Cria o efeito zebrado em treeviews void Fabula::treeviewHighLight( $widget, $colora, $colorb $widget GtkTreeView GtkTreeview à aplicar o efeito zebrado $colora Cor HEX Cor em hexadecimal da primeira linha $colorb Cor HEX Cor em hexadecimal da segunda linha $model = new GtkListStore(GObject::TYPE_STRING $trvpartners = new GtkTreeView($model $render = new GtkCellRendererText( $column = new GtkTreeViewColumn("Cód.", $render, "text", 0 $trvpartners->append_column($column Fabula::treeviewHighLight($trvPartners, "#EDEDED", "#FFFFFF" $model->append(array('teste') $model->append(array('teste') $model->append(array('teste') $model->append(array('teste')
WIDGETS DeskAlert Mostra alertas no estilo MSN int constant Fabula::DeskAlert( Métodos e propriedades: set_size_request($width, $height) Método Seta o tamanho do dialog show() Método Mostra o dialog hide() Método Esconde o dialog initial Propriedade Seta a altura inicial do dialog $alert = Fabula::DeskAlert( $alert->set_size_request(300, 100 $alert->show( GtkLabel Cria um GtkLabel, alinhado à esquerda void Fabula::GtkLabel( $text $file String Texto do label require_once("trunk/fabula.class.php" // Classe de testes class Teste
// Armazena os widgets da classe public $widgets = array( "frmmain_unload") // Construtor public function construct() // Cria a janela $this->widgets['frmmain'] = new GtkWindow( $this->widgets['frmmain']->set_size_request(200, 200 $this->widgets['frmmain']->add($vbox = new GtkVBox() $this->widgets['frmmain']->connect_simple("destroy", array($this, // Adiciona um fixed $vbox->pack_start($fix = new GtkFixed(), TRUE, TRUE // Cria o label $this->widgets['lbltest'] = Fabula::GtkLabel("ok" $fix->put($this->widgets['lbltest'], 8, 8 // Mostra a janela $this->widgets['frmmain']->show_all( Gtk::main( // Encerra a aplicação public function frmmain_unload() Gtk::main_quit( exit(0 new Teste( minimizablepanel Cria paineis minimizáveis int constant Fabula::minimizablePanel( Métodos e propriedades: set_tab_pos($pos) Método Seta a posição das abas insert($widget, $label) Método Insere uma aba ao painel $hbox = new GtkHBox( $hbox->pack_start($panel1 = Fabula::minimizablePanel(), FALSE, FALSE $hbox->pack_start(new GtkTextView(), TRUE, TRUE $hbox->pack_start($panel2 = Fabula::minimizablePanel(), FALSE, FALSE $panel1->set_tab_pos(gtk::pos_left
$panel2->set_tab_pos(gtk::pos_right newbuttonfromimage ** Método temporário ** Cria um GtkButton, com imagem a partir de um arquivo void Fabula::newButtonFromImage( $image, $label = NULL $image String Caminho para o arquivo de imagem $label String Opcional Texto para o botão require_once("trunk/fabula.class.php" // Classe de testes class Teste // Armazena os widgets da classe public $widgets = array( // Construtor public function construct() // Cria a janela $this->widgets['frmmain'] = new GtkWindow( $this->widgets['frmmain']->set_size_request(200, 200 $this->widgets['frmmain']->add($vbox = new GtkVBox() $this->widgets['frmmain']->connect_simple("destroy", array($this, "frmmain_unload") // Adiciona um fixed $vbox->pack_start($fix = new GtkFixed(), TRUE, TRUE "camera" // Cria o botão $this->widgets['btntest'] = Fabula::newButtonFromImage("icons/camera.png", $fix->put($this->widgets['btntest'], 8, 8 // Mostra a janela $this->widgets['frmmain']->show_all( Gtk::main( // Encerra a aplicação public function frmmain_unload()
Gtk::main_quit( exit(0 new Teste(