/** * Retorna um dialeto pelo nome * @author Hugo Ferreira da Silva * @param string $dialectName * @return ILumine_Dialect */ public static function getByName($dialectName) { if (isset(self::$createdItems[$dialectName])) { return self::$createdItems[$dialectName]; } else { Lumine::load('Lumine_Dialect_' . $dialectName); $ref = new ReflectionClass('Lumine_Dialect_' . $dialectName); self::$createdItems[$dialectName] = $ref->newInstance(); } return self::$createdItems[$dialectName]; }
/** * Inicia uma geracao em PDF * * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br/ * @param Lumine_Base $obj * @return Lumine_IReport */ public static function PDF(Lumine_Base $obj) { Lumine::load('Report_PDF'); $obj = new Lumine_Report_PDF($obj, 'PDF'); return $obj; }
<?php /** * Geracao de formularios basicos para Lumine * * @package Lumine_Form * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br */ // carrega a interface Lumine::load('Form_IForm'); /** * Geracao de formularios basicos para Lumine * * @package Lumine_Form * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br */ class Lumine_Form_White extends Lumine_EventListener implements Lumine_Form_IForm { /** * Objeto a ser usado * @var Lumine_Base */ private $obj; /** * flag para saber se eh para remover as contra-barras dos valores * @var boolean */ private $strip_slashes; /**
// vamos indicar quais metodos este plugin usa self::$_plugins[$methodName] = $class; } } /** * Executa um plugin registrado * * @param string $method Nome do metodo * @param Lumine_Base $obj Objeto de escopo para a chamada do plugin * @param array $args Argumentos * @author Hugo Ferreira da silva * @link http://www.hufersil.com.br * @return mixed O retorno do metodo do plugin */ public static function runPlugin($method, Lumine_Base $obj, array $args) { // se nao existir if (!array_key_exists($method, self::$_plugins)) { // retorna false throw new Lumine_Exception('Metodo inexistente: ' . $method, Lumine_Exception::NO_SUCH_METHOD); } // coloca o objeto de lumine na primeira posicao de argumentos array_unshift($args, $obj); // executa o metodo e retorna o mesmo retorno do metodo return call_user_func_array(array(self::$_plugins[$method], $method), $args); } } // carrega principais dependencias Lumine::load('Utils_Util', 'Utils_Crypt', 'Event', 'Events_SQLEvent', 'Events_FormatEvent', 'Events_IteratorEvent'); Lumine::load('Exception', 'SQLException', 'EventListener', 'Tokenizer', 'Parser', 'Exception', 'Configuration', 'ConnectionManager', 'Base', 'Validator', 'Union', 'Factory', 'Model', 'IPlugin');
<?php /** * Classe de conexao com o firebird * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br * @package Lumine_Dialect */ Lumine::load('Dialect_Exception'); Lumine::load('Dialect_IDialect'); /** * Classe de conexao com o firebird * @package Lumine_Dialect * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br */ class Lumine_Dialect_Firebird extends Lumine_EventListener implements Lumine_Dialect_IDialect { /** * Conexao ativa * @var Lumine_Connection_IConnection */ private $connection = null; /** * Resultset atual * @var resource */ private $result_set = null; /** * Objeto que requisitou a "ponte" * @var Lumine_Base
# This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/> ################################################################################ require_once 'C:\\www\\ExtJS\\teste2\\Abstergo\\library\\Lumine/Lumine.php'; require_once 'C:/www/ExtJS/teste2/Abstergo/library/lumine-conf.php'; Lumine::load('Form_White'); $cfg = new Lumine_Configuration($lumineConfig); $cfg->import('Clientes'); register_shutdown_function(array($cfg->getConnection(), 'close')); $obj = new Clientes(); $form = new Lumine_Form_White($obj); if (!empty($_REQUEST['_lumineAction'])) { switch ($_REQUEST['_lumineAction']) { case 'insert': case 'save': $result = $form->handleAction($_REQUEST['_lumineAction'], $_POST); if ($result === true) { header("Location: " . $_SERVER['PHP_SELF'] . '?msg=ok'); exit; } break;
/** * Retorna o ultimo ID da tabela para campos auto-increment * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br/ * @param string $campo Nome do campo da tabela de auto-increment * @return int Valor da ultima insercao */ public function getLastId($campo) { $obj = Lumine::factory($this->getTablename()); $field = $obj->metadata()->getFieldByColumn($campo); $obj->destroy(); // se nao tiver sequence if (empty($field['options']['sequence'])) { // verificacao de existencia de esquema no nome da tabela. // sugestao de Tiago Hiller - 05/10/2011 $tablename = $this->getTablename(); $hasSchema = preg_match('@\\b(?P<schema>\\w+)\\.(?P<tablename>\\w+)\\b@', $this->getTablename(), $res); if ($hasSchema) { $tablename = $res['tablename']; } $sql = "SELECT currval( s2.nspname || '.' || t2.relname ) AS id\n\t\t\t\t\tFROM pg_depend AS d\n\t\t\t\t\tJOIN pg_class AS t1 ON t1.oid = d.refobjid\n\t\t\t\t\tJOIN pg_class AS t2 ON t2.oid = d.objid\n\t\t\t\t\tJOIN pg_namespace AS s1 ON s1.oid = t1.relnamespace\n\t\t\t\t\tJOIN pg_namespace AS s2 ON s2.oid = t2.relnamespace\n\t\t\t\t\tJOIN pg_attribute AS a ON a.attrelid = d.refobjid AND a.attnum = d.refobjsubid\n\t\t\t\t\tWHERE t1.relkind = 'r'\n\t\t\t\t\tAND t2.relkind = 'S'\n\t\t\t\t\tAND t1.relname = '" . $tablename . "'\n\t\t\t\t\tAND attname = '" . $campo . "'"; if ($hasSchema) { $sql .= " AND s2.nspname = '{$res['schema']}'"; } } else { $sql = "SELECT currval('" . $field['options']['sequence'] . "') as id"; } $cn = $this->getConnection(); $rs = $cn->executeSQL($sql); if (pg_num_rows($rs) > 0) { $line = pg_fetch_row($rs); pg_free_result($rs); return $line[0]; } pg_free_result($rs); return 0; }
<?php /** * classe de conexao com o PostgreSQL * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br * @package Lumine_Connection */ Lumine::load('Connection_AbstractConnection'); /** * classe de conexao com o PostgreSQL * @package Lumine_Connection * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br */ class Lumine_Connection_PostgreSQL extends Lumine_Connection_AbstractConnection { /** * ultima consulta * @var resource */ private $last_rs; /** * Construtor * * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br * @return Lumine_Connection_PostgreSQL */ public function __construct() {
<?php /** * @package Lumine_Connection * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br */ Lumine::load('Events_ConnectionEvent'); /** * Interface para conexoes * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br * @package Lumine_Connection */ interface ILumine_Connection extends ILumine_EventListener { /** * Abre a conexao com o banco * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br/ * @return void */ function connect(); /** * Fecha a conexao * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br/ * @return void */ function close(); /**
} echo '<br />'; echo '<input type="button" id="btnConcluir" value="Gerar Classes" onclick="concluir()" />'; } else { echo 'Nenhuma tabela encontrada'; } } catch (Exception $e) { $message = $e->getMessage(); $res = false; echo $message; } exit; break; case 'gerar': try { Lumine::load('Reverse'); $table_list = !empty($_POST['tables']) ? $_POST['tables'] : array(); unset($_POST['tables'], $_POST['options']['dto_package_mapping_check']); $_POST['options']['classDescriptor'] = ''; if ($_POST['options']['classMapping'] != 'default') { $_POST['options']['classDescriptor'] = $_POST['options']['classMapping']; } $_POST['options']['overwrite'] = 0; $_POST['options']['create_dtos'] = !empty($_POST['options']['create_dtos']); $_POST['options']['create_paths'] = !empty($_POST['options']['create_paths']); $_POST['options']['generateAccessors'] = !empty($_POST['options']['generateAccessors']); $_POST['options']['create_entities_for_many_to_many'] = !empty($_POST['options']['create_entities_for_many_to_many']); // ajusta algumas configuracoes if ($_POST['options']['tipo_geracao'] == 1) { $_POST['options']['generate_files'] = 1; $_POST['options']['generate_zip'] = 0;
<?php /** * Conexao com MySQL * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br * @package Lumine_Connection */ Lumine::load('Connection_IConnection'); /** * Conexao abstrata * * @package Lumine_Connection * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br */ abstract class Lumine_Connection_AbstractConnection extends Lumine_EventListener implements ILumine_Connection { /** * Estado fechado * @var int */ const CLOSED = 0; /** * Estado aberto * @var int */ const OPEN = 1; /** * Constante para versao do servidor * @var int
/** * Retorna o ultimo ID da tabela para campos auto-increment * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br/ * @param string $campo Nome do campo da tabela de auto-increment * @return int Valor da ultima insercao */ public function getLastId($campo) { $obj = Lumine::factory($this->getTablename()); $field = $obj->_getFieldByColumn($campo); $obj->destroy(); // se nao tiver sequence if (empty($field['options']['sequence'])) { $sql = "SELECT currval( s2.nspname || '.' || t2.relname ) AS id\n\t\t\t\t\tFROM pg_depend AS d\n\t\t\t\t\tJOIN pg_class AS t1 ON t1.oid = d.refobjid\n\t\t\t\t\tJOIN pg_class AS t2 ON t2.oid = d.objid\n\t\t\t\t\tJOIN pg_namespace AS s1 ON s1.oid = t1.relnamespace\n\t\t\t\t\tJOIN pg_namespace AS s2 ON s2.oid = t2.relnamespace\n\t\t\t\t\tJOIN pg_attribute AS a ON a.attrelid = d.refobjid AND a.attnum = d.refobjsubid\n\t\t\t\t\tWHERE t1.relkind = 'r'\n\t\t\t\t\tAND t2.relkind = 'S'\n\t\t\t\t\tAND t1.relname = '" . $this->getTablename() . "'\n\t\t\t\t\tAND attname = '" . $campo . "'"; } else { $sql = "SELECT currval('" . $field['options']['sequence'] . "') as id"; } $cn = $this->getConnection(); $rs = $cn->executeSQL($sql); if (pg_num_rows($rs) > 0) { $line = pg_fetch_row($rs); pg_free_result($rs); return $line[0]; } pg_free_result($rs); return 0; }
<?php /** * Classe para gerar as tabelas em MySQL * @package Lumine_Export * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br */ // carrega a classe abstrata Lumine::load('Export_IExport'); /** * Classe para gerar as tabelas em MySQL * @package Lumine_Export * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br */ class Lumine_Export_MySQL extends Lumine_Export_IExport { /** * guarda as SQL's para chaves estrangeiras * @var array */ private $foreignKeysSQL = array(); /** * * @see Lumine_Export_IExport::create() */ public function create() { $this->getForeignKeys(); $this->getIndexes();
/** * Recupera uma sequencia para um campo * * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br/ * @param array $field * @return string */ public function getSequence($field) { $st = null; $con_st = $this->obj->_getConnection()->getOption('sequence_type'); if (empty($field['sequence_type'])) { $st = $con_st; } else { $st = $field['sequence_type']; } $dialect = $this->obj->_getConfiguration()->getProperty('dialect'); switch ($st) { case self::SEQUENCE: $class = $dialect . "_Sequence"; Lumine::load('Sequence_' . $class); $this->seq_obj = new $class($obj, $field); break; case self::COUNT_TABLE: $class = $dialect . "_Count"; Lumine::load('Sequence_' . $class); $this->seq_obj = new $class($obj, $field); break; case self::NATURAL: default: $class = $dialect . "_Natural"; Lumine::load('Sequence_' . $class); $this->seq_obj = new $class($obj, $field); } $this->seq_obj->createSequence(); return $this->seq_obj; }
<?php Lumine::load('Reverse_ClassTemplate'); class Lumine_Reverse_ConfigurationTemplate { private $author = 'Hugo Ferreira da Silva'; private $date = null; private $generator = "Lumine_Reverse"; private $link = 'http://www.hufersil.com.br/lumine'; private $conf = null; private $ident = ' '; private $database = ''; function __construct(array $conf) { $this->date = date("Y-m-d"); $this->conf = $conf; $this->database = $conf['database']; } public function getGeneratedFile() { $ds = DIRECTORY_SEPARATOR; $modelo = LUMINE_INCLUDE_PATH . "{$ds}lib{$ds}Templates{$ds}config.txt"; $props = array(); $options = array(); foreach ($this->conf as $key => $val) { if ($key == 'options') { foreach ($val as $k => $v) { if (!is_array($v)) { $options[] = $this->ident . $this->ident . "'{$k}' => '{$v}'"; } else { $optionsString = $this->ident . $this->ident . "'{$k}' => array(" . PHP_EOL;
<?php /** * Classe de geracao de relatorio em pdf * * @package Lumine_Report * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br */ Lumine::load('Report_IReport'); if (!class_exists('FPDF')) { Lumine::load('Utils_fpdf'); } /** * Classe de geracao de relatorio em pdf * * @package Lumine_Report * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br */ class Lumine_Report_PDF extends Lumine_Report implements Lumine_Report_IReport { /** * objeto pdf * @var resource */ protected $pdf; /** * estilo anterior * @var array */
<?php Lumine::load('Lumine_Annotations_Annotations'); /** * * * @author Hugo Ferreira da Silva */ class Lumine_Templates_DefaultTemplate extends Lumine_Templates_AbstractTemplate { /** * nome do autor * * @var string */ private $author = 'Hugo Ferreira da Silva'; /** * data de criacao * * @var unknown_type */ private $date = null; /** * nome do gerador * * @var string */ private $generator = "Lumine_Reverse"; /** * link padrao da documentacao *
<?php ini_set('display_errors', 1); ini_set('display_startup_erros', 1); error_reporting(E_ALL); require_once 'Lumine/Lumine.php'; require_once 'lumine-conf.php'; $cfg = new Lumine_Configuration($lumineConfig); Lumine::import('Clientes'); $clientes = new Clientes(); $clientes->find(); foreach ($clientes->allToArray(true) as $row) { print_r($row); echo '<br>'; echo '<br>'; } //print_r( $cfg ); //include('eden.php'); //include('verify.php'); //include('../model.php'); //------------------------------------------------- //-- Inicializa��o MYSQL //------------------------------------------------- //$database = eden('mysql', '192.185.210.70' ,'msdis793_new', 'msdis793_new', 'new159753'); //$select = $database->select(); //$insert = $database->insert(); /*$update = $database->update(); /*$delete = $database->delete(); /*$model = $database->model();
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/> ################################################################################ /** * Classe que representa uma arvore de dados * * @author Hugo Ferreira da Silva * @package Lumine_Tree * @link http://www.hufersil.com.br/lumine * */ // Carrega as dependencias Lumine::load('Tree_Node', 'Tree_NodeList', 'Tree_Event'); /** * Classe que representa uma arvore de dados * * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br/lumine * */ class Lumine_Tree extends Lumine_EventListener { /** * Constante para setar o valor como nulo * @var int */ const DELETE_SET_NULL = 0x1; /**
<?php } // agora vamos listar as referencias $list = $this->obj->metadata()->getRelations(FALSE); foreach ($list as $name => $item) { switch ($item['type']) { case Lumine_Metadata::MANY_TO_MANY: ?> <tr> <td bgcolor="#FFFFFF" valign="top" align="right"><?php echo ucfirst($name); ?> </td> <td bgcolor="#FFFFFF"> <?php Lumine::import($item['class']); $obj = new $item['class'](); $obj->find(); $pk = $obj->metadata()->getPrimaryKeys(); while ($obj->fetch()) { printf('<input type="checkbox" name="%s[]" value="%s" %s /> %s<br />', $name, $obj->{$pk}[0]['name'], !empty($_POST[$name]) && in_array($obj->{$pk}[0]['name'], $_POST[$name]) ? ' checked="checked"' : '', $obj->nome == '' ? $obj->{$pk}[0]['name'] : $obj->nome); } ?> </td> </tr> <?php break; } } ?> <tr>
<?php Lumine::load('Reverse_ValidatorTemplate'); class Lumine_Reverse_ValidatorTemplate { private $author = 'Hugo Ferreira da Silva'; private $date = null; private $generator = "Lumine_Reverse"; private $link = 'http://www.hufersil.com.br/lumine'; private $dtd = 'http://www.hufersil.com.br/lumine/validator.dtd'; private $conf = null; private $ident = ' '; private $database = ''; private $obj = null; function __construct(Lumine_Reverse_ClassTemplate $obj, array $conf) { $this->date = date("Y-m-d"); $this->conf = $conf; $this->obj = $obj; $this->database = $conf['database']; } public function getGeneratedFile() { $ds = DIRECTORY_SEPARATOR; $modelo = LUMINE_INCLUDE_PATH . "{$ds}lib{$ds}Templates{$ds}validator.xml"; $props = array(); $options = array(); foreach ($this->conf as $key => $val) { if ($key == 'options') { foreach ($val as $k => $v) { $options[] = $this->ident . $this->ident . "'{$k}' => '{$v}'";
/** * Exporta o schema para o banco * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br/ * @return void */ public function export() { $class = 'Lumine_Export_' . $this->options['dialect']; Lumine::load($class); $reflection = new ReflectionClass($class); $instance = $reflection->newInstance(); $instance->export($this); }
/** * cria os controles basicos * * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br/ * @param string $controlName Nome do controle * @return void */ private function createControls($controlName) { $clname = 'Lumine_Form_' . $controlName; Lumine::load('Form_' . $controlName); $clControls = new $clname(null); reset($this->files); foreach ($this->files as $classname => $content) { $this->controls[$classname] = $clControls->getControlTemplate($this->cfg, $classname); } }
<?php /** * Implementacao de EventListeners * * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br * @package Lumine */ // carrega o arquivo da interface desta classe Lumine::load('IEventListener'); /** * Implementacao de EventListeners * * @package Lumine * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br */ class Lumine_EventListener implements Lumine_IEventListener { /** * ouvintes registrados * @var array */ private $_listeners = array(); /** * tipos de eventos suportados * @var array */ protected $_event_types = array(); /**
/** * Sobrecarga de metodo * * <p>Utilizado para chamar plugins</p> * * @author Hugo Ferreira da silva * @link http://www.hufersil.com.br * @param string $method Nome do metodo * @param args $args argumentos passados pelo usuario * @return mixed retorno do metodo do plugin */ public function __call($method, $args) { return Lumine::runPlugin($method, $this, $args); }
<?php /** * Classe abstrata para validacao * * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br * @package Lumine */ // carrega os validators Lumine::load('Validator_XMLValidator'); Lumine::load('Validator_ClassValidator'); Lumine::load('Validator_PHPValidator'); /** * Classe abstrata para validacao * * @package Lumine * @author Hugo Ferreira da Silva * @link http://www.hufersil.com.br */ abstract class Lumine_Validator { /** * Indica que e para validar uma string * @var string */ const REQUIRED_STRING = 'requiredString'; /** * Indica que e para validar um numero * @var string */