Example #1
0
 /**
  * Plugin configuration form. Let user choose which menus he wants
  * to print in the main topbar.
  */
 function settings_form(&$theme_settings_form = array())
 {
     $theme_settings_form['#submit'][] = 'foundation_ui_settings_form_submit';
     $expert = arg(4) == 'expert' ? TRUE : FALSE;
     // drupal_add_js($this->base_theme_path . '/' . $this->vendors_directory . '/jquery/dist/jquery.min.js');
     // drupal_add_js("jQuery(document).ready(function () {
     //  jQuery('#edit-theme-plugin-settings-foundation-ui-primary-color').colorpicker();
     //  alert('ok');
     // })",
     // array('type' => 'inline', 'scope' => 'footer'));
     // form id match exactly foundation settings names.
     $form['row-width'] = array('#type' => 'textfield', '#title' => 'Grid row width', '#default_value' => theme_plugin_get_setting(__CLASS__, 'row-width', '1000px'), '#description' => "Any valid css unit. Note that foundation will try to convert this to rem");
     $form['total-columns'] = array('#access' => $expert, '#type' => 'textfield', '#title' => 'Grid columns number', '#default_value' => theme_plugin_get_setting(__CLASS__, 'total-columns', '12'), '#description' => "Number of columns for the grid. Enable grid viewer plugin to display the grid in your theme.");
     $form['primary-color'] = array('#type' => 'textfield', '#title' => 'Primary color', '#default_value' => theme_plugin_get_setting(__CLASS__, 'primary-color', '#008CBA'), '#description' => 'Any valid css color.');
     $form['secondary-color'] = array('#type' => 'textfield', '#title' => 'Secondary color', '#default_value' => theme_plugin_get_setting(__CLASS__, 'secondary-color', '#e7e7e7'), '#description' => 'Any valid css color.');
     $form['header-font-color'] = array('#type' => 'textfield', '#title' => 'h1, h2, etc... font colors', '#default_value' => theme_plugin_get_setting(__CLASS__, 'header-font-color', '#222'), '#description' => 'Any valid css color.');
     $form['alert-color'] = array('#type' => 'textfield', '#title' => 'Alert colors', '#default_value' => theme_plugin_get_setting(__CLASS__, 'alert-color', '#f04124'), '#description' => 'Any valid css color.');
     $form['success-color'] = array('#type' => 'textfield', '#title' => 'Success colors', '#default_value' => theme_plugin_get_setting(__CLASS__, 'success-color', '#43AC6A'), '#description' => 'Any valid css color.');
     $form['warning-color'] = array('#type' => 'textfield', '#title' => 'Warning colors', '#default_value' => theme_plugin_get_setting(__CLASS__, 'warning-color', '#f08a24'), '#description' => 'Any valid css color.');
     $form['info-color'] = array('#type' => 'textfield', '#title' => 'Info colors', '#default_value' => theme_plugin_get_setting(__CLASS__, 'info-color', '#a0d3e8'), '#description' => 'Any valid css color.');
     $form['ancho-font-color'] = array('#type' => 'textfield', '#title' => 'Links colors', '#default_value' => theme_plugin_get_setting(__CLASS__, 'anchor-font-color', '#008CBA'), '#description' => 'Any valid css color.');
     $form['ancho-font-color-hover'] = array('#type' => 'textfield', '#title' => 'Links colors hover', '#default_value' => theme_plugin_get_setting(__CLASS__, 'anchor-font-color-hover', 'scale-color($primary-color, $lightness: -14%)'), '#description' => 'Any valid css color.');
     $form['expert'] = array('#access' => $expert, '#type' => 'textarea', '#title' => "Write custom valid scss here", '#default_value' => theme_plugin_get_setting(__CLASS__, 'expert', ''), '#description' => 'Free scss for expert.');
     return $form;
 }
