Ignore:
Timestamp:
04/15/10 15:26:02 (14 years ago)
Author:
rodsouza
Message:

Ticket #1009 - Corrigindo problemas com a inclusão de javascript.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpgwapi/inc/class.common.inc.php

    r2547 r2549  
    368368                                define('PHPGW_FINAL',True); 
    369369 
     370                                $module_content = ob_get_contents( ); 
     371 
     372                                ob_clean( ); 
     373 
     374                                /*************************************************************************\ 
     375                                * Load the header unless the developer turns it off                       * 
     376                                \*************************************************************************/ 
     377                                if ( array_key_exists( 'HTTP_BACKGROUNDREQUEST', $_SERVER ) || array_key_exists( 'BackgroundRequest', $_GET ) ) 
     378                                        $GLOBALS['phpgw_info']['flags'] = array_merge( $GLOBALS['phpgw_info']['flags'], array( 
     379                                                'noheader'   => true, 
     380                                                'nonavbar'   => true 
     381                                        ) ); 
     382 
     383                                if ( ! @$GLOBALS['phpgw_info']['flags']['noheader'] ) 
     384                                { 
     385                                        if ( ! isset( $GLOBALS[ 'phpgw_info' ][ 'flags' ][ 'java_script_thirst' ] ) ) 
     386                                                $GLOBALS['phpgw_info']['flags']['java_script_thirst'] = ''; 
     387 
     388                                        $GLOBALS['phpgw_info']['flags']['java_script_thirst'] .= '<script type="text/javascript">var URL_SERVER = "' 
     389                                                . $GLOBALS[ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . '";' 
     390                                                . 'var template = "' . $GLOBALS[ 'phpgw_info' ][ 'server' ][ 'template_set' ] . '";</script>'; 
     391 
     392                                        $GLOBALS[ 'phpgw' ] -> js -> validate_file( 'wz_dragdrop', 'wz_dragdrop', NULL, true ); 
     393                                        $GLOBALS[ 'phpgw' ] -> js -> validate_file( 'expressoAjax', 'expressoAjax', NULL, true ); 
     394                                        $GLOBALS[ 'phpgw' ] -> js -> validate_file( 'tools','xlink', NULL, true ); 
     395                                        $GLOBALS[ 'phpgw' ] -> js -> validate_file( 'tools','xconnector', NULL, true ); 
     396                                        $GLOBALS[ 'phpgw' ] -> js -> validate_file( 'tools','xevent', NULL, true ); 
     397 
     398                                        $this -> phpgw_header( ); 
     399                                } 
     400                                else 
     401                                        echo $this -> get_java_script( ); 
     402 
     403                                echo $module_content; 
     404 
    370405                                /*if (is_object($GLOBALS['phpgw']->accounts)) 
    371406                                { 
    372407                                        $GLOBALS['phpgw']->accounts->save_session_cache(); 
    373408                                }*/ 
     409 
    374410                                // call the asyncservice check_run function if it is not explicitly set to cron-only 
    375411                                // 
     
    378414                                        ExecMethod('phpgwapi.asyncservice.check_run','fallback'); 
    379415                                } 
     416 
    380417                                /* Clean up mcrypt */ 
    381418                                if (@is_object($GLOBALS['phpgw']->crypto)) 
     
    384421                                        unset($GLOBALS['phpgw']->crypto); 
    385422                                } 
     423 
    386424                                $GLOBALS['phpgw']->db->disconnect(); 
    387425                        } 
     
    12131251                        // add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv) 
    12141252                        header('Content-type: text/html; charset='.$GLOBALS['phpgw']->translation->charset()); 
    1215                         include(PHPGW_INCLUDE_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info']['server']['template_set'] 
    1216                                 . '/head.inc.php'); 
     1253 
     1254                        include(PHPGW_INCLUDE_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info']['server']['template_set'] . '/head.inc.php'); 
     1255 
    12171256                        $this->navbar(False); 
    1218                         include(PHPGW_INCLUDE_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info']['server']['template_set'] 
    1219                                 . '/navbar.inc.php'); 
    1220  
    1221                         if(!@is_object($GLOBALS['phpgw']->js)) 
    1222                         { 
    1223                                 $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); 
    1224                         } 
    1225  
    1226                         $GLOBALS['phpgw']->js->validate_file( 'tools','xevent' ); 
    1227                         $GLOBALS['phpgw']->js->validate_file( 'tools','xconnector' ); 
    1228                         $GLOBALS['phpgw']->js->validate_file( 'tools','xlink' ); 
    1229  
    1230                         $GLOBALS['phpgw']->js->validate_file('expressoAjax','expressoAjax'); 
    1231  
    1232                         $GLOBALS['phpgw']->js->validate_file('wz_dragdrop','wz_dragdrop'); 
    1233  
    1234                         echo "\n<script type='text/javascript'>var URL_SERVER = '".$GLOBALS['phpgw_info']['server']['webserver_url']."';</script>\n"; 
    1235                         echo $GLOBALS['phpgw']->js->get_script_links(); 
    1236  
    1237                         $GLOBALS['phpgw']->js->unset_script_link( 'phpgwapi','tools' ); 
    1238  
    1239                         $GLOBALS['phpgw']->js->unset_script_link('phpgwapi','expressoAjax'); 
    1240  
    1241                         // TODO 
    1242                         // Esse javascript será carregado sempre pois causa grandes 
    1243                         // problemas em diversos módulos. Algum dia será substituido. 
    1244                         $GLOBALS['phpgw']->js->unset_script_link('phpgwapi','wz_dragdrop'); 
     1257 
     1258                        include(PHPGW_INCLUDE_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info']['server']['template_set'] . '/navbar.inc.php'); 
    12451259 
    12461260                        if (!@$GLOBALS['phpgw_info']['flags']['nonavbar'] && !@$GLOBALS['phpgw_info']['flags']['navbar_target']) 
    1247                         { 
    12481261                                echo parse_navbar(); 
    1249                         }  
    12501262                } 
    12511263 
     
    13431355                * @return string the javascript to be included 
    13441356                */ 
    1345                 function get_java_script() 
     1357                function get_java_script( ) 
    13461358                { 
    13471359                        $java_script = ''; 
     
    13491361                        /* this flag is for all javascript code that has to be put before other jscode.  
    13501362                        Think of conf vars etc...  (pim@lingewoud.nl) */ 
    1351                         if (isset($GLOBALS['phpgw_info']['flags']['java_script_thirst'])) 
    1352                         { 
    1353                                 $java_script .= $GLOBALS['phpgw_info']['flags']['java_script_thirst'] . "\n"; 
    1354                         } 
    1355                          
    1356                         if(@is_object($GLOBALS['phpgw']->js)) 
    1357                         { 
    1358                                 $java_script .= $GLOBALS['phpgw']->js->get_script_links(); 
    1359                         } 
     1363                        if ( isset( $GLOBALS[ 'phpgw_info' ][ 'flags' ][ 'java_script_thirst' ] ) ) 
     1364                                $java_script .= $GLOBALS['phpgw_info']['flags']['java_script_thirst']; 
     1365 
     1366                        if( is_object( $GLOBALS[ 'phpgw' ] -> js ) ) 
     1367                                $java_script .= $GLOBALS[ 'phpgw' ] -> js -> get_script_links( ); 
    13601368 
    13611369                        if(@isset($_GET['menuaction'])) 
     
    13681376                                } 
    13691377                        } 
    1370                         if (isset($GLOBALS['phpgw_info']['flags']['java_script'])) 
    1371                         { 
    1372                                 $java_script .= $GLOBALS['phpgw_info']['flags']['java_script'] . "\n"; 
    1373                         } 
     1378 
     1379                        if ( isset( $GLOBALS[ 'phpgw_info' ][ 'flags' ][ 'java_script' ] ) ) 
     1380                                $java_script .= $GLOBALS[ 'phpgw_info' ][ 'flags' ][ 'java_script' ]; 
     1381 
    13741382                        return $java_script; 
    13751383                } 
Note: See TracChangeset for help on using the changeset viewer.