You are here

public function OSMTemplate::createCSS in MediaFront 6

Same name and namespace in other branches
  1. 6.2 players/osmplayer/player/OSMTemplate.php \OSMTemplate::createCSS()
  2. 7 players/osmplayer/player/OSMTemplate.php \OSMTemplate::createCSS()

Create the CSS files for this media player. This will dynamically rename all the id's and class names within the master CSS files ( theme and template ), and then create a cached version of them within the css folder.

2 calls to OSMTemplate::createCSS()
OSMTemplate::getCSSFiles in players/osmplayer/player/OSMTemplate.php
Get an array of the CSS files for this player.
OSMTemplate::resetCSS in players/osmplayer/player/OSMTemplate.php
Resets all generated CSS files.

File

players/osmplayer/player/OSMTemplate.php, line 284

Class

OSMTemplate
Copyright (c) 2010 Alethia Inc, http://www.alethia-inc.com Developed by Travis Tidwell | travist at alethia-inc.com

Code

public function createCSS() {

  // This is only necessary if they are using Theme Roller.
  if ($this->settings['generateCSS']) {

    // Store the CSS directory for later usage.
    $dir = $this->css_dir ? $this->css_dir : dirname(__FILE__) . '/css';

    // Make sure this directory exists.
    if (!is_dir($dir)) {

      // Create the directory.
      mkdir($dir, 0777, true);
    }

    // Now make sure the directory has the right permissions.
    @chmod($dir, 0777);

    // Store the to path and to css.
    $to_path = $dir . '/' . $this->playerSettings['id'];
    $to_css = $to_path . '.css';

    // Setup the files array.
    $files = array();
    $files[$to_css] = array();
    if ($this->settings['cssFiles']['theme']) {
      $files[$to_css][] = $this->settings['cssFiles']['theme'];
    }
    if ($this->settings['cssFiles']['template']) {
      $files[$to_css][] = $this->settings['cssFiles']['template'];
    }
    if ($this->settings['cssFiles']['template_ie']) {
      $files[$to_path . '_ie.css'] = array(
        $this->settings['cssFiles']['template_ie'],
      );
    }

    // Iterate through all of our css files we need to create.
    foreach ($files as $file => $contents) {

      // Now open up the new css file.
      $handle = fopen($file, 'a+');
      if ($handle) {

        // Iterate through all the files that will be combined to
        // create this css file.
        foreach ($contents as $content) {
          if ($content) {

            // Write to the css file.
            $this
              ->writeCSS($content, $handle);
          }
        }

        // Close the file.
        fclose($handle);
      }

      // Now set the file permissions to 775.
      @chmod($file, 0777);
    }
  }
}