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

134 lines
5.2KB

  1. <?php
  2. if (!defined('DEDEINC')) exit('dedebiz');
  3. /**
  4. * 图像标签
  5. *
  6. * @version $id:img.lib.php 9:33 2010年7月8日 tianya $
  7. * @package DedeBIZ.Taglib
  8. * @copyright Copyright (c) 2022 DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license
  10. * @link https://www.dedebiz.com
  11. */
  12. function ch_img($fvalue, &$arcTag, &$refObj, $fname = '')
  13. {
  14. global $cfg_album_width, $cfg_album_row, $cfg_album_col, $cfg_album_pagesize, $cfg_album_style, $cfg_album_ddwidth, $cfg_basehost, $cfg_multi_site;
  15. $dtp = new DedeTagParse();
  16. $dtp->LoadSource($fvalue);
  17. if (!is_array($dtp->CTags)) {
  18. $dtp->Clear();
  19. return "无图片信息";
  20. }
  21. $pagestyle = $cfg_album_style;
  22. $maxwidth = $cfg_album_width;
  23. $ddmaxwidth = $cfg_album_ddwidth;
  24. $pagepicnum = $cfg_album_pagesize;
  25. $row = $cfg_album_row;
  26. $icol = $cfg_album_col;
  27. $ptag = $dtp->GetTag('pagestyle');
  28. if (is_object($ptag)) {
  29. $pagestyle = $ptag->GetAtt('value');
  30. $maxwidth = $ptag->GetAtt('maxwidth');
  31. $ddmaxwidth = $ptag->GetAtt('ddmaxwidth');
  32. $pagepicnum = $ptag->GetAtt('pagepicnum');
  33. $irow = $ptag->GetAtt('row');
  34. $icol = $ptag->GetAtt('col');
  35. if (empty($maxwidth)) {
  36. $maxwidth = $cfg_album_width;
  37. }
  38. }
  39. //遍历图片信息
  40. $mrow = 0;
  41. $mcol = 0;
  42. $images = array();
  43. $innerTmp = $arcTag->GetInnerText();
  44. if (trim($innerTmp) == '') {
  45. $innerTmp = GetSysTemplets("channel_article_image.htm");
  46. }
  47. if ($pagestyle == 1) {
  48. $pagesize = $pagepicnum;
  49. } else if ($pagestyle == 2) {
  50. $pagesize = 1;
  51. } else {
  52. $pagesize = $irow * $icol;
  53. }
  54. if (is_object($arcTag) && $arcTag->GetAtt('pagesize') > 0) {
  55. $pagesize = $arcTag->GetAtt('pagesize');
  56. }
  57. if (empty($pagesize)) {
  58. $pagesize = 12;
  59. }
  60. $aid = $refObj->ArcID;
  61. $row = $refObj->dsql->GetOne("SELECT title FROM `#@__archives` WHERE `id` = '$aid';");
  62. $title = $row['title'];
  63. $revalue = '';
  64. $GLOBAL['photoid'] = 0;
  65. foreach ($dtp->CTags as $ctag) {
  66. if ($ctag->GetName() == "img") {
  67. $fields = $ctag->CAttribute->Items;
  68. $fields['text'] = str_replace("'", "", $ctag->GetAtt('text'));
  69. $fields['title'] = $title;
  70. $fields['imgsrc'] = trim($ctag->GetInnerText());
  71. $fields['imgsrctrue'] = $fields['imgsrc'];
  72. if (empty($fields['ddimg'])) {
  73. $fields['ddimg'] = $fields['imgsrc'];
  74. }
  75. if ($cfg_multi_site == 'Y') {
  76. //$cfg_basehost)
  77. if (!preg_match('#^http:#i', $fields['imgsrc'])) {
  78. $fields['imgsrc'] = $cfg_basehost.$fields['imgsrc'];
  79. }
  80. if (!preg_match('#^http:#i', $fields['ddimg'])) {
  81. $fields['ddimg'] = $cfg_basehost.$fields['ddimg'];
  82. }
  83. }
  84. if (empty($fields['width'])) {
  85. $fields['width'] = $maxwidth;
  86. }
  87. //if ($fields['text']=='')
  88. //{
  89. //$fields['text'] = '图片'.($GLOBAL['photoid']+1);
  90. //}
  91. $fields['alttext'] = str_replace("'", '', $fields['text']);
  92. $fields['pagestyle'] = $pagestyle;
  93. $dtp2 = new DedeTagParse();
  94. $dtp2->SetNameSpace("field", "[", "]");
  95. $dtp2->LoadSource($innerTmp);
  96. if ($GLOBAL['photoid'] > 0 && ($GLOBAL['photoid'] % $pagesize) == 0) {
  97. $revalue .= "#p#分页标题#e#";
  98. }
  99. if ($pagestyle == 1) {
  100. $fields['imgwidth'] = '';
  101. $fields['linkurl'] = $fields['imgsrc'];
  102. $fields['textlink'] = "<br><a href='{$fields['linkurl']}' target='_blank'>{$fields['text']}</a>";
  103. } else if ($pagestyle == 2) {
  104. if ($fields['width'] > $maxwidth) {
  105. $fields['imgwidth'] = " width='$maxwidth' ";
  106. } else {
  107. $fields['imgwidth'] = " width='{$fields['width']}' ";
  108. }
  109. $fields['linkurl'] = $fields['imgsrc'];
  110. if ($fields['text'] != '') {
  111. $fields['textlink'] = "<br><a href='{$fields['linkurl']}' target='_blank'>{$fields['text']}</a>\r\n";
  112. } else {
  113. $fields['textlink'] = '';
  114. }
  115. } else if ($pagestyle == 3) {
  116. $fields['text'] = $fields['textlink'] = '';
  117. $fields['imgsrc'] = $fields['ddimg'];
  118. $fields['imgwidth'] = " width='$ddmaxwidth' ";
  119. $fields['linkurl'] = "{$GLOBALS['cfg_phpurl']}/showphoto.php?aid={$refObj->ArcID}&src=".urlencode($fields['imgsrctrue'])."&npos={$GLOBAL['photoid']}";
  120. }
  121. if (is_array($dtp2->CTags)) {
  122. foreach ($dtp2->CTags as $tagid => $ctag) {
  123. if (isset($fields[$ctag->GetName()])) {
  124. $dtp2->Assign($tagid, $fields[$ctag->GetName()]);
  125. }
  126. }
  127. $revalue .= $dtp2->GetResult();
  128. }
  129. $GLOBAL['photoid']++;
  130. }
  131. }
  132. return $revalue;
  133. }
  134. ?>