Location: PHPKode > projects > oBiblioOPAC for Joomla! > trunk-56/admin.obiblioopac4j.html.php
<?php
/**
* @version 0.0.1
* @package obiblioopac4j
* @copyright (C) 2005 Adriano dos Santos Vieira
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
 
/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or
    die( 'Direct Access to this location is not allowed.' );
 
/**
 * @package obiblioopac4j
 */
class obiblioAdmin {
	
	function obiblioAdmin() {
		/**
		 * array contento as definicoes de banco, idioma
		 *      $obib_cfg['db'] -> banco
		 *      $obib_cfg['lang'] -> idioma
		 */
		global $obib_cfg;
		
			obiblioAdmin::obiblioConfig();
			return $obib_cfg;
	}

		
	function obiblioConfig() {
        global $mainframe, $mosConfig_lang, $database, 	$obib_cfg;
		
        // include support libraries
        require_once( $mainframe->getPath( 'class' ) );
        
        $_adminPath = dirname($mainframe->getPath( 'admin_html' ));

        $_admin_setup = oBiblioOPAC4J::oBiblioGetAdminSetup();
        
        $obib_cfg['db']['host']  = $_admin_setup[0]->obibhostname;
        $obib_cfg['db']['database'] = $_admin_setup[0]->obibdatabase;
        $obib_cfg['db']['username']  = $_admin_setup[0]->obibusername;
        $obib_cfg['db']['userpwd']  = $_admin_setup[0]->obibuserpass;
        $obib_cfg['setup']['pageitens']  = $_admin_setup[0]->obibpageitens;
        $obib_cfg['setup']['pagecounter']  = $_admin_setup[0]->obibpagecounter;
		
		return $obib_cfg;
	}
	
    /**
     * Static method to create the template object
     * @return patTemplate
     */
    function &createTemplate() {
        global $option, $mosConfig_absolute_path;
        require_once($mosConfig_absolute_path.'/includes/patTemplate/patTemplate.php' );
		
        $tmpl =& patFactory::createTemplate( $option, true, false );
        $tmpl->setRoot( dirname( __FILE__ ) . '/tmpl' );
		
        return $tmpl;
    }

    /**
     * show obiblio configuration event
     * @param array The server data configuration
     */
    function showObibConfig() {
		
		$_obib_cfg =& obiblioAdmin::obiblioConfig();
        
        // Tradutor da aplicacao
        $_objLang  =& obiblioAdmin::create_Translator();
		
        // import the body of the page
        $tmpl =& obiblioAdmin::createTemplate();
        $tmpl->setAttribute( 'body', 'src', 'showobibconfig.html' );
 
        $tmpl->addVar( 'body', 'OBIB_SETUP_TITLE', $_objLang->GetText('#obib_setup title#') );
        $tmpl->addVar( 'body', 'obib_openbiblio_setup_title', $_objLang->GetText('#obib_openbiblio setup title#') );
        $tmpl->addVar( 'body', 'obib_openbiblio_setup_host', $_objLang->GetText('#obib_openbiblio setup host#') );
        $tmpl->addVar( 'body', 'obib_openbiblio_setup_database', $_objLang->GetText('#obib_openbiblio setup database#') );
        $tmpl->addVar( 'body', 'obib_openbiblio_setup_user', $_objLang->GetText('#obib_openbiblio setup user#') );
        $tmpl->addVar( 'body', 'obib_openbiblio_setup_pass', $_objLang->GetText('#obib_openbiblio setup pass#') );
        $tmpl->addVar( 'body', 'obib_outras_definicoes_padrao', $_objLang->GetText('#obib_outras definicoes padrao#' ));
        $tmpl->addVar( 'body', 'obib_itens_por_pagina', $_objLang->GetText('#obib_itens por pagina#') );
        $tmpl->addVar( 'body', 'obib_quantidade_paginas', $_objLang->GetText('#obib_quantidade paginas#') );
          
        $tmpl->addVar( 'body', 'OBIB_HOST', $_obib_cfg['db']['host'] );
        $tmpl->addVar( 'body', 'OBIB_DATABASE', $_obib_cfg['db']['database'] );
        $tmpl->addVar( 'body', 'OBIB_USERNAME', $_obib_cfg['db']['username'] );
        $tmpl->addVar( 'body', 'OBIB_PWD', $_obib_cfg['db']['userpwd'] );
        $tmpl->addVar( 'body', 'OBIB_PAGEITENS', $_obib_cfg['setup']['pageitens'] );
        $tmpl->addVar( 'body', 'OBIB_PAGECOUNTER', $_obib_cfg['setup']['pagecounter'] );
 
        $tmpl->displayParsedTemplate( 'form' );
    }
    
