当前位置: 首页>>代码示例>>PHP>>正文


PHP MS_Model_Membership::get_types方法代码示例

本文整理汇总了PHP中MS_Model_Membership::get_types方法的典型用法代码示例。如果您正苦于以下问题:PHP MS_Model_Membership::get_types方法的具体用法?PHP MS_Model_Membership::get_types怎么用?PHP MS_Model_Membership::get_types使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MS_Model_Membership的用法示例。


在下文中一共展示了MS_Model_Membership::get_types方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepare_fields

 /**
  * Prepare the HTML fields that can be displayed
  *
  * @since  1.0.0
  *
  * @return array
  */
 protected function prepare_fields($data)
 {
     // List of known Membership types; used to display the nice-name
     $ms_types = MS_Model_Membership::get_types();
     $ms_paytypes = MS_Model_Membership::get_payment_types();
     // Prepare the "Memberships" table
     $memberships = array(array(__('Membership name', 'membership2'), __('Membership Type', 'membership2'), __('Payment Type', 'membership2'), __('Description', 'membership2')));
     foreach ($data->memberships as $item) {
         if (!isset($ms_types[$item->type])) {
             $item->type = MS_Model_Membership::TYPE_STANDARD;
         }
         switch ($item->pay_type) {
             case 'recurring':
                 $payment_type = MS_Model_Membership::PAYMENT_TYPE_RECURRING;
                 break;
             case 'finite':
                 $payment_type = MS_Model_Membership::PAYMENT_TYPE_FINITE;
                 break;
             case 'date':
                 $payment_type = MS_Model_Membership::PAYMENT_TYPE_DATE_RANGE;
                 break;
             default:
                 $payment_type = MS_Model_Membership::PAYMENT_TYPE_PERMANENT;
                 break;
         }
         $memberships[] = array($item->name, $ms_types[$item->type], $ms_paytypes[$payment_type], $item->description);
     }
     // Prepare the "Members" table
     $members = array(array(__('Username', 'membership2'), __('Email', 'membership2'), __('Subscriptions', 'membership2'), __('Invoices', 'membership2')));
     foreach ($data->members as $item) {
         $inv_count = 0;
         if (isset($item->subscriptions) && is_array($item->subscriptions)) {
             foreach ($item->subscriptions as $registration) {
                 $inv_count += count($registration->invoices);
             }
         }
         $members[] = array($item->username, $item->email, count($item->subscriptions), $inv_count);
     }
     $settings = array();
     foreach ($data->settings as $setting => $value) {
         switch ($setting) {
             case 'addons':
                 $model = MS_Factory::load('MS_Model_Addon');
                 $list = $model->get_addon_list();
                 $code = '';
                 foreach ($value as $addon => $state) {
                     if ($state) {
                         $code .= __('Activate: ', 'membership2');
                     } else {
                         $code .= __('Dectivate: ', 'membership2');
                     }
                     $code .= $list[$addon]->name . '<br/>';
                 }
                 $settings[] = array(__('Add-Ons', 'membership2'), $code);
                 break;
         }
     }
     if (empty($settings)) {
         $settings[] = array('', __('(No settings are changed)', 'membership2'));
     }
     // Prepare the return value.
     $fields = array();
     // Export-Notes
     $notes = '';
     if (isset($data->notes)) {
         if (is_scalar($data->notes)) {
             $notes = array($data->notes);
         }
         $in_sub = false;
         $notes = '<ul class="ms-import-notes">';
         foreach ($data->notes as $line => $text) {
             $is_sub = strpos($text, '- ') === 0;
             if ($in_sub != $is_sub) {
                 $in_sub = $is_sub;
                 if ($is_sub) {
                     $notes .= '<ul>';
                 } else {
                     $notes .= '</ul>';
                 }
             }
             if ($in_sub) {
                 $text = substr($text, 2);
             }
             $notes .= '<li>' . $text;
         }
         $notes .= '</ul>';
     }
     $fields['details'] = array('type' => MS_Helper_Html::TYPE_HTML_TABLE, 'class' => 'ms-import-preview', 'value' => array(array(__('Data source', 'membership2'), $data->source . ' &emsp; <small>' . sprintf(__('exported on %1$s', 'membership2'), $data->export_time) . '</small>'), array(__('Content', 'membership2'), sprintf(_n('%1$s Membership', '%1$s Memberships', count($data->memberships), 'membership2'), '<b>' . count($data->memberships) . '</b>') . ' / ' . sprintf(_n('%1$s Member', '%1$s Members', count($data->members), 'membership2'), '<b>' . count($data->members) . '</b>'))), 'field_options' => array('head_col' => true, 'head_row' => false, 'col_class' => array('preview-label', 'preview-data')));
     if (!empty($notes)) {
         $fields['details']['value'][] = array(__('Please note', 'membership2'), $notes);
     }
     $batchsizes = array(10 => __('Small (10 items)'), 30 => __('Normal (30 items)'), 100 => __('Big (100 items)'));
     $fields['batchsize'] = array('id' => 'batchsize', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'title' => __('Batch size for import', 'membership2'), 'desc' => __('Big batches will be processed faster but may result in PHP Memory errors.', 'membership2'), 'value' => 30, 'field_options' => $batchsizes, 'class' => 'sel-batchsize');
//.........这里部分代码省略.........
开发者ID:EdoMagen,项目名称:project-s-v2,代码行数:101,代码来源:class-ms-view-settings-import.php


注:本文中的MS_Model_Membership::get_types方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。