Returns filelist of js files for the requested area.

Also combines all local files and inline scripts into one cached combined_{$area}.js file.

@param string $area

@return array
162141
public function getFiles($area)
    {
        // Get scripts of this area
        $script_stack = $this->getScriptObjects($area);

        if (empty($script_stack)) {
            return $script_stack;
        }

        // Init js storages
        $files = $blocks = $inline = $scripts = $ready = $vars = $local_files = [];

        /* @var $script JavascriptObject */
        foreach ($script_stack as $key => $script) {

            switch ($script->getType()) {

                // File to lin
                case 'file':
                    $filename = $script->getScript();

                    if (strpos($filename, BASEURL) !== false && $script->getCombine()) {
                        $local_files[] = str_replace(BASEURL, BASEDIR, $filename);
                    }
                    else {
                        $files[] = $filename;
                    }
                    break;

                // Script to create
                case 'script':
                    $inline[] = $script->getScript();
                    break;

                // Dedicated block to embaed
                case 'block':
                    $blocks[] = $script->getScript();
                    break;

                // A variable to publish to global space
                case 'var':
                    $var = $script->getScript();
                    $vars[$var[0]] = $var[1];
                    break;

                // Script to add to $.ready()
                case 'ready':
                    $ready[] = $script->getScript();
                    break;
            }

            // Remove worked script object
            unset($script_stack[$key]);
        }

        // Check cache
        if ($local_files || $inline || $vars || $scripts || $ready) {

            $key = 'combined_' . $area;
            $extension = 'js';

            $filename = $this->config->Core['dir.cache'] . '/' . $key . '.' . $extension;

            // End of combined file TTL reached?
            if (!file_exists($filename) || filemtime($filename) + $this->config->Core['cache.ttl.' . $extension] < time()) {

                // Strat combining all parts
                $combined = '';

                if ($local_files) {
                    foreach ($local_files as $js_file) {
                        $combined .= file_get_contents($js_file);
                    }
                }

                if ($inline) {
                    $combined .= implode('', $inline);
                }

                if ($vars) {
                    foreach ($vars as $name => $val) {
                        $combined .= 'var ' . $name . ' = ' . (is_string($val) ? '"' . $val . '"' : $val) . ';';
                    }
                }

                if ($ready) {
                    $combined .= '$(document).ready(function() {' . implode('', $ready) . '});';
                }

                if ($blocks) {
                    $combined .= implode($blocks);
                }

                $combined = \JSMin::minify($combined);

                // Make sure we write files only into to cache folder!
                if (strpos($filename, $this->config->Core['dir.cache']) === false) {
                    Throw new PageException('Writing files outside the cachefolder from Javascript::getFiles() is not permitted.');
                }

                file_put_contents($filename, $combined);
            }

            $files[] = $this->config->Core['url.cache'] . '/' . $key . '.' . $extension;
        }

        return $files;
    }
720274
public function get_areas_config($searchareas) {

        $vars = array('indexingstart', 'indexingend', 'lastindexrun', 'docsignored',
                'docsprocessed', 'recordsprocessed', 'partial');

        $configsettings = [];
        foreach ($searchareas as $searcharea) {

            $areaid = $searcharea->get_area_id();

            $configsettings[$areaid] = new \stdClass();
            list($componentname, $varname) = $searcharea->get_config_var_name();

            if (!$searcharea->is_enabled()) {
                // We delete all indexed data on disable so no info.
                foreach ($vars as $var) {
                    $configsettings[$areaid]->{$var} = 0;
                }
            } else {
                foreach ($vars as $var) {
                    $configsettings[$areaid]->{$var} = get_config($componentname, $varname .'_' . $var);
                }
            }

            // Formatting the time.
            if (!empty($configsettings[$areaid]->lastindexrun)) {
                $configsettings[$areaid]->lastindexrun = userdate($configsettings[$areaid]->lastindexrun);
            } else {
                $configsettings[$areaid]->lastindexrun = get_string('never');
            }
        }
        return $configsettings;
    }
369128
public function getFiles($asArray = false)
    {
        $return = array();
        if ($asArray && $this->files) {
            foreach ($this->files as $file) {
                $return[] = $file->toArray();
            }
        }

        return $asArray ? $return : $this->files;
    }
