コード例 #1
0
 function get_form()
 {
     $form = $this->content;
     //email fields
     $form = preg_replace('/\\[email( "([^"]+)")?\\]/i', '<input id="sailthru-email-' . $this->id . '" type="text" class="required $2" />', $form);
     //first name
     $form = preg_replace('/\\[fname(\\*?)( "([^"]+)")?\\]/i', '<input id="sailthru-fname-' . $this->id . '" type="text" class="$1$3" />', $form);
     //last name
     $form = preg_replace('/\\[lname(\\*?)( "([^"]+)")?\\]/i', '<input id="sailthru-lname-' . $this->id . '" type="text" class="$1$3" />', $form);
     //submit
     $form = preg_replace('/\\[submit "([^"]+)"( "([^"]+)")?\\]/i', '<input id="sailthru-submit-' . $this->id . '" onclick="return false;" type="submit" class="$3" value="$1" />&nbsp;&nbsp;&nbsp;<img id="sailthru_loader-' . $this->id . '" src="' . Sailthru::get_plugin_url() . '/loading.gif" style="display: none;"/>', $form);
     //each list
     $lists = sailthru_form::get_all_lists();
     foreach ($lists as $id => $list) {
         $form = preg_replace("/\\[optin-{$id}( \"([^\"]+)\")?\\]/i", "<label class=\"\$2\"><input checked=\"checked\" type=\"checkbox\" value=\"true\" id=\"sailthru-optin-{$this->id}-{$id}\" /> {$list}</label>", $form);
     }
     //replace the asterisks with "required"
     //remove empty class=""
     $form = str_replace(array('class="*', ' class=""'), array('class="required ', ''), $form);
     $form .= '<input type="hidden" id="sailthru_plugin_url" value="' . Sailthru::get_plugin_path() . '" />';
     $form = "<form id=\"sailthru-{$this->id}\" class=\"sailthru-form\">{$form}</form>";
     return $form;
 }
コード例 #2
0
						</table>					
					</form>
				</p>
			<?php 
} elseif ($action == 'forms') {
    $sailthru_forms = sailthru_form::get_forms();
    ?>
				Edit Forms | <a href="options-general.php?page=sailthru&action=blast">Send an Email Blast</a>| <a href="options-general.php?page=sailthru&action=options">General Options</a> | <a href="options-general.php?page=sailthru&action=datafeeds">Manage Datafeeds</a>
			<?php 
    if (isset($_GET['form_id']) && $_GET['form_id']) {
        $form_id = $_GET['form_id'] == 'new' ? false : $_GET['form_id'];
    } else {
        $form_id = false;
    }
    try {
        $form = new sailthru_form($form_id);
    } catch (Exception $e) {
        echo '<br />';
        echo '<span style="color: red; font-weight: bold;">';
        echo "Error: {$e->getMessage()}";
        echo '</span>';
    }
    if (isset($_POST['form_content'])) {
        $errors = array();
        if (!isset($_POST['form_name']) || !strlen($_POST['form_name'])) {
            $errors[] = 'You must provide a name for the form.';
        }
        if (!preg_match_all('/\\[email[^\\]]*[\\]]/i', $_POST['form_content'], $matches)) {
            $errors[] = 'You must include an email field in your form.';
        }
        if (!preg_match_all('/\\[submit[^\\]]+[\\]]/i', $_POST['form_content'], $matches)) {
コード例 #3
0
 function get_sailthru_form($form_id)
 {
     $sailthru_forms = sailthru_form::get_forms();
     if (isset($sailthru_forms[$form_id])) {
         $form = new sailthru_form($form_id);
         return $form->get_form();
     }
     return '';
 }