PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/php/xuzhou58/xuzhou58.com/include/taglib/tag.lib.php

http://jqbird.googlecode.com/
PHP | 86 lines | 76 code | 8 blank | 2 comment | 23 complexity | e9507dd7b8e1e8581179ce68866bd036 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0, LGPL-2.1, GPL-2.0
  1. <?php
  2. //function GetTags($num,$ltype='new',$InnerText='')
  3. function lib_tag(&$ctag,&$refObj)
  4. {
  5. global $dsql,$envs,$cfg_cmsurl;
  6. //????
  7. $attlist="row|30,sort|new,getall|0,typeid|0";
  8. FillAttsDefault($ctag->CAttribute->Items,$attlist);
  9. extract($ctag->CAttribute->Items, EXTR_SKIP);
  10. $InnerText = $ctag->GetInnerText();
  11. if(trim($InnerText)=='') $InnerText = GetSysTemplets('tag_one.htm');
  12. $revalue = '';
  13. $ltype = $sort;
  14. $num = $row;
  15. $addsql = '';
  16. if($getall==0 && isset($refObj->Fields['tags']) && !empty($refObj->Fields['aid']))
  17. {
  18. $dsql->SetQuery("Select tid From `#@__taglist` where aid = '{$refObj->Fields['aid']}' ");
  19. $dsql->Execute();
  20. $ids = '';
  21. while($row = $dsql->GetArray())
  22. {
  23. $ids .= ( $ids=='' ? $row['tid'] : ','.$row['tid'] );
  24. }
  25. if($ids != '')
  26. {
  27. $addsql = " where id in($ids) ";
  28. }
  29. if($addsql=='') return '';
  30. }
  31. else
  32. {
  33. if(!empty($typeid))
  34. {
  35. $addsql = " where typeid='$typeid' ";
  36. }
  37. }
  38. if($ltype=='rand') $orderby = 'rand() ';
  39. else if($ltype=='week') $orderby=' weekcc desc ';
  40. else if($ltype=='month') $orderby=' monthcc desc ';
  41. else if($ltype=='hot') $orderby=' count desc ';
  42. else if($ltype=='total') $orderby=' total desc ';
  43. else $orderby = 'addtime desc ';
  44. $dsql->SetQuery("Select * From `#@__tagindex` $addsql order by $orderby limit 0,$num");
  45. $dsql->Execute();
  46. $ctp = new DedeTagParse();
  47. $ctp->SetNameSpace('field','[',']');
  48. $ctp->LoadSource($InnerText);
  49. while($row = $dsql->GetArray())
  50. {
  51. $row['keyword'] = $row['tag'];
  52. $row['tag'] = htmlspecialchars($row['tag']);
  53. $row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";
  54. $row['highlight'] = 0;
  55. if($row['monthcc']>1000 || $row['weekcc']>300 )
  56. {
  57. $row['highlight'] = mt_rand(3,4);
  58. }
  59. else if($row['count']>3000)
  60. {
  61. $row['highlight'] = mt_rand(5,6);
  62. }
  63. else
  64. {
  65. $row['highlight'] = mt_rand(1,2);
  66. }
  67. foreach($ctp->CTags as $tagid=>$ctag)
  68. {
  69. if(isset($row[$ctag->GetName()]))
  70. {
  71. $ctp->Assign($tagid,$row[$ctag->GetName()]);
  72. }
  73. }
  74. $revalue .= $ctp->GetResult();
  75. }
  76. return $revalue;
  77. }
  78. ?>