198528
protected function getMap(): array
    {
        $auth = $this->core->auth();
        $paths = [
            ['GET', '/sw.[i].js', function () {
                if (headers_sent() === false) {
                    header("Content-Type: application/javascript");
                }
                return file_get_contents(dirname(__DIR__) . "/files/sw.js");
            }],
            ['GET', '/offline', "Home@offline"],
        ];
        if ($auth->details === false) {
            $paths = array_merge($paths, [
                ['GET', '/api/[**:link]?', "API"],
                ['GET', '/login', "Auth@showLogin", 'login-page'],
                ['GET', '/register', "Auth@showRegister", 'register-page'],
                ['GET', '/confirm', "Auth@confirm", 'confirm-page'],
                ['GET', '/forgot', "Auth@showForgot", 'forgot-page'],
                ['GET', '/reset/[a:reset_code]', "Auth@showReset", 'reset-page']
            ]);
        } else {
            $paths = array_merge($paths, [
                ['GET', '/api/[**:link]', "Auth@redirect"],
                ['GET', '/login', "Auth@redirect"],
                ['GET', '/register', "Auth@redirect"],
                ['GET', '/confirm', "Auth@confirm", 'confirm-page'],
                ['GET', '/forgot', "Auth@redirect"],
                ['GET', '/reset/[a:reset_code]', "Auth@redirect"]
            ]);
        }
        if ($auth->allow(["min" => 5, "max" => 1]) === true) {
            $paths = array_merge($paths, [
                ['GET', '/', "User@showProfile", 'home-page'],
                ['GET', '/logout', "User@logout", 'logout-page']
            ]);
        } elseif ($auth->details === false) {
            $paths = array_merge($paths, [
                ['GET', '/', "Home@redirect"],
                ['GET', '/logout', "Home@redirect"]
            ]);
        }
        if ($auth->allow(["min" => 4, "max" => 4]) === true) {
            $paths = array_merge($paths, [
                ['GET', '/users', "User@showList", 'users-list-page']
            ]);
        } elseif ($auth->details === false) {
            $paths = array_merge($paths, [
                ['GET', '/users', "Home@redirect"]
            ]);
        }
        if ($auth->allow(["min" => 4, "max" => 1]) === true) {
            $paths = array_merge($paths, [
                ['GET', '/pages/[i:page]?', "Page@showList", 'pages-list-page']
            ]);
        } elseif ($auth->details === false) {
            $paths = array_merge($paths, [
                ['GET', '/pages/[i:page]?', "Home@redirect"]
            ]);
        }
        if ($auth->allow(["min" => 3, "max" => 1]) === true) {
            $paths = array_merge($paths, [
                ['GET', '/pages/new', "Page@showNew", 'pages-new-page'],
                ['GET', '/pages/edit/[i:id]', "Page@showEdit", 'pages-edit-page'],
            ]);
        } elseif ($auth->details === false) {
            $paths = array_merge($paths, [
                ['GET', '/pages/new', "Home@redirect"],
                ['GET', '/pages/edit/[i:id]', "Home@redirect"],
            ]);
        }
        if ($auth->allow(["min" => 2, "max" => 1]) === true) {
            $paths = array_merge($paths, [
                ['GET', '/navigations', "Navigation@showNavigations", 'navigations-page']
            ]);
        } elseif ($auth->details === false) {
            $paths = array_merge($paths, [
                ['GET', '/navigations', "Home@redirect"]
            ]);
        }
        if ($auth->allow(["min" => 1, "max" => 1]) === true) {
            $paths = array_merge($paths, [
                ['GET', '/users/[i:page]?', "User@showList", 'users-list-page'],
                ['GET', '/users/new', "User@showNew", 'users-new-page'],
                ['GET', '/users/edit/[i:id]', "User@showEdit", 'users-edit-page'],
                ['GET', '/settings', "Site@showSettings", 'settings-page']
            ]);
        } elseif ($auth->details === false) {
            $paths = array_merge($paths, [
                ['GET', '/users/[i:page]?', "Home@redirect"],
                ['GET', '/users/new', "Home@redirect"],
                ['GET', '/users/edit/[i:id]', "Home@redirect"],
                ['GET', '/settings', "Home@redirect"]
            ]);
        }
        return $paths;
    }
39916
final protected function getScript($area, $data_only = false)
    {
        $files = $this->page->js->getFiles($area);

        if ($data_only) {
            return $files;
        }

        // Init output var
        $html = '';

        // Create files
        foreach ($files as $file) {

            // Create script html object
            $html .= PHP_EOL . '<script src="' . $file . '"></script>';
        }

        return $html;
    }
592053
public function getMenu($area = null)
    {
        if (!key_exists($area, self::$data)) {
            return self::$data;
        } else {
            return self::$data[$area];
        }
    }
1241519
public function setAreas($areas = null)
    {
        if ($areas === null) {
            $appDir = $this->alias->get('@app');
            $dirs = glob("$appDir/Areas/*", GLOB_ONLYDIR) ?: glob("$appDir/Controllers/*", GLOB_ONLYDIR);

            $areas = [];
            foreach ($dirs as $dir) {
                $dir = substr($dir, strrpos($dir, '/') + 1);
                if (preg_match('#^[A-Za-z]\w+$#', $dir)) {
                    $areas[] = $dir;
                }
            }
        }

        $this->_areas = $areas;

        return $this;
    }
1276616
public function getGroups($area, $locale)
    {
        return $this->model->where('area', $area)->whereHas('language', function($query) use($locale) {
                            $query->where('code', $locale);
                        })->groupBy('group')->orderBy('group', 'desc')
                        ->get();
    }
880283
public static function getAssetFilePaths($type)
    {
        $path = sprintf('%s/assets/%s/', __DIR__, $type);
        $filenames = preg_grep('/^[^\.]/', scandir($path));
        if (!Arr::iterable($filenames)) {
            return array();
        }

        return array_map(function ($filename) use ($path) {
            return $path.$filename;
        }, $filenames);
    }
