コード例 #1
0
 /**
  * Function to integrate scripts to the site
  * 
  * @return void
  */
 function onAfterInitialise()
 {
     $document =& JFactory::getDocument();
     // set document for next usage
     $doctype = $document->getType();
     // get document type
     // disable plugin for non-HTML interface (like RSS feed or PDF)
     if ($doctype !== 'html') {
         return false;
     }
     JPlugin::loadLanguage('plg_system_' . JScriptegrator::properties('name'), JPATH_ADMINISTRATOR);
     // define language
     // get folder names - from libraries folder
     $libraries = JFolder::folders(JScriptegrator::folder(true) . DS . 'libraries', false, false);
     // serach each library and call function
     foreach ($libraries as $library) {
         if ($this->enableLibrary($library)) {
             // define helper path
             $library_class_path = JScriptegrator::folder(true) . DS . 'libraries' . DS . $library . DS . $library . '.php';
             // load class file if exists
             if (JFile::exists($library_class_path)) {
                 $class_name = $library;
                 JLoader::register($class_name, $library_class_path);
                 // import header files
                 if (is_callable(array($class_name, 'importFiles'))) {
                     $files_to_import = call_user_func(array($class_name, 'importFiles'));
                     if (is_array($files_to_import)) {
                         JScriptegrator::library($library, $files_to_import);
                     }
                 }
                 // add script declaration
                 if (is_callable(array($class_name, 'scriptDeclaration'))) {
                     $script_declaration = call_user_func(array($class_name, 'scriptDeclaration'), $this->params);
                     if ($script_declaration) {
                         $document->addScriptDeclaration($script_declaration);
                     }
                 }
                 if (is_callable(array($class_name, 'load'))) {
                     call_user_func(array($class_name, 'load'));
                 }
             }
         }
     }
 }