心理咨询网
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.

ExtLabelController.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * @copyright (C)2020-2099 Hnaoyun Inc.
  4. * @author XingMeng
  5. * @email hnxsh@foxmail.com
  6. * @date 2020年3月8日
  7. * 个人扩展标签可编写到本类中,升级不会覆盖
  8. */
  9. namespace app\home\controller;
  10. use core\basic\Controller;
  11. use core\basic\Config;
  12. class ExtLabelController
  13. {
  14. protected $content;
  15. /* 必备启动函数 */
  16. public function run($content)
  17. {
  18. // 接收数据
  19. $this->content = $content;
  20. // 执行个人自定义标签函数
  21. $this->test();
  22. // 城市分站标签
  23. $this->citytag();
  24. // 返回数据
  25. return $this->content;
  26. }
  27. // 测试扩展单个标签
  28. private function test()
  29. {
  30. $this->content = str_replace('{pboot:userip}', get_user_ip(), $this->content);
  31. }
  32. // 城市分站标签
  33. private function citytag(){
  34. $cur_city = cookie('city');
  35. if( !! $cur_city ){
  36. $citys = Config::get('citys');
  37. $city = $citys[$cur_city];
  38. $this->content = str_replace('{xx}', $city['title'], $this->content);
  39. $this->content = str_replace('{citylink}', $city['etitle'], $this->content);
  40. }else{
  41. $this->content = str_replace('{xx}', '', $this->content);
  42. $this->content = str_replace('{citylink}', '', $this->content);
  43. }
  44. }
  45. }