695286
def _load_area_def(self, dsid, file_handlers):
        """"""
        area_defs = [fh.get_area_def(dsid) for fh in file_handlers]
        area_defs = [area_def for area_def in area_defs
                     if area_def is not None]

        final_area = StackedAreaDefinition(*area_defs)
        return final_area.squeeze()
844297
public function getList(
        $page = null,
        $pageSize = null,
        array $localeFilter = array(),
        array $countryCodeFilter = array(),
        array $additionalFields = array()
    ) {
        return $this->getInternalList(
            'region/list',
            'Region',
            array(
                'page' => (int)$page,
                'page_size' => (int)$pageSize,
                'locale_filter' => self::getArray($localeFilter),
                'country_code_filter' => self::getArray($countryCodeFilter),
                'fields' => self::getArray($additionalFields),
            )
        );
    }
563017
protected function get_search_area($areaid) {

        if (isset($this->cachedareas[$areaid]) && $this->cachedareas[$areaid] === false) {
            // We already checked that area and it is not available.
            return false;
        }

        if (!isset($this->cachedareas[$areaid])) {
            // First result that matches this area.

            $this->cachedareas[$areaid] = \core_search\manager::get_search_area($areaid);
            if ($this->cachedareas[$areaid] === false) {
                // The area does not exist or it is not available any more.

                $this->cachedareas[$areaid] = false;
                return false;
            }

            if (!$this->cachedareas[$areaid]->is_enabled()) {
                // We skip the area if it is not enabled.

                // Marking it as false so next time we don' need to check it again.
                $this->cachedareas[$areaid] = false;

                return false;
            }
        }

        return $this->cachedareas[$areaid];
    }
487186
public static function get_categories_with_fields(string $component, string $area, int $itemid) : array {
        global $DB;

        $categories = [];

        $options = [
                'component' => $component,
                'area'      => $area,
                'itemid'    => $itemid
        ];

        $plugins = \core\plugininfo\customfield::get_enabled_plugins();
        list($sqlfields, $params) = $DB->get_in_or_equal(array_keys($plugins), SQL_PARAMS_NAMED, 'param', true, null);

        $fields = 'f.*, ' . join(', ', array_map(function($field) {
                return "c.$field AS category_$field";
        }, array_diff(array_keys(category::properties_definition()), ['usermodified', 'timemodified'])));
        $sql = "SELECT $fields
                  FROM {customfield_category} c
             LEFT JOIN {customfield_field} f ON c.id = f.categoryid AND f.type $sqlfields
                 WHERE c.component = :component AND c.area = :area AND c.itemid = :itemid
              ORDER BY c.sortorder, f.sortorder";
        $fieldsdata = $DB->get_recordset_sql($sql, $options + $params);

        foreach ($fieldsdata as $data) {
            if (!array_key_exists($data->category_id, $categories)) {
                $categoryobj = new \stdClass();
                foreach ($data as $key => $value) {
                    if (preg_match('/^category_(.*)$/', $key, $matches)) {
                        $categoryobj->{$matches[1]} = $value;
                    }
                }
                $category = category_controller::create(0, $categoryobj);
                $categories[$categoryobj->id] = $category;
            } else {
                $category = $categories[$data->categoryid];
            }
            if ($data->id) {
                $fieldobj = new \stdClass();
                foreach ($data as $key => $value) {
                    if (!preg_match('/^category_/', $key)) {
                        $fieldobj->{$key} = $value;
                    }
                }
                $field = field_controller::create(0, $fieldobj, $category);
            }
        }
        $fieldsdata->close();

        return $categories;
    }
1152240
public function getAreaProvidersCollection()
    {
        $collection = new Collection;

        foreach ($this->providers as $model) {
            $area = $this->areaManager->getById($model->area);
            if (is_null($area)) {
                continue;
            }

            $areaProviders = $collection->get($area->getId());
            if ($areaProviders === null) {
                $areaProviders = new AreaProviders($area);
                $areaProviders->addModel($model);
                $collection->put($area->getId(), $areaProviders);
            } else {
                $areaProviders->addModel($model);
            }
        }

        return $collection;
    }
946957
public function getList(array $module)
    {
        $list = array();

        foreach ($this->getScanFolders() as $folder) {
            $files = gplcart_file_scan_recursive("{$module['directory']}/$folder");
            sort($files);
            $list[$folder] = $files;
        }

        $this->hook->attach('module.editor.list', $list);
        return $list;
    }
619247
protected function getSiteFiles()
    {
        $files = array_filter($this->filesystem->allFiles(KATANA_CONTENT_DIR), function (SplFileInfo $file) {
            return $this->filterFile($file);
        });

        $this->appendFiles($files);

        return $files;
    }
1075074
function _getFiles (route) {
  const dir = route[0]
  const prefix = route.splice(1).join('/')

  return _browseDir(dir)
    .map(file => require(file))
    .reduce((acc, routes) => acc.concat(routes), [])
    .map(routes => _normalizeUrl(routes, prefix))
}