public function theme_styleswitcher()
 {
     $output = array('<select id="styleswitcher">');
     $stacks = Stack::get_named_stack('template_stylesheet_with_title');
     foreach ($stacks as $stack) {
         $output[] = '<option value="' . $stack[2] . '">' . $stack[2] . '</option>';
     }
     $output[] = '</select>';
     print implode("\r\n", $output);
 }
Esempio n. 2
0
 public function body_class()
 {
     $classes = array();
     foreach (get_object_vars($this->request) as $key => $value) {
         if ($value) {
             $classes[$key] = $key;
         }
     }
     $classes[] = URL::get_matched_rule()->entire_match;
     $classes = array_unique(array_merge($classes, Stack::get_named_stack('body_class')));
     $classes = Plugins::filter('body_class', $classes, $this);
     echo implode(' ', $classes);
 }
Esempio n. 3
0
 function configure()
 {
     $ui = new FormUI('jsmincdn');
     $scripts = $ui->append('checkboxes', 'scripts', 'jsmincdn__storage', 'Select the scripts that should be served as minimized.');
     $theme = Themes::create();
     Plugins::act('template_header', $theme);
     Plugins::act('template_footer', $theme);
     $options = Stack::get_named_stack('template_header_javascript');
     $options = array_merge($options, Stack::get_named_stack('template_footer_javascript'));
     $options_out = array();
     foreach ($options as $option => $value) {
         if (preg_match('#[a-f0-9]{32}#', $option)) {
             $value = htmlspecialchars(substr($value, 0, 80));
         } else {
             $value = $option;
         }
         $options_out[$option] = $value;
     }
     $scripts->options = $options_out;
     $ui->append('submit', 'submit', 'Submit');
     return $ui;
 }
Esempio n. 4
0
 /**
  * A theme function for outputting CSS classes based on the requested content
  * @param Theme $theme A Theme object instance
  * @param mixed $args Additional classes that should be added to the ones generated
  * @return string The resultant classes
  */
 function theme_body_class($theme, $args = array())
 {
     $body_class = array();
     foreach (get_object_vars($this->request) as $key => $value) {
         if ($value) {
             $body_class[$key] = $key;
         }
     }
     $body_class = array_unique(array_merge($body_class, Stack::get_named_stack('body_class'), Utils::single_array($args)));
     $body_class = Plugins::filter('body_class', $body_class, $theme);
     return implode(' ', $body_class);
 }
 /**
  * Process the stack and replace links to Google hosted Javascript libraries.
  *
  * @param array $stack
  * @param string $stack_name
  * @param $filter
  * @return array
  */
 public function filter_stack_out($stack, $stack_name, $filter)
 {
     if (count($stack) == 0) {
         return $stack;
     }
     // Array of direct links - defaults to latest version
     // TODO: Google doesn't offer a method to programatically determine the available versions, so these are hard-coded.
     $googleHosts = array('jquery' => 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js', 'jqueryui' => 'http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js', 'prototype' => 'http://ajax.googleapis.com/ajax/libs/prototype/1/prototype.js', 'scriptaculous' => 'http://ajax.googleapis.com/ajax/libs/scriptaculous/1/scriptaculous.js', 'mootools' => 'http://ajax.googleapis.com/ajax/libs/mootools/1/mootools-yui-compressed.js', 'dojo' => 'http://ajax.googleapis.com/ajax/libs/dojo/1/dojo/dojo.xd.js', 'swfobject' => 'http://ajax.googleapis.com/ajax/libs/swfobject/2/swfobject.js', 'yui' => 'http://ajax.googleapis.com/ajax/libs/yui/2/build/yuiloader/yuiloader-min.js', 'ext-core' => 'http://ajax.googleapis.com/ajax/libs/ext-core/3/ext-core.js', 'chrome-frame' => 'http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js');
     switch ($stack_name) {
         case 'template_header_javascript':
         case 'template_footer_javascript':
             // First we remove the duplicates that occur in the header stack if we're processing the footer stack - Habari doesn't do this, so we do.  This is all about performance after all.
             if ($stack_name == 'template_footer_javascript') {
                 $header_stack = Stack::get_named_stack('template_header_javascript');
                 $stack = array_diff_key($stack, $header_stack);
             }
             if (Options::get(__CLASS__ . '__direct_link')) {
                 $int = array_intersect_key($googleHosts, $stack);
                 return array_merge($stack, $int);
             } else {
                 // We only need this in the footer if it's not already in the header
                 $newstack['jsapi'] = 'http://www.google.com/jsapi';
                 if ($stack_name == 'template_footer_javascript' && array_intersect_key($googleHosts, $header_stack)) {
                     unset($newstack['jsapi']);
                 }
                 $newstack['jsapi_load'] = '';
                 foreach ($stack as $key => $value) {
                     if (array_key_exists($key, $googleHosts)) {
                         $ver = explode('/', $googleHosts[$key]);
                         $newstack['jsapi_load'] .= 'google.load("' . $key . '", "' . $ver[6] . '");';
                         // This assumes Google keeps a consistent URL structure with the version in the 6th field.
                         unset($stack[$key]);
                         // Remove replaced key from original stack
                     }
                 }
                 return $newstack['jsapi_load'] != '' ? array_merge($newstack, $stack) : $stack;
                 // Merge stacks, putting the Google API calls first.
             }
             break;
         default:
             return $stack;
     }
 }