Example #2
0
 /**
  * Change dynamically classes according to user defined settings, or using
  * default values if user did not configured anything yet.
  * @param $variables
  */
 function hook_preprocess_page(&$variables)
 {
     $left_only = theme_plugin_get_setting(__CLASS__, 'left_only', $this->left_only);
     $right_only = theme_plugin_get_setting(__CLASS__, 'right_only', $this->right_only);
     $both = theme_plugin_get_setting(__CLASS__, 'both', $this->both);
     $none = theme_plugin_get_setting(__CLASS__, 'none', $this->none);
     // If the two sidebars are present
     if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) {
         $sidebar_first_classes = $sidebar_second_classes = $both['sidebar'];
         $content_classes = $both['content'];
     } elseif (!empty($variables['page']['sidebar_first']) && empty($variables['page']['sidebar_second'])) {
         $sidebar_first_classes = $left_only['sidebar'];
         $sidebar_second_classes = '';
         $content_classes = $left_only['content'];
     } elseif (empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) {
         $sidebar_second_classes = $right_only['sidebar'];
         $sidebar_first_classes = '';
         $content_classes = $right_only['content'];
     } elseif (empty($variables['page']['sidebar_first']) && empty($variables['page']['sidebar_second'])) {
         $sidebar_second_classes = $sidebar_first_classes = $none['sidebar'];
         $content_classes = $none['content'];
     }
     // send our dynamic foundation classes to the page.tpl.php template
     $variables['content_classes'] = $content_classes;
     $variables['sidebar_first_classes'] = $sidebar_first_classes;
     $variables['sidebar_second_classes'] = $sidebar_second_classes;
 }
 /**
  * Fake theme functions to display the grid.
  */
 function theme_grid_viewer($columns)
 {
     $above = theme_plugin_get_setting(__CLASS__, 'display_above_theme', 0);
     $display_gutters = strip_tags(theme_plugin_get_setting(__CLASS__, 'display_gutters', 0));
     $grid_color = strip_tags(theme_plugin_get_setting(__CLASS__, 'grid_color', '#DDD'));
     $columns_css = '';
     if ($display_gutters) {
         $grid_gutters_color = strip_tags(theme_plugin_get_setting(__CLASS__, 'grid_gutters_color', '#EEE'));
         $columns_css = "background : {$grid_gutters_color}";
     }
     $z_index = $above ? '1' : '0';
     $html = array();
     $html[] = '<div style="z-index:' . $z_index . ';position:relative;opacity:0.5" class="row">';
     $html[] = '<div style="position:absolute;top:0;height:100%;width:100%">';
     for ($i = 1; $i <= $columns; $i++) {
         $html[] = '<div style="' . $columns_css . '" class="small-1 columns">';
         $html[] = '<p style="text-align:center;color:white;height:3000px;padding-top:300px;font-weight:bold;background: ' . $grid_color . ';"> ' . $i . '</p>';
         $html[] = '</div>';
     }
     $html[] = '</div>';
     $html[] = '</div>';
     return implode("\r\n", $html);
 }
Example #4
0
 function hook_preprocess_page(&$variables)
 {
     $links_left = menu_tree_output(menu_tree_all_data(theme_plugin_get_setting('foundation_topbar', 'menu_left', 'main-menu')));
     $links_right = menu_tree_output(menu_tree_all_data(theme_plugin_get_setting('foundation_topbar', 'menu_right', 'user-menu')));
     $variables['foundation_topbar'] = theme('foundation_topbar', array('links_left' => $links_left, 'links_right' => $links_right));
 }
        }
        ?>

            <?php 
    }
    ?>
          </ul>
        </section>
      <?php 
}
?>

    </nav>

    <?php 
if (theme_plugin_get_setting('foundation_topbar', 'contain_to_grid')) {
    ?>
  </div>
<?php 
}
?>

  <?php 
if (theme_plugin_get_setting('foundation_topbar', 'sticky')) {
    ?>
</div>
<?php 
}
?>

 /**
  * Make sure theme_plugin_get_settings() works as expected.
  */
 function test_theme_plugin_get_setting()
 {
     // Always do our test on okcdesign rather than default active theme.
     // this if for theme_get_setting function
     $GLOBALS['theme_key'] = 'okcdesign';
     $plugin_id = 'phpunit_test';
     // theme_plugin_get_settings shloud return NULL if setting does not exist.
     $result = theme_plugin_get_setting($plugin_id, 'test');
     $this->assertNull($result);
     // function shloud return default value when settings does not exist.
     $result = theme_plugin_get_setting($plugin_id, 'test', 'default_value');
     $this->assertSame($result, 'default_value');
     $theme_settings = variable_get("theme_okcdesign_settings");
     $theme_settings["theme_plugin_settings_{$plugin_id}"] = array('test' => 'value');
     variable_set("theme_okcdesign_settings", $theme_settings);
     drupal_static_reset('theme_get_setting');
     // function shloud now return "value", fetching from theme settings.
     $result = theme_plugin_get_setting($plugin_id, 'test', 'default_value');
     $this->assertSame($result, 'value');
     // clean settings, remove our test variable.
     $theme_settings = variable_get("theme_okcdesign_settings");
     unset($theme_settings["theme_plugin_settings_{$plugin_id}"]);
     variable_set("theme_okcdesign_settings", $theme_settings);
     drupal_static_reset('theme_get_setting');
     // theme_plugin_get_settings shloud return NULL because setting does not exist anymore.
     $result = theme_plugin_get_setting($plugin_id, 'test');
     $this->assertNull($result);
 }