/** * 知知文库 - 文档信息表格(显示在正文顶部) */ // 获取文档详细信息 function zib_get_doc_detail($post_id) { $cached = get_post_meta($post_id, 'zib_doc_detail_cache', true); if ($cached && is_array($cached)) { return $cached; } $detail = array( 'type' => '未知', 'size' => '未知', 'pages' => '未知', 'words' => '未知', 'downloads' => 0, 'ocr_text' => '', ); $file_id = 0; $file_keys = array('jike_file_id', 'wenku_file_id', 'document_file', 'attachment_id', 'file_id'); foreach ($file_keys as $key) { $val = get_post_meta($post_id, $key, true); if ($val && is_numeric($val)) { $file_id = intval($val); break; } } if ($file_id) { $file_path = get_attached_file($file_id); if ($file_path && file_exists($file_path)) { $ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION)); $detail['type'] = strtoupper($ext); $detail['size'] = zib_format_filesize(filesize($file_path)); if ($ext == 'docx' && class_exists('ZipArchive')) { $zip = new ZipArchive(); if ($zip->open($file_path) === true) { $app_xml = $zip->getFromName('docProps/app.xml'); $zip->close(); if ($app_xml) { if (preg_match('/(\d+)<\/Pages>/i', $app_xml, $m)) { $detail['pages'] = intval($m[1]) . ' 页'; } if (preg_match('/(\d+)<\/Words>/i', $app_xml, $m)) { $detail['words'] = intval($m[1]) . ' 字'; } } } } } } $text_keys = array('jike_ocr_text', 'wenku_ocr_text', 'document_text', 'ocr_content', 'preview_text'); foreach ($text_keys as $key) { $val = get_post_meta($post_id, $key, true); if ($val && is_string($val) && mb_strlen($val) > 50) { $detail['ocr_text'] = $val; break; } } $download_keys = array('jike_download_count', 'wenku_download_count', 'download_count', 'downloads'); foreach ($download_keys as $key) { $val = get_post_meta($post_id, $key, true); if ($val && is_numeric($val)) { $detail['downloads'] = intval($val); break; } } update_post_meta($post_id, 'zib_doc_detail_cache', $detail); return $detail; } function zib_format_filesize($bytes) { if ($bytes >= 1048576) return number_format($bytes / 1048576, 2) . ' MB'; elseif ($bytes >= 1024) return number_format($bytes / 1024, 2) . ' KB'; else return $bytes . ' B'; } // 在正文顶部插入文档信息表格 add_filter('the_content', 'zib_add_doc_info_table_before_content', 5); function zib_add_doc_info_table_before_content($content) { if (!is_single() || !in_the_loop() || !is_main_query()) { return $content; } global $post; if (!$post || $post->post_type != 'post') { return $content; } $doc_info = zib_get_doc_detail($post->ID); if ($doc_info['type'] == '未知' && $doc_info['size'] == '未知') { return $content; } $table_html = '
📄 文档类型 ' . $doc_info['type'] . ' 📊 文档大小 ' . $doc_info['size'] . '
📄 总页数 ' . $doc_info['pages'] . ' 📝 总字数 ' . $doc_info['words'] . '
⬇️ 下载次数 ' . $doc_info['downloads'] . ' 次
'; return $table_html . $content; } admin-知知文库网-第5页
admin-知知文库网-第5页
高校宿舍管理系统的设计与实现-知知文库网

高校宿舍管理系统的设计与实现

目录1绪论011.1研究背景11.2研究目的和意义.11.3课题任务.11.4本文结构….12开发工具及技术介绍22.1开发工具介绍.22.2开发技术介绍.23系统分析…33.1可行性分析.33.2需求分析….44系统设计…64....
2024年03月16日
网络视频直播系统研究与开发-知知文库网

网络视频直播系统研究与开发

AbstractWith the gradual improvement of campus network construction,the traditionaleducation mode must be affected by the network development,supported by themodern education must ...
2024年03月16日
基于hadoop的音乐推荐系统的设计与实现-知知文库网

基于hadoop的音乐推荐系统的设计与实现

目录1前言.…1.1课题背景及目的...1.2国内外研究状况.………11.3发展趋势2 hadoop系统平台的搭建以及环境搭建2.1 Hadoop伪分布式平台搭建...…....22.2环境配置以及相关软件安装23音乐数据的处...
2024年03月16日
基于安卓的学生在线评教小程序设计与实现-知知文库网

基于安卓的学生在线评教小程序设计与实现

1关键技术介绍l.1 Android简介Android是一个开源的移动操作系统,采用Linux作为操作系统内核,实现了进程管理,存储管理,设备管理,文件管理等操作系统的基本功能,同时,Android:提供开源Andr...
2024年03月16日
新能源汽车动力电池检测与拆装-知知文库网

新能源汽车动力电池检测与拆装

盐城工业职业技术学院毕业论文目录摘要.引言.…1第1章动力电池的概述21.1动力电池的历史..1.2动力电池的类型...31.3动力电池国内外研究....第2章动力电池检测..2.1动力电池故障诊断及流程..2.2...
2024年03月16日
新能源汽车维修技术探析-知知文库网

新能源汽车维修技术探析

导致电池能量不足、电池寿命缩短等问题。电动汽车工作原理电池材电量,离盛与轻量化悬电他的关键,吾神产电沁存嘴甲心“核PCU控纯机速可600合17000的置机鳍安本油电动纯电产车PRA迈动开关,负贵...
2024年03月16日
基于web的酒店管理系统开发-知知文库网

基于web的酒店管理系统开发

AbstractWith the continuous development of the socio-economy,Internet technology hasmade a leap forward,The way various industries operate in society has changed,Thehotel's busines...
2024年03月16日
高校宿舍管理系统的设计与实现-知知文库网

高校宿舍管理系统的设计与实现

目录1绪论011.1研究背景11.2研究目的和意义.11.3课题任务.11.4本文结构….12开发工具及技术介绍22.1开发工具介绍.22.2开发技术介绍.23系统分析…33.1可行性分析.33.2需求分析….44系统设计…64....
2024年03月16日
校园网设计与实现-知知文库网

校园网设计与实现

Campus network design and implementationAbstract:The rapid development of computer network and multimedia and otherInternet technologies,the information transmission speed is faste...
2024年03月16日
疫情防控信息系统的设计与实现-知知文库网

疫情防控信息系统的设计与实现

4.3数据库设计.…124.3.1数据库E-R图…124.3.2数据库表设计.14第五章系统实现……175.1用户功能模块实现175.1.1用户登录界面.175.1.2物品信息界面.185.1.3在线留言界面.185.1.4信息登记界面.195...
2024年03月16日

在线客服系统