Changeset 2549 for trunk/phpgwapi


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

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

Location:
trunk/phpgwapi/inc
Files:
4 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                } 
  • trunk/phpgwapi/inc/class.javascript.inc.php

    r2547 r2549  
    4949                * @var array list of validated files to be included in the head section of a page 
    5050                */ 
    51                 var $files; 
     51                private $files = array( ); 
    5252 
    5353                /** 
     
    153153                                                                                $links .= '<script type="text/javascript" src="' 
    154154                                                                                        . $GLOBALS['phpgw_info']['server']['webserver_url'] 
    155                                                                                         . "/$app/js/$pkg/$file" . '.js">' 
     155                                                                                        . "/$app/js/$pkg/$file" . '.js?' . microtime( true ) . '">' 
    156156                                                                                        . "</script>\n"; 
    157157                                                                        } 
     158 
     159                                                                        $this -> unset_script_link( $app, $pkg, $file ); 
    158160                                                                } 
    159161                                                        } 
     
    223225                * @returns bool was the file found? 
    224226                */ 
    225                 function validate_file($package, $file, $app='phpgwapi') 
    226                 { 
    227                         if(is_readable(PHPGW_INCLUDE_ROOT .SEP .$app .SEP .'js' .SEP . $package .SEP. $file . '.js')) 
    228                         { 
    229                                 $this->files[$app][$package][$file] = $file; 
    230                                 return True; 
    231                         } 
    232                         elseif($app != 'phpgwapi') 
    233                         { 
    234                                 if(is_readable(PHPGW_INCLUDE_ROOT .SEP .'phpgwapi' .SEP .'js' .SEP . $package .SEP . $file . '.js')) 
    235                                 { 
    236                                         $this->files['phpgwapi'][$package][$file] = $file; 
    237                                         return True; 
    238                                 } 
    239                                 return False; 
    240                         } 
     227                function validate_file( $package, $file, $app = NULL, $stack = false ) 
     228                { 
     229                        if ( $app == NULL ) 
     230                                $app = 'phpgwapi'; 
     231 
     232                        $_file = PHPGW_INCLUDE_ROOT . SEP . $app . SEP . 'js' . SEP . $package . SEP. $file . '.js'; 
     233                        if ( is_readable( $_file ) ) 
     234                        { 
     235                                unset( $_file ); 
     236 
     237                                if ( ! array_key_exists( $app, $this -> files ) ) 
     238                                        $this -> files[ $app ] = array( ); 
     239 
     240                                if ( ! array_key_exists( $package, $this -> files[ $app ] ) ) 
     241                                        $this -> files[ $app ][ $package ] = array( ); 
     242 
     243                                if ( $stack ) 
     244                                        $this -> files[ $app ][ $package ] = array_merge( array( $file => $file ), $this -> files[ $app ][ $package ] ); 
     245                                else 
     246                                        $this -> files[ $app ][ $package ][ $file ] = $file; 
     247 
     248                                return true; 
     249                        } 
     250                        return false; 
    241251                } 
    242252        } 
  • trunk/phpgwapi/inc/class.preferences.inc.php

    r2002 r2549  
    174174                                                foreach($val as $k => $v) 
    175175                                                { 
    176                                                         if (!is_array($v) && strstr($val,'$$') !== False) 
     176                                                        if (!is_array($v) && is_string( $val ) && strstr($val,'$$') !== False) 
    177177                                                        { 
    178178                                                                $this->data[$app][$key][$k] = $this->parse_notify($v); 
  • trunk/phpgwapi/inc/functions.inc.php

    r2419 r2549  
    3030        error_reporting(error_reporting() & ~E_NOTICE); 
    3131 
    32         include(PHPGW_API_INC.'/common_functions.inc.php'); 
     32        include_once(PHPGW_API_INC.'/common_functions.inc.php'); 
    3333         
    3434        /*! 
     
    234234        $GLOBALS['phpgw']->preferences  = CreateObject('phpgwapi.preferences'); 
    235235        $GLOBALS['phpgw']->applications = CreateObject('phpgwapi.applications'); 
     236        $GLOBALS['phpgw']->js           = CreateObject('phpgwapi.javascript'); 
    236237        print_debug('main class loaded', 'messageonly','api'); 
    237238        if (! isset($GLOBALS['phpgw_info']['flags']['included_classes']['error']) || 
     
    403404                                ! $GLOBALS['phpgw_info']['user']['apps']['admin'])) 
    404405                        { 
    405                                 $GLOBALS['phpgw']->common->phpgw_header(); 
     406                                //$GLOBALS['phpgw']->common->phpgw_header(); 
    406407 
    407408                                $GLOBALS['phpgw']->log->write(array('text'=>'W-Permissions, Attempted to access %1','p1'=>$GLOBALS['phpgw_info']['flags']['currentapp'])); 
     
    416417                        $GLOBALS['phpgw']->datetime = CreateObject('phpgwapi.date_time'); 
    417418                } 
     419 
    418420                $GLOBALS['phpgw']->applications->read_installed_apps(); // to get translated app-titles 
    419                  
    420                 /*************************************************************************\ 
    421                 * Load the header unless the developer turns it off                       * 
    422                 \*************************************************************************/ 
    423                 if ( array_key_exists( 'HTTP_BACKGROUNDREQUEST', $_SERVER ) || array_key_exists( 'BackgroundRequest', $_GET ) ) 
    424                 { 
    425                         $GLOBALS['phpgw_info']['flags'] = array( 
    426                                 'noheader'   => true, 
    427                                 'nonavbar'   => true 
    428                         ); 
    429                 } 
    430                 if (!@$GLOBALS['phpgw_info']['flags']['noheader']) 
    431                 { 
    432                         $GLOBALS['phpgw']->common->phpgw_header(); 
    433                 } 
    434         } 
     421        } 
Note: See TracChangeset for help on using the changeset viewer.