Пример #1
0
 public static function initTemplateEngine($renderAs)
 {
     if (self::$initTemplateEngineFirstRun) {
         //apps that started before the template initialization can load their own scripts/styles
         //so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true
         //meaning the last script/style in this list will be loaded first
         if (\OC::$server->getSystemConfig()->getValue('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) {
             if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') {
                 OC_Util::addScript('backgroundjobs', null, true);
             }
         }
         OC_Util::addStyle("tooltip", null, true);
         OC_Util::addStyle('jquery-ui-fixes', null, true);
         OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui', null, true);
         OC_Util::addStyle("multiselect", null, true);
         OC_Util::addStyle("fixes", null, true);
         OC_Util::addStyle("global", null, true);
         OC_Util::addStyle("apps", null, true);
         OC_Util::addStyle("fonts", null, true);
         OC_Util::addStyle("icons", null, true);
         OC_Util::addStyle("mobile", null, true);
         OC_Util::addStyle("header", null, true);
         OC_Util::addStyle("inputs", null, true);
         OC_Util::addStyle("styles", null, true);
         // avatars
         if (\OC::$server->getSystemConfig()->getValue('enable_avatars', true) === true) {
             \OC_Util::addScript('avatar', null, true);
             \OC_Util::addScript('jquery.avatar', null, true);
             \OC_Util::addScript('placeholder', null, true);
         }
         OC_Util::addScript('oc-backbone', null, true);
         OC_Util::addVendorScript('core', 'backbone/backbone', true);
         OC_Util::addVendorScript('snapjs/dist/latest/snap', null, true);
         OC_Util::addScript('mimetypelist', null, true);
         OC_Util::addScript('mimetype', null, true);
         OC_Util::addScript("apps", null, true);
         OC_Util::addScript("oc-requesttoken", null, true);
         OC_Util::addScript('search', 'search', true);
         OC_Util::addScript("config", null, true);
         OC_Util::addScript("eventsource", null, true);
         OC_Util::addScript("octemplate", null, true);
         OC_Util::addTranslations("core", null, true);
         OC_Util::addScript("l10n", null, true);
         OC_Util::addScript("js", null, true);
         OC_Util::addScript("oc-dialogs", null, true);
         OC_Util::addScript("jquery.ocdialog", null, true);
         OC_Util::addStyle("jquery.ocdialog");
         OC_Util::addScript("compatibility", null, true);
         OC_Util::addScript("placeholders", null, true);
         OC_Util::addScript('files/fileinfo');
         OC_Util::addScript('files/client');
         // Add the stuff we need always
         // following logic will import all vendor libraries that are
         // specified in core/js/core.json
         $fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json');
         if ($fileContent !== false) {
             $coreDependencies = json_decode($fileContent, true);
             foreach (array_reverse($coreDependencies['vendor']) as $vendorLibrary) {
                 // remove trailing ".js" as addVendorScript will append it
                 OC_Util::addVendorScript(substr($vendorLibrary, 0, strlen($vendorLibrary) - 3), null, true);
             }
         } else {
             throw new \Exception('Cannot read core/js/core.json');
         }
         if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) {
             // shim for the davclient.js library
             \OCP\Util::addScript('files/iedavclient');
         }
         self::$initTemplateEngineFirstRun = false;
     }
 }