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

140 lines
5.3KB

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