Пример #1
0
 /**
  * Renders the settings lightbox for a module.
  *
  * @since 1.0
  * @param string $node_id The module node ID.
  * @param string $type The type of module.
  * @param string $parent_id The parent column node ID.
  * @param bool $return Whether to return the layout data or echo it.
  * @return void
  */
 public static function render_module_settings($node_id = null, $type = null, $parent_id = null, $return = false)
 {
     $post_data = FLBuilderModel::get_post_data();
     $node_id = isset($post_data['node_id']) ? $post_data['node_id'] : $node_id;
     $type = isset($post_data['type']) ? $post_data['type'] : $type;
     $parent_id = isset($post_data['parent_id']) ? $post_data['parent_id'] : $parent_id;
     $buttons = array();
     // Get the module and settings.
     if ($node_id) {
         $module = FLBuilderModel::get_module($node_id);
         $settings = $module->settings;
     } else {
         $module = FLBuilderModel::$modules[$type];
         $settings = FLBuilderModel::get_module_defaults($type);
     }
     // Is this module global?
     $global = FLBuilderModel::is_node_global($module);
     // Add the Save As button?
     if (!$global && !FLBuilderModel::is_post_node_template() && FLBuilderModel::node_templates_enabled()) {
         $buttons[] = 'save-as';
     }
     // Render the settings CSS/JS.
     if (file_exists($module->dir . 'css/settings.css')) {
         echo '<link class="fl-builder-settings-css" rel="stylesheet" href="' . $module->url . 'css/settings.css" />';
     }
     if (file_exists($module->dir . 'js/settings.js')) {
         echo '<script class="fl-builder-settings-js" src="' . $module->url . 'js/settings.js"></script>';
     }
     // Render the form.
     echo self::render_settings(array('class' => 'fl-builder-module-settings fl-builder-' . $type . '-settings', 'attrs' => 'data-node="' . $node_id . '" data-parent="' . $parent_id . '" data-type="' . $type . '"', 'title' => sprintf(_x('%s Settings', '%s stands for module name.', 'fl-builder'), $module->name), 'badges' => $global ? array('global' => _x('Global', 'Indicator for global node templates.', 'fl-builder')) : array(), 'tabs' => $module->form, 'buttons' => $buttons), $settings, $return);
 }
Пример #2
0
 /**
  * Renders the settings lightbox for a module.
  *
  * @since 1.0
  * @param string $node_id The module node ID.
  * @param string $type The type of module.
  * @param string $parent_id The parent column node ID.
  * @param bool $render_state Whether to render the preview state or not.
  * @return array
  */
 public static function render_module_settings($node_id = null, $type = null, $parent_id = null, $render_state = true)
 {
     $buttons = array();
     $assets = '';
     // Get the module and settings.
     if ($node_id) {
         $module = FLBuilderModel::get_module($node_id);
         $settings = $module->settings;
     } else {
         $module = FLBuilderModel::$modules[$type];
         $settings = FLBuilderModel::get_module_defaults($type);
     }
     // Is this module global?
     $global = FLBuilderModel::is_node_global($module);
     // Add the Save As button?
     if (!$global && !FLBuilderModel::is_post_node_template() && FLBuilderModel::node_templates_enabled()) {
         $buttons[] = 'save-as';
     }
     // Render the settings CSS/JS assets.
     if (file_exists($module->dir . 'css/settings.css')) {
         $assets .= '<link class="fl-builder-settings-css" rel="stylesheet" href="' . $module->url . 'css/settings.css" />';
     }
     if (file_exists($module->dir . 'js/settings.js')) {
         $assets .= '<script class="fl-builder-settings-js" src="' . $module->url . 'js/settings.js"></script>';
     }
     // Render the form.
     $rendered_settings = self::render_settings(array('class' => 'fl-builder-module-settings fl-builder-' . $type . '-settings', 'attrs' => 'data-node="' . $node_id . '" data-parent="' . $parent_id . '" data-type="' . $type . '"', 'title' => sprintf(_x('%s Settings', '%s stands for module name.', 'fl-builder'), $module->name), 'badges' => $global ? array('global' => _x('Global', 'Indicator for global node templates.', 'fl-builder')) : array(), 'tabs' => $module->form, 'buttons' => $buttons), $settings);
     // Return the HTML.
     return array('settings' => $assets . $rendered_settings['html'], 'state' => $render_state ? FLBuilderAJAXLayout::render($node_id) : null);
 }