You are here

public function FrxSkin::load in Forena Reports 7.4

Same name and namespace in other branches
  1. 7.3 FrxSkin.inc \FrxSkin::load()

Load the skin based on the name.

Parameters

$name path/name of skin.:

File

./FrxSkin.inc, line 70
FrxSkin.inc Skinning

Class

FrxSkin
@file FrxSkin.inc Skinning

Code

public function load($name) {
  if (!$name) {
    $name = $this->default_skin;
  }
  if ($this->name != $name) {

    //Check for an info file
    if (Frx::File()
      ->exists($name . '.skinfo')) {

      // Parse the info file using drupals stock version
      $this->info = drupal_parse_info_format(Frx::File()
        ->contents($name . '.skinfo'));
      $path_info = Frx::File()
        ->pathinfo($name . '.skinfo');
      $this->info['base_path'] = base_path() . $path_info['dirname'];
      $this->info['dir'] = base_path() . $path_info['dirname'];
      Frx::Data()
        ->setContext('skin', $this->info);
      if (isset($this->info['stylesheets'])) {
        foreach ($this->info['stylesheets'] as $type => $sheets) {
          if ($sheets) {
            foreach ($sheets as $sheet) {
              $this
                ->addCSS($type, $sheet);
            }
          }
        }
      }

      // Add the javascript files
      if (@is_array($this->info['scripts'])) {
        foreach ($this->info['scripts'] as $script) {
          $this
            ->addJS($script);
        }
      }
    }
    else {
      $this->info = array(
        'name' => $name,
      );

      //Perform the legacy detection of css and pdf files.
      $this
        ->addCSS('all', $name . '.css');
      $this
        ->addJS($name . '.js');
    }
    $this->name = $name;
  }
  return $this;
}