コード例 #1
0
ファイル: subscribers.php プロジェクト: selectSIFISO/.comsite
    function add($data = false)
    {
        $this->buttonsave = __('Save', WYSIJA);
        if (!$data['user'] || isset($this->add)) {
            $this->buttonsave = __('Add Subscriber', WYSIJA);
        }
        $formid = 'wysija-' . $_REQUEST['action'];
        ?>
	<form name="<?php 
        echo $formid;
        ?>
" method="post" id="<?php 
        echo $formid;
        ?>
" action="" class="form-valid">

	    <table class="form-table">
		<tbody>
		    <tr>
			<th scope="row">
			    <label for="email"><?php 
        _e('Email', WYSIJA);
        ?>
</label>
			</th>
			<td>
			    <input type="text" size="40" class="validate[required,custom[email]]" id="email" value="<?php 
        if ($data['user']) {
            echo esc_attr($data['user']['details']['email']);
        }
        ?>
" name="wysija[user][email]" />
			</td>
		    </tr>

		    <tr>
			<th scope="row">
			    <label for="fname"><?php 
        _e('First name', WYSIJA);
        ?>
</label>
			</th>
			<td>
			    <input type="text" size="40" id="fname" value="<?php 
        if ($data['user']) {
            echo esc_attr($data['user']['details']['firstname']);
        }
        ?>
" name="wysija[user][firstname]" />
			</td>
		    </tr>

		    <tr>
			<th scope="row">
			    <label for="lname"><?php 
        _e('Last name', WYSIJA);
        ?>
</label>
			</th>
			<td>
			    <input type="text" size="40" id="lname" value="<?php 
        if ($data['user']) {
            echo esc_attr($data['user']['details']['lastname']);
        }
        ?>
" name="wysija[user][lastname]" />
			</td>
		    </tr>
		    <tr>
			<th scope="row">
			    <label for="user-status" ><?php 
        _e('Status', WYSIJA);
        ?>
</label>
			</th>
			<td>
			    <?php 
        $form_obj = WYSIJA::get('forms', 'helper');
        $user_status = 1;
        $config = WYSIJA::get('config', 'model');
        if ($config->getValue("confirm_dbleoptin")) {
            $statusddp = array('1' => __('Subscribed', WYSIJA), '0' => __('Unconfirmed', WYSIJA), '-1' => __('Unsubscribed', WYSIJA));
            if ($data['user']) {
                $user_status = $data['user']['details']['status'];
            }
        } else {
            $statusddp = array('1' => __('Subscribed', WYSIJA), '-1' => __('Unsubscribed', WYSIJA));
            if ($data['user']) {
                if ((int) $data['user']['details']['status'] == 0) {
                    $user_status = 1;
                } else {
                    $user_status = $data['user']['details']['status'];
                }
            }
        }
        echo "<p>" . $form_obj->radios(array('id' => 'user-status', 'name' => 'wysija[user][status]'), $statusddp, $user_status, ' class="validate[required]" ') . "</p>";
        ?>
			</td>
		    </tr>
		    <tr>
			<th scope="row">
			    <label for="lists" class="title"><?php 
        _e('Lists', WYSIJA);
        ?>
</label>

			</th>
			<td>
			    <?php 
        $field_html = '';
        $field = 'list';
        $valuefield = array();
        if ($data['user'] && isset($data['user']['lists'])) {
            foreach ($data['user']['lists'] as $list) {
                $valuefield[$list['list_id']] = $list;
            }
        }
        $_display_style = 2;
        // 1 = 1 column, 2 = float left
        usort($data['list'], array($this, 'sort_by_name'));
        foreach ($data['list'] as $list) {
            $checked = false;
            $extra_checkbox = $hidden_field = '';
            if (isset($valuefield[$list['list_id']])) {
                //if the subscriber has this list and is not unsubed then we check the checkbox
                if ($valuefield[$list['list_id']]['unsub_date'] <= 0) {
                    $checked = true;
                } else {
                    //we keep a reference of the list to which we are unsubscribed
                    $hidden_field = $form_obj->hidden(array('id' => $field . $list['list_id'], 'name' => 'wysija[user_list][unsub_list][]', 'class' => 'checkboxx'), $list['list_id']);
                    $hidden_field .= ' / <span class="wysija-unsubscribed-on"> ' . sprintf(__('Unsubscribed on %1$s', WYSIJA), date('D, j M Y H:i:s', $valuefield[$list['list_id']]['unsub_date'])) . '</span>';
                }
            }
            $checkout_params = array('id' => $field . $list['list_id'], 'name' => "wysija[user_list][list_id][]", 'class' => '');
            $checkbox = $form_obj->checkbox($checkout_params, $list['list_id'], $checked, $extra_checkbox) . "<label for='list{$list['list_id']}'>{$list['name']}</label>";
            if ($_display_style == 1) {
                $field_html .= '<p><label for="' . $field . $list['list_id'] . '">';
                $field_html .= $checkbox;
                $field_html .= $hidden_field;
                $field_html .= '</label></p>';
            } else {
                $field_html .= '<p class="labelcheck">';
                $field_html .= $checkbox;
                $field_html .= $hidden_field;
                $field_html .= '</p>';
            }
        }
        echo $field_html;
        ?>
			</td>
		    </tr>
			<?php 
        /*
         Custom Fields.
        */
        echo WJ_FieldRender::render_all($data['user']['details']['user_id']);
        ?>
		    <tr class='submit_row'>
			<td colspan='2'>
	<?php 
        $this->secure(array('action' => "save", 'id' => $data['user']['details']['user_id']));
        ?>
			    <input type="hidden" name="wysija[user][user_id]" id="user_id" value="<?php 
        echo esc_attr($data['user']['details']['user_id']);
        ?>
" />
			    <input type="hidden" value="save" name="action" />
			    <input type="submit" value="<?php 
        echo esc_attr($this->buttonsave);
        ?>
" class="button-primary wysija">
			</td>
		    </tr>
		</tbody>
	    </table>
	</form>
	<?php 
    }
