/** * 替换编辑器内容中的文件地址 * @param string $content 编辑器内容 * @param boolean $isForDbSave true:表示把绝对地址换成相对地址,用于数据库保存,false:表示把相对地址换成绝对地址用于界面显示 * @return string */ function cmf_replace_content_file_url($content, $isForDbSave = false) { import('phpQuery.phpQuery', EXTEND_PATH); \phpQuery::newDocumentHTML($content); $pq = pq(null); $storage = Storage::instance(); $localStorage = new cmf\lib\storage\Local([]); $storageDomain = $storage->getDomain(); $domain = request()->host(); $images = $pq->find("img"); if ($images->length) { foreach ($images as $img) { $img = pq($img); $imgSrc = $img->attr("src"); if ($isForDbSave) { if (preg_match("/^\/upload\//", $imgSrc)) { $img->attr("src", preg_replace("/^\/upload\//", '', $imgSrc)); } elseif (preg_match("/^http(s)?:\/\/$domain\/upload\//", $imgSrc)) { $img->attr("src", $localStorage->getFilePath($imgSrc)); } elseif (preg_match("/^http(s)?:\/\/$storageDomain\//", $imgSrc)) { $img->attr("src", $storage->getFilePath($imgSrc)); } } else { $img->attr("src", cmf_get_image_url($imgSrc)); } } } $links = $pq->find("a"); if ($links->length) { foreach ($links as $link) { $link = pq($link); $href = $link->attr("href"); if ($isForDbSave) { if (preg_match("/^\/upload\//", $href)) { $link->attr("href", preg_replace("/^\/upload\//", '', $href)); } elseif (preg_match("/^http(s)?:\/\/$domain\/upload\//", $href)) { $link->attr("href", $localStorage->getFilePath($href)); } elseif (preg_match("/^http(s)?:\/\/$storageDomain\//", $href)) { $link->attr("href", $storage->getFilePath($href)); } } else { if (!(preg_match("/^\//", $href) || preg_match("/^http/", $href))) { $link->attr("href", cmf_get_file_download_url($href)); } } } } $content = $pq->html(); \phpQuery::$documents = null; return $content; }
simplewind\cmf\common.php 里面加载了phpquery。composer require jaeger/querylist 的时候重复加载phpquery 导致发生错误。
0.话题发布后没及时显示,请联系官方QQ群管理;
1.话题支持代码,qq截屏直接粘贴,和QQ群一样;
2.问题描述清,比如服务器版本,程序版本;
3.能上代码,就不用文字;
4.把问题发到话题后再发QQ群;
5.如果感觉回复者解答的不错,可以发红包!
6.多帮助别人也是对自己的锻炼!
7.付费讨论中只有提问者和付费用户才可以查看回复
1.评论积分+1;每天最多10次奖励
2.发布话题积分+1;每天最多5次奖励
3.垃圾评论积分-500;
4.黄色,暴力,违反我国法律评论直接封号