예제 #1
0
 /**
  * Popup Elements
  *
  * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  * opens a modal window that allows to edit the element properties
  *
  * @return void
  */
 function popup_elements()
 {
     $api = false;
     $owner = "";
     $lists = array();
     //load the api only when the popup gets opened
     if (!empty($_POST) && !empty($_POST['action']) && $_POST['action'] == "avia_ajax_av_mailchimp") {
         $api = new av_mailchimp_api($this->api_key);
         $owner = $api->api_owner();
         if (empty($this->api_key) || !$owner) {
             $this->elements = array(array("name" => __("No Mailchimp API key found", 'avia_framework'), "desc" => __("Please enter a valid Mailchimp API key, otherwise we will not be able to retrieve the lists that your visitors may subscribe to.", 'avia_framework') . '<br/><br/><a target="_blank" href="' . admin_url('admin.php?page=avia#goto_newsletter') . '">' . __("You can enter your API key here", 'avia_framework') . "</a>", "type" => "heading", "description_class" => "av-builder-note av-error"));
             return;
         }
         $api->store_lists();
         $lists = $api->get_list_ids();
         if (!empty($this->api_key) && (empty($lists) || !is_array($lists))) {
             $this->elements = array(array("name" => __("No Mailchimp Lists found", 'avia_framework'), "desc" => __("We could not find any lists that your customers can subscribe to. Please check if the API key you have entered in your Enfold Theme Panel is valid and also check if you have at least one list created on mailchimp", 'avia_framework') . '<br/><br/><a target="_blank" href="' . admin_url('admin.php?page=avia#goto_newsletter') . '">' . __("Check API key here", 'avia_framework') . '</a> | <a target="_blank" href="https://login.mailchimp.com/">' . __("Go to Mailchimp", 'avia_framework') . "</a>", "type" => "heading", "description_class" => "av-builder-note av-error"));
             return;
         }
         $newlist = array();
         foreach ($lists as $key => $list_item) {
             $newlist[$list_item['name']] = $key;
         }
         $lists = $newlist;
         $first = array(__("Select a mailchimp list...", "avia_framework") => '');
         $lists = array_merge($first, $lists);
     }
     //default elements that gets loaded if
     $this->elements = apply_filters('avf_sc_mailchimp_popup_elements', array(array("type" => "tab_container", 'nodescription' => true), array("type" => "tab", "name" => __("Form", 'avia_framework'), 'nodescription' => true), array("name" => __("Mailchimp active", 'avia_framework'), "desc" => __("This installation is connected to the Mailchimp account: ", 'avia_framework') . "'" . $owner . "'<br/><br/>" . "<strong>" . __("Please note:", 'avia_framework') . "</strong> " . __("This element currently only supports basic list subscription with basic form fields (text and dropdowns). Please let us know if you would like to see more advanced features.", 'avia_framework'), "type" => "heading", "description_class" => "av-builder-note av-notice"), array("name" => __("Lists", 'avia_framework'), "desc" => __("Select the list that the user should be added to. The form will be build automatically based on the list that you have set up in mailchimp.", 'avia_framework'), "id" => "list", "type" => "mailchimp_list", "std" => "", "subtype" => $lists, "api" => $api, "std" => ""), array("name" => __("Edit Contact Form Elements", 'avia_framework'), "desc" => __("Once you have selected a list above the available form fields will be displayed here", 'avia_framework') . "<br/>" . "<br/><strong>" . __("Please note:", 'avia_framework') . "</strong>" . "<ul>" . "<li>" . __("You can only hide form fields that are not required", 'avia_framework') . "</li>" . "<li>" . __("Currently only text and dropdown elements are supported properly", 'avia_framework') . "</li>" . "</ul>", "type" => "modal_group", "id" => "content", "modal_title" => __("Edit Form Element", 'avia_framework'), "disable_manual" => true, "class" => "av-automated-inserts", "std" => array(), 'subelements' => array(array("id" => 'id', "std" => '', "type" => "hidden"), array("id" => 'type', "std" => '', "type" => "hidden"), array("id" => 'check', "std" => '', "type" => "hidden"), array("id" => 'options', "std" => '', "type" => "hidden"), array("name" => __("Form Element hidden", 'avia_framework'), "desc" => __("Check if you want to hide this form element", 'avia_framework'), "id" => "disabled", "type" => "checkbox", "std" => "", "required" => array('check', 'equals', '')), array("name" => __("Form Element Label", 'avia_framework'), "desc" => "", "id" => "label", "std" => "", "type" => "input"), array("name" => __("Form Element Width", 'avia_framework'), "desc" => __("Change the width of your elements and let them appear beside each other instead of underneath", 'avia_framework'), "id" => "width", "type" => "select", "std" => "", "no_first" => true, "subtype" => array("Fullwidth" => '', "1/2" => 'element_half', "1/3" => 'element_third', "2/3" => 'element_two_third', "1/4" => 'element_fourth', "3/4" => 'element_three_fourth')))), array("name" => __("Double opt-in?", 'avia_framework'), "desc" => __("Check if you want people to confirm their email address before being subscribed (highly recommended)", 'avia_framework'), "id" => "double_opt_in", "std" => "true", "type" => "checkbox"), array("name" => __("What should happen once the form gets sent?", 'avia_framework'), "desc" => "", "id" => "on_send", "type" => "select", "std" => "text", "no_first" => true, "subtype" => array(__('Display a short message on the same page', 'avia_framework') => '', __('Redirect the user to another page', 'avia_framework') => 'redirect')), array("name" => __("Message Sent label", 'avia_framework'), "desc" => __("What should be displayed once the message is sent?", 'avia_framework'), "id" => "sent", "required" => array('on_send', 'not', 'redirect'), "std" => __("Thank you for subscribing to our newsletter!", 'avia_framework'), "type" => "input"), array("name" => __("Redirect", 'avia_framework'), "desc" => __("To which page do you want the user send to?", 'avia_framework'), "id" => "link", "type" => "linkpicker", "fetchTMPL" => true, "std" => "", "required" => array('on_send', 'equals', 'redirect'), "subtype" => array(__('Set Manually', 'avia_framework') => 'manually', __('Single Entry', 'avia_framework') => 'single'), "std" => ""), array("type" => "close_div", 'nodescription' => true), array("type" => "tab", "name" => __("Form Styling", 'avia_framework'), 'nodescription' => true), array("name" => __("Form Color Scheme", 'avia_framework'), "desc" => __("Select a form color scheme here", 'avia_framework'), "id" => "color", "type" => "select", "std" => "", "subtype" => array(__('Default', 'avia_framework') => '', __('Light transparent', 'avia_framework') => 'av-custom-form-color av-light-form', __('Dark transparent', 'avia_framework') => 'av-custom-form-color av-dark-form')), array("name" => __("Hide Form Labels", 'avia_framework'), "desc" => __("Check if you want to hide form labels above the form elements. The form will instead try to use an inline label (not supported on old browsers)", 'avia_framework'), "id" => "hide_labels", "std" => "", "type" => "checkbox"), array("type" => "close_div", 'nodescription' => true), array("type" => "close_div", 'nodescription' => true)));
 }