コード例 #2
0
ファイル: confirm.php プロジェクト: christocmp/bingopaws
 /**
  * In that view we put all the content in a string because if we don't we won't be able to return it in the right place of the page
  * ob_start can't be used because of the other plugins possible conflicts
  * @param type $data
  * @return string
  */
 function subscriptions($data)
 {
     $this->addScripts(false);
     $content = $this->messages();
     $formObj = WYSIJA::get('forms', 'helper');
     $content .= '<form id="wysija-subscriptions" method="post" action="#wysija-subscriptions" class="form-valid">';
     $content .= '<table class="form-table">
             <tbody>';
     //user details */
     //do not show the email input if the subscriber is a wordPress user
     $configm = WYSIJA::get('config', 'model');
     $synchwp = $configm->getValue('importwp_list_id');
     $iswpsynched = false;
     foreach ($data['user']['lists'] as $listdt) {
         if ($listdt['list_id'] == $synchwp) {
             $iswpsynched = true;
         }
     }
     if (!$iswpsynched) {
         $content .= '<tr>
             <th scope="row">
                 <label for="email">' . __('Email', WYSIJA) . '</label>
             </th>
             <td>
                 <input type="text" size="40" class="validate[required,custom[email]]" id="email" value="' . esc_attr($data['user']['details']['email']) . '" name="wysija[user][email]" />
             </td>
         </tr>';
     }
     $content .= '<tr>
         <th scope="row">
             <label for="fname">' . __('First name', WYSIJA) . '</label>
         </th>
         <td>
             <input type="text" size="40" id="fname" value="' . esc_attr($data['user']['details']['firstname']) . '" name="wysija[user][firstname]" />
         </td>
     </tr>';
     $content .= '<tr>
         <th scope="row">
             <label for="lname">' . __('Last name', WYSIJA) . '</label>
         </th>
         <td>
             <input type="text" size="40" id="lname" value="' . esc_attr($data['user']['details']['lastname']) . '" name="wysija[user][lastname]" />
         </td>
     </tr>';
     $content .= '<tr>
         <th scope="row">
             <label for="status">' . __('Status', WYSIJA) . '</label>
         </th>
         <td>
             ' . $formObj->radios(array('id' => 'status', 'name' => 'wysija[user][status]'), array('-1' => ' ' . __('Unsubscribed', WYSIJA) . ' ', '1' => ' ' . __('Subscribed', WYSIJA) . ' '), $data['user']['details']['status'], ' class="validate[required]" ') . '
         </td>
     </tr>';
     /*
     Custom Fields.
     */
     $content .= WJ_FieldRender::render_all($data['user']['details']['user_id']);
     //list subscriptions */
     if ($data['list']) {
         $content .= '<tr></tr><tr>
             <th scope="row" colspan="2">';
         $content .= '<h3>' . __('Your lists', WYSIJA) . '</h3>';
         $field = "lists-";
         $content .= '</th>';
         $fieldHTML = '';
         $field = 'list';
         $valuefield = array();
         foreach ($data['user']['lists'] as $list) {
             $valuefield[$list['list_id']] = $list;
         }
         $fieldHTML = '';
         $field = 'list';
         $valuefield = array();
         if ($data['user']) {
             foreach ($data['user']['lists'] as $list) {
                 $valuefield[$list['list_id']] = $list;
             }
         }
         $formObj = WYSIJA::get('forms', 'helper');
         foreach ($data['list'] as $list) {
             $checked = false;
             $extratext = $extraCheckbox = $hiddenField = '';
             if (isset($valuefield[$list['list_id']])) {
                 //if the subscriber has this list and is not unsubed then we check the checkbox
                 if ($valuefield[$list['list_id']]['unsub_date'] <= 0) {
                     $checked = true;
                 } else {
                     //we keep a reference of the list to which we are unsubscribed
                     $hiddenField = $formObj->hidden(array('id' => $field . $list['list_id'], 'name' => "wysija[user_list][unsub_list][]", 'class' => 'checkboxx'), $list['list_id']);
                     $hiddenField .= ' / <span class="wysija-unsubscribed-on">' . sprintf(__('Unsubscribed on %1$s', WYSIJA), date_i18n(get_option('date_format'), $valuefield[$list['list_id']]['unsub_date'])) . '</span>';
                 }
             }
             $labelHTML = '<label for="' . $field . $list['list_id'] . '">' . $list['name'] . '</label>';
             $fieldHTML = $formObj->checkbox(array('id' => $field . $list['list_id'], 'name' => "wysija[user_list][list_id][]", 'class' => 'checkboxx'), $list['list_id'], $checked, $extraCheckbox) . $labelHTML;
             $fieldHTML .= $hiddenField;
             $content .= '<tr><td colspan="2">' . $fieldHTML . '</td></tr>';
         }
     }
     $content .= '</tbody></table>';
     $content .= '<p class="submit">
                     ' . $this->secure(array('controller' => "confirm", 'action' => "save", 'id' => $data['user']['details']['user_id']), false, false) . '
                     <input type="hidden" name="wysija[user][user_id]" id="user_id" value="' . esc_attr($data['user']['details']['user_id']) . '" />
                    <input type="hidden" name="id" id="user_id2" value="' . esc_attr($data['user']['details']['user_id']) . '" />
                     <input type="hidden" value="save" name="action" />
                     <input type="submit" value="' . esc_attr(__('Save', WYSIJA)) . '" class="button-primary wysija">
                 </p>';
     $content .= '</form>';
     return $content;
 }