    function SaveObibConfig($_obibsetup) {
        global $database;
        
        $_sql_update = "update #__obiblioopac4j_obibsetup ";
        $_sql_update_set = " set obibhostname = '".$_obibsetup['server']['hostname'].
                                             "', obibdatabase = '".$_obibsetup['server']['database'].
                                             "', obibusername = '".$_obibsetup['server']['username'].
                                             "', obibuserpass = '".$_obibsetup['server']['userpass'].
                                             "', obibpageitens = '".$_obibsetup['pageitens'].
                                             "', obibpagecounter = '".$_obibsetup['pagecounter']."'";
                                             
        $_sql_update_where = " where obibhostname = '".$_obibsetup['server']['hostname_ori'].
                                             "' and obibdatabase = '".$_obibsetup['server']['database_ori'].
                                             "' and obibusername = '".$_obibsetup['server']['username_ori']."'";
        
        $_sql = $_sql_update . $_sql_update_set.$_sql_update_where;
        
        $database->setQuery($_sql);
        if(!$result = $database->query()) {
          echo $database->stderr();
          return false;
        }
        mosRedirect("index2.php?option=$option&task=cfg_obiblioopac4j" );
    }

    /**
     * obiblio Translator event
     * 
     */
        function create_Translator() {
            global $mainframe, $mosConfig_lang, $database;
            
            $_adminPath = dirname($mainframe->getPath( 'admin_html' ));
            $_classPath = dirname($mainframe->getPath( 'class' ));
            define(TRANSLATOR_PATH, $_classPath."/phpTranslator/");
            define(OBIBOPAC_ADMIN_PATH, $_adminPath);
            
            if(@include_once(TRANSLATOR_PATH.'/Translator.php')) {
                $_objLang = new Translator(TRANSLATOR_PATH);
                
                $_objLang->SetFilePath(OBIBOPAC_ADMIN_PATH."/language/");
                $_objLang->SetTabPaneURLPath("../components/com_obiblioopac4j/phpTranslator/");
                $_objLang->SetLangSrc("en");
                $_objLang->SetLanguage(_LANGUAGE,'target');
                
                $_objLang->BuildLangArray();
                $_objLang->BuildLangArray('target');  
                
            }
            else {
                echo "<div class='centermain'>Translator package (phpTranslator) isn't found!</div>";
                exit;
            }
            
            return $_objLang;
      } // end func: create_Translator

    /**
     * obiblio translation event
     * 
     */
        function translate_obiblioopac4j() {
            
            $_objLang  =& obiblioAdmin::create_Translator();
            if(is_object($_objLang)) {
                $_objLang->Translate(false);
            }
            else {
                echo "<div class='centermain'>Translator object (phpTranslator) isn't created!</div>";
            }
      } // end func: translate_obiblioopac4j

    /**
     * obiblio about event
     * 
     */
        function aboutObiblioopac4j() {
            global $mainframe;
            $_adminPath = dirname($mainframe->getPath( 'admin_html' ));
            include $_adminPath."/help/obiblioopac4j-about.html";
      } // end func: aboutObiblioopac4j

}
?>
Return current item: oBiblioOPAC for Joomla!