国内流行的内容管理系统(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.

193 lines
9.0KB

  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. $this->__construct($modtype);
  36. }
  37. //析构函数
  38. function __construct($modtype){
  39. $this->name = $modtype;
  40. $this->db = $GLOBALS['dsql'];
  41. $query = "SELECT * FROM #@__member_model WHERE name='{$modtype}'";
  42. $diyinfo = $this->db->getone($query);
  43. if(!is_array($diyinfo))
  44. {
  45. showMsg('参数不正确,该会员模型不存在','javascript:;');
  46. exit();
  47. }
  48. $etypes = array();
  49. $egroups = array();
  50. $this->db->Execute('me','SELECT * FROM `#@__stepselect` ORDER BY id desc');
  51. while($arr = $this->db->GetArray())
  52. {
  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. {
  84. foreach($dtp->CTags as $tagid=>$tag)
  85. {
  86. if($tag->GetAtt('autofield'))
  87. {
  88. if($tag->GetAtt('state') == 1)
  89. {
  90. //如果启用该字段
  91. if($type == 'post')
  92. {
  93. //对一些字段进行特殊处理
  94. if($tag->GetName() == 'onlynet')
  95. {
  96. $formstring .= '<li><span>联系方式限制:</span><div class="lform">
  97. <input name="onlynet" type="radio" id="onlynet" value="2" checked="checked" />
  98. 不公开所有联系方式
  99. <input name="onlynet" type="radio" id="onlynet" value="1" />
  100. 不公开电话、详细地址
  101. <input name="onlynet" type="radio" id="onlynet" value="0" />
  102. 公开所有联系方式</div></li>';
  103. } else if ($tag->GetName() == 'place' || $tag->GetName() == 'oldplace')
  104. {
  105. $formtitle = ($tag->GetName() == 'place')? '目前所在地' : '家乡所在地';
  106. $formstring .='<li><div class="lform">' . GetEnumsForm('nativeplace',
  107. 0,$tag->GetName()).'</div><span>'.$formtitle.':</span></li>';
  108. } else if (array_key_exists($tag->GetName(),$this->egroups))
  109. {
  110. //对联动模型进行特殊处理
  111. $formstring .='<li><div class="lform">'. GetEnumsForm($tag->GetName(),
  112. 0,$tag->GetName()).'</div><span>'.$this->egroups[$tag->GetName()].':</span></li>';
  113. } else if ($tag->GetAtt('type') == 'checkbox')
  114. {
  115. //对checkbox模型进行特殊处理
  116. $formstring .=$func($tag,$admintype);
  117. } else {
  118. $formstring .= $func($tag,$admintype);
  119. }
  120. } else {
  121. if($tag->GetName() == 'onlynet')
  122. {
  123. $formstring .= '<p style="display:none"><label>联系方式限制:</label>
  124. <input name="onlynet" type="radio" id="onlynet" value="2" checked="checked" />
  125. 不公开所有联系方式
  126. <input name="onlynet" type="radio" id="onlynet" value="1" />
  127. 不公开电话、详细地址
  128. <input name="onlynet" type="radio" id="onlynet" value="0" />
  129. 公开所有联系方式</p>';
  130. } else if ($tag->GetName() == 'place' || $tag->GetName() == 'oldplace'){
  131. $formtitle = ($tag->GetName() == 'place')? '目前所在地' : '家乡所在地';
  132. $formstring .='<p><label>'.$formtitle.':</label>' . GetEnumsForm('nativeplace',$value[$tag->GetName()],$tag->GetName()).'</p>';
  133. } else if ($tag->GetName() == 'birthday'){
  134. $formstring .='<p><label>'.$tag->GetAtt('itemname').':</label><input type="text" class="intxt" style="width: 100px;" id="birthday" value="'.$value[$tag->GetName()].'" name="birthday"></p>';
  135. } else if (array_key_exists($tag->GetName(),$this->egroups)){
  136. //对联动模型进行特殊处理
  137. $formstring .='<p><label>'.$this->egroups[$tag->GetName()].':</label> '. GetEnumsForm($tag->GetName(),$value[$tag->GetName()],$tag->GetName()).'</p>';
  138. } else if ($tag->GetAtt('type') == 'checkbox'){
  139. //对checkbox模型进行特殊处理
  140. $formstring .=$func($tag,dede_htmlspecialchars($value[$tag->GetName()],ENT_QUOTES),$admintype);
  141. }
  142. else if ($tag->GetAtt('type') == 'img')
  143. {
  144. $fieldname = $tag->GetName();
  145. $labelname = $tag->GetAtt('itemname');
  146. $fvalue = dede_htmlspecialchars($value[$tag->GetName()],ENT_QUOTES);
  147. $imgstrng = "<p><label>{$labelname}:</label><input type='text' name='$fieldname' value='$fvalue' id='$fieldname' style='width:300px' class='text' /> <input name='".$fieldname."_bt' class='inputbut' type='button' value='浏览...' onClick=\"SelectImage('addcontent.$fieldname','big')\" />\r\n</p>";
  148. $formstring .=$imgstrng;
  149. }
  150. else {
  151. $formstring .= $func($tag,dede_htmlspecialchars($value[$tag->GetName()],ENT_QUOTES),$admintype);
  152. //echo $formstring;
  153. }
  154. }
  155. $formfields .= $formfields == '' ? $tag->GetName().','.$tag->GetAtt('type') : ';'.$tag->GetName().','.$tag->GetAtt('type');
  156. }
  157. }
  158. }
  159. }
  160. $formstring .= "<input type=\"hidden\" name=\"dede_fields\" value=\"".$formfields."\" />\n";
  161. $formstring .= "<input type=\"hidden\" name=\"dede_fieldshash\" value=\"".md5($formfields.$cfg_cookie_encode)."\" />";
  162. return $formstring;
  163. }//end func getForm
  164. /**
  165. * 获取字段列表
  166. *
  167. * @access public
  168. * @param string
  169. * @return array
  170. */
  171. function getFieldList()
  172. {
  173. $dtp = new DedeTagParse();
  174. $dtp->SetNameSpace("field","<",">");
  175. $dtp->LoadSource($this->info);
  176. $fields = array();
  177. if(is_array($dtp->CTags))
  178. {
  179. foreach($dtp->CTags as $tagid=>$tag)
  180. {
  181. $fields[$tag->GetName()] = array($tag->GetAtt('itemname'), $tag->GetAtt('type'));
  182. }
  183. }
  184. return $fields;
  185. }
  186. }