/**
  * Adds al the elements to the page.
  * I took this out of the factory so that it's done only if the page is clicked
  */
 private function add_renderables_to_page()
 {
     // These are the tabs
     $tabs_ids_description = array('general' => __('General', AI1EC_PLUGIN_NAME), 'table' => __('Tables', AI1EC_PLUGIN_NAME), 'buttons' => __('Buttons', AI1EC_PLUGIN_NAME), 'forms' => __('Forms', AI1EC_PLUGIN_NAME), 'calendar' => __('Calendar general', AI1EC_PLUGIN_NAME), 'posterboard' => __('Posterboard view', AI1EC_PLUGIN_NAME), 'stream' => __('Stream view', AI1EC_PLUGIN_NAME), 'month' => __('Month/week/day view', AI1EC_PLUGIN_NAME), 'agenda' => __('Agenda view', AI1EC_PLUGIN_NAME));
     // Create the tab layout
     $bootstrap_tabs_layout = Ai1ec_Helper_Factory::create_bootstrap_tabs_layout_instance();
     $bootstrap_tabs_layout->set_layout('left');
     $less_variables = Ai1ec_Lessphp_Controller::get_saved_variables(Ai1ec_Adapters_Factory::create_db_adapter_instance());
     // Inizialize the array of tabs that will be added to the layout
     $bootstrap_tabs_to_add = array();
     // initialize the array of tab bodyes that will be added to the tabs
     $tabs_bodies = array();
     foreach ($tabs_ids_description as $id => $description) {
         $bootstrap_tabs_to_add["ai1ec-{$id}"] = Ai1ec_Helper_Factory::create_bootstrap_tab_instance($id, $description);
         $bootstrap_tabs_to_add["ai1ec-{$id}"]->add_class('form-horizontal');
         // create the main div that will hold all the variables
         $div = Ai1ec_Helper_Factory::create_generic_html_tag('div');
         $tabs_bodies["ai1ec-{$id}"] = $div;
     }
     foreach ($less_variables as $variable_id => $variable_attributes) {
         $variable_attributes['id'] = $variable_id;
         $less_variable = Ai1ec_Less_Factory::create_less_variable($variable_attributes['type'], $variable_attributes);
         $tabs_bodies["ai1ec-{$variable_attributes['tab']}"]->add_renderable_children($less_variable);
     }
     foreach ($tabs_bodies as $tab => $div) {
         $bootstrap_tabs_to_add[$tab]->add_renderable_children($div);
     }
     foreach ($bootstrap_tabs_to_add as $tab) {
         $bootstrap_tabs_layout->add_renderable_children($tab);
     }
     $this->add_renderable_children($bootstrap_tabs_layout);
     $input = Ai1ec_Helper_Factory::create_input_instance();
     $input->set_type('submit');
     $input->set_value(__('Save Options', AI1EC_PLUGIN_NAME));
     $input->set_name(Ai1ec_Less_Variables_Editing_Page::FORM_SUBMIT_NAME);
     $input->add_class("button-primary");
     $reset_theme = Ai1ec_Helper_Factory::create_input_instance();
     $reset_theme->set_type('submit');
     $reset_theme->set_value(__('Reset to defaults', AI1EC_PLUGIN_NAME));
     $reset_theme->set_name(Ai1ec_Less_Variables_Editing_Page::FORM_SUBMIT_RESET_THEME);
     $reset_theme->add_class("button");
     $reset_theme->set_id('ai1ec-reset-variables');
     $this->add_renderable_children($input);
     $this->add_renderable_children($reset_theme);
 }
 /**
  * create_cache_strategy_instance method
  *
  * Method to instantiate new cache strategy object
  *
  * @param string $cache_directory Cache directory to use
  * @param bool   $skip_small_bits Set to true, to ignore small entities
  *                                cache engines, as APC [optional=false]
  *
  * @return Ai1ec_Cache_Strategy Instantiated writer
  */
 public static function create_cache_strategy_instance($cache_directory = NULL, $skip_small_bits = false)
 {
     $engine = NULL;
     $name = '';
     if (true !== $skip_small_bits && Ai1ec_Apc_Cache::is_available()) {
         $engine = new Ai1ec_Apc_Cache();
         $name = 'apc';
     } else {
         if (NULL !== $cache_directory && self::_is_cache_dir_writable($cache_directory)) {
             $engine = new Ai1ec_File_Cache($cache_directory);
             $name = 'file';
         } else {
             if (true !== $skip_small_bits) {
                 $engine = new Ai1ec_Db_Cache(Ai1ec_Adapters_Factory::create_db_adapter_instance());
                 $name = 'db';
             } else {
                 $engine = new Ai1ec_Void_Cache();
                 $name = 'void';
             }
         }
     }
     $engine->inject_logger(Logger::getLogger('cache.' . $name));
     return $engine;
 }
 /**
  * @param string $cache_directory
  * @return Ai1ec_Cache_Strategy
  */
 public static function create_cache_startegy_instance($cache_directory = null)
 {
     $is_cache_directory_writable = false;
     if (null !== $cache_directory) {
         if (!isset(self::$cache_directories[$cache_directory])) {
             self::$cache_directories[$cache_directory] = Ai1ec_Filesystem_Utility::is_writable($cache_directory);
         }
         $is_cache_directory_writable = self::$cache_directories[$cache_directory];
     }
     $is_apc_installed = function_exists('apc_store') && function_exists('apc_fetch') && ini_get('apc.enabled');
     $sapi_type = php_sapi_name();
     if (substr($sapi_type, 0, 3) === 'cgi' || substr($sapi_type, -3, 3) === 'cgi') {
         $is_apc_installed = false;
     }
     if ($is_apc_installed) {
         return new Ai1ec_Apc_Cache();
     } else {
         if ($is_cache_directory_writable) {
             return new Ai1ec_File_Cache($cache_directory);
         } else {
             return new Ai1ec_Db_Cache(Ai1ec_Adapters_Factory::create_db_adapter_instance());
         }
     }
 }
 public function __construct()
 {
     $this->template_adapter = Ai1ec_Adapters_Factory::create_template_adapter_instance();
 }
 /**
  * Create the page
  *
  * @return Ai1ec_Less_Variables_Editing_Page
  */
 public static function create_less_variables_editing_page_instance()
 {
     $less_variable_page = new Ai1ec_Less_Variables_Editing_Page(Ai1ec_Adapters_Factory::create_menu_adapter_instance(), Ai1ec_Helper_Factory::create_view_helper_instance(), Ai1ec_Adapters_Factory::create_template_adapter_instance());
     return $less_variable_page;
 }
 /**
  * @param string $active_theme_path
  * @param string $default_theme_path
  * @return Ai1ec_Css_Controller
  */
 public static function create_css_controller_instance()
 {
     $aie1c_admin_notices_helper = Ai1ec_Admin_Notices_Helper::get_instance();
     $db_adapter = Ai1ec_Adapters_Factory::create_db_adapter_instance();
     $persistence_context = Ai1ec_Strategies_Factory::create_persistence_context(Ai1ec_Css_Controller::KEY_FOR_PERSISTANCE, AI1EC_CACHE_PATH);
     $lessphp_controller = self::create_lessphp_controller();
     $controller = new Ai1ec_Css_Controller($persistence_context, $lessphp_controller, $db_adapter, self::$preview_mode, Ai1ec_Adapters_Factory::create_template_adapter_instance());
     $controller->set_admin_notices_helper($aie1c_admin_notices_helper);
     return $controller;
 }
 /**
  * Get instance of query manager class
  *
  * @return Ai1ec_Adapter_Query_Interface
  */
 public static function query_manager()
 {
     return Ai1ec_Adapters_Factory::create_query_adapter_instance();
 }