国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
9.2KB

  1. <?php if (!defined('DEDEINC')) exit('forbidden');
  2. /**
  3. * 会员自定义模块
  4. *
  5. * @version $Id: oxwindow.class.php 1 15:21 2010年7月5日Z tianya $
  6. * @package DedeCMS.Libraries
  7. * @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.com
  10. */
  11. require_once DEDEINC . '/dedetag.class.php';
  12. require_once DEDEINC . '/customfields.func.php';
  13. require_once DEDEINC . '/enums.func.php';
  14. /**
  15. * 会员自定义模块
  16. *
  17. * @package membermodel
  18. * @subpackage DedeCMS.Libraries
  19. * @link http://www.dedecms.com
  20. */
  21. class membermodel
  22. {
  23. var $modid;
  24. var $db;
  25. var $info;
  26. var $name;
  27. var $table;
  28. var $public;
  29. var $egroups;
  30. var $listTemplate;
  31. var $viewTemplate;
  32. var $postTemplate;
  33. //兼容PHP4版本
  34. function membermodel($modtype)
  35. {
  36. $this->__construct($modtype);
  37. }
  38. //析构函数
  39. function __construct($modtype)
  40. {
  41. $this->name = $modtype;
  42. $this->db = $GLOBALS['dsql'];
  43. $query = "SELECT * FROM #@__member_model WHERE name='{$modtype}'";
  44. $diyinfo = $this->db->getone($query);
  45. if (!is_array($diyinfo)) {
  46. showMsg('参数不正确,该会员模型不存在', 'javascript:;');
  47. exit();
  48. }
  49. $etypes = array();
  50. $egroups = array();
  51. $this->db->Execute('me', 'SELECT * FROM `#@__stepselect` ORDER BY id desc');
  52. while ($arr = $this->db->GetArray()) {
  53. $etypes[] = $arr;
  54. $egroups[$arr['egroup']] = $arr['itemname'];
  55. }
  56. $this->egroups = $egroups;
  57. $this->modid = $diyinfo['id'];
  58. $this->table = $diyinfo['table'];
  59. $this->description = $diyinfo['description'];
  60. $this->state = $diyinfo['state'];
  61. $this->issystem = $diyinfo['issystem'];
  62. $this->info = $diyinfo['info'];
  63. } //end func __construct()
  64. /**
  65. * 获取用户数据表单
  66. *
  67. * @access public
  68. * @param string $type 表单类型
  69. * @param string $value 值
  70. * @param string $admintype 模型类型
  71. * @return string
  72. */
  73. function getForm($type = 'post', $value = '', $admintype = 'membermodel2')
  74. {
  75. global $cfg_cookie_encode;
  76. $dtp = new DedeTagParse();
  77. $dtp->SetNameSpace("field", "<", ">");
  78. $dtp->LoadSource($this->info);
  79. $formstring = '';
  80. $formfields = '';
  81. $func = $type == 'post' ? 'GetFormItem' : 'GetFormItemValue';
  82. if (is_array($dtp->CTags)) {
  83. foreach ($dtp->CTags as $tagid => $tag) {
  84. if ($tag->GetAtt('autofield')) {
  85. if ($tag->GetAtt('state') == 1) {
  86. //如果启用该字段
  87. if ($type == 'post') {
  88. //对一些字段进行特殊处理
  89. if ($tag->GetName() == 'onlynet') {
  90. $formstring .= '<li><span>联系方式限制:</span><div class="lform">
  91. <input name="onlynet" type="radio" id="onlynet" value="2" checked="checked" />
  92. 不公开所有联系方式
  93. <input name="onlynet" type="radio" id="onlynet" value="1" />
  94. 不公开电话、详细地址
  95. <input name="onlynet" type="radio" id="onlynet" value="0" />
  96. 公开所有联系方式</div></li>';
  97. } else if ($tag->GetName() == 'place' || $tag->GetName() == 'oldplace') {
  98. $formtitle = ($tag->GetName() == 'place') ? '目前所在地' : '家乡所在地';
  99. $formstring .= '<li><div class="lform">' . GetEnumsForm(
  100. 'nativeplace',
  101. 0,
  102. $tag->GetName()
  103. ) . '</div><span>' . $formtitle . ':</span></li>';
  104. } else if (array_key_exists($tag->GetName(), $this->egroups)) {
  105. //对联动模型进行特殊处理
  106. $formstring .= '<li><div class="lform">' . GetEnumsForm(
  107. $tag->GetName(),
  108. 0,
  109. $tag->GetName()
  110. ) . '</div><span>' . $this->egroups[$tag->GetName()] . ':</span></li>';
  111. } else if ($tag->GetAtt('type') == 'checkbox') {
  112. //对checkbox模型进行特殊处理
  113. $formstring .= $func($tag, $admintype);
  114. } else {
  115. $formstring .= $func($tag, $admintype);
  116. }
  117. } else {
  118. if ($tag->GetName() == 'onlynet') {
  119. $formstring .= '<p style="display:none"><label>联系方式限制:</label>
  120. <input name="onlynet" type="radio" id="onlynet" value="2" checked="checked" />
  121. 不公开所有联系方式
  122. <input name="onlynet" type="radio" id="onlynet" value="1" />
  123. 不公开电话、详细地址
  124. <input name="onlynet" type="radio" id="onlynet" value="0" />
  125. 公开所有联系方式</p>';
  126. } else if ($tag->GetName() == 'place' || $tag->GetName() == 'oldplace') {
  127. $formtitle = ($tag->GetName() == 'place') ? '目前所在地' : '家乡所在地';
  128. $formstring .= '<div class="form-group row"><label class="col-sm-2 col-form-label">' . $formtitle . ':</label><div class="col-sm-10">' . GetEnumsForm('nativeplace', $value[$tag->GetName()], $tag->GetName()) . '</div></div>';
  129. } else if ($tag->GetName() == 'birthday') {
  130. $formstring .= '<div class="form-group row"><label class="col-sm-2 col-form-label">' . $tag->GetAtt('itemname') . ':</label><div class="col-sm-10"><input type="text" class="form-control" style="width: 100px;" id="birthday" value="' . $value[$tag->GetName()] . '" name="birthday"></div></div>';
  131. } else if (array_key_exists($tag->GetName(), $this->egroups)) {
  132. //对联动模型进行特殊处理
  133. $formstring .= '<div class="form-group row"><label class="col-sm-2 col-form-label">' . $this->egroups[$tag->GetName()] . ':</label><div class="col-sm-10">' . GetEnumsForm($tag->GetName(), $value[$tag->GetName()], $tag->GetName()) . '</div></div>';
  134. } else if ($tag->GetAtt('type') == 'checkbox') {
  135. //对checkbox模型进行特殊处理
  136. $formstring .= $func($tag, dede_htmlspecialchars($value[$tag->GetName()], ENT_QUOTES), $admintype);
  137. } else if ($tag->GetAtt('type') == 'img') {
  138. $fieldname = $tag->GetName();
  139. $labelname = $tag->GetAtt('itemname');
  140. $fvalue = dede_htmlspecialchars($value[$tag->GetName()], ENT_QUOTES);
  141. $imgstrng = "<div class='form-group row'><label class='col-sm-2 col-form-label'>{$labelname}:</label><div class='col-sm-10'><input type='text' name='$fieldname' value='$fvalue' id='$fieldname' class='text' /> <input name='" . $fieldname . "_bt' class='inputbut' type='button' value='浏览...' onClick=\"SelectImage('addcontent.$fieldname','big')\" />\r\n</div></div>";
  142. $formstring .= $imgstrng;
  143. } else {
  144. $formstring .= $func($tag, dede_htmlspecialchars($value[$tag->GetName()], ENT_QUOTES), $admintype);
  145. //echo $formstring;
  146. }
  147. }
  148. $formfields .= $formfields == '' ? $tag->GetName() . ',' . $tag->GetAtt('type') : ';' . $tag->GetName() . ',' . $tag->GetAtt('type');
  149. }
  150. }
  151. }
  152. }
  153. $formstring .= "<input type=\"hidden\" name=\"dede_fields\" value=\"" . $formfields . "\" />\n";
  154. $formstring .= "<input type=\"hidden\" name=\"dede_fieldshash\" value=\"" . md5($formfields . $cfg_cookie_encode) . "\" />";
  155. return $formstring;
  156. } //end func getForm
  157. /**
  158. * 获取字段列表
  159. *
  160. * @access public
  161. * @param string
  162. * @return array
  163. */
  164. function getFieldList()
  165. {
  166. $dtp = new DedeTagParse();
  167. $dtp->SetNameSpace("field", "<", ">");
  168. $dtp->LoadSource($this->info);
  169. $fields = array();
  170. if (is_array($dtp->CTags)) {
  171. foreach ($dtp->CTags as $tagid => $tag) {
  172. $fields[$tag->GetName()] = array($tag->GetAtt('itemname'), $tag->GetAtt('type'));
  173. }
  174. }
  175. return $fields;
  176. }
  177. }