class Skin in Forena Reports 7.5
Same name and namespace in other branches
- 8 src/Skin.php \Drupal\forena\Skin
Hierarchy
- class \Drupal\forena\Skin
Expanded class hierarchy of Skin
1 string reference to 'Skin'
File
- src/
Skin.php, line 17 - Skin.inc Skinning
Namespace
Drupal\forenaView source
class Skin {
public $name = '';
public $stylesheets = array();
public $scripts = array();
public $default_skin = '';
public $info = '';
/**
* Method constructor.
*/
public function __construct() {
$this->default_skin = variable_get('forena_default_form', 'default_skin');
}
/**
* Add CSS Files
* @param $type
* @param $sheet
*/
public function addCSS($type, $sheet) {
if (strpos($sheet, 'http:') === 0 || strpos($sheet, 'https:') === 0) {
$this->stylesheets[$type][] = $sheet;
}
elseif (Frx::File()
->exists($sheet)) {
$this->stylesheets[$type][] = Frx::File()
->path($sheet);
}
elseif (file_exists($sheet)) {
$this->stylesheets[$type][] = $sheet;
}
}
/**
*
* @param unknown_type $script
*/
public function addJS($script) {
if (strpos($script, 'http:') === 0 || strpos($script, 'https:') === 0) {
$this->scripts[] = $script;
}
elseif (Frx::File()
->exists($script)) {
$this->scripts[] = Frx::File()
->path($script);
}
elseif (file_exists('sites/all/libraries/' . $script)) {
$this->scripts[] = 'sites/all/libraries/' . $script;
}
elseif (file_exists($script)) {
$this->scripts[] = $script;
}
}
/**
* Load the skin based on the name.
* @param $name path/name of skin.
*/
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;
}
/**
* Adds on report specific skin files to
* @param $name name of report to add.
*/
public function loadSkinFiles($name) {
$this
->addCSS('all', $name . '.css');
foreach (Frx::Menu()->doc_formats as $ext) {
$this
->addCSS($ext, $name . '-' . $ext . '.css');
}
$this
->addJS($name . '.js');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Skin:: |
public | property | ||
Skin:: |
public | property | ||
Skin:: |
public | property | ||
Skin:: |
public | property | ||
Skin:: |
public | property | ||
Skin:: |
public | function | Add CSS Files | |
Skin:: |
public | function | ||
Skin:: |
public | function | Load the skin based on the name. | |
Skin:: |
public | function | Adds on report specific skin files to | |
Skin:: |
public | function | Method constructor. |