当前位置: 首页>>代码示例>>PHP>>正文


PHP misc::getKeywords方法代码示例

本文整理汇总了PHP中misc::getKeywords方法的典型用法代码示例。如果您正苦于以下问题:PHP misc::getKeywords方法的具体用法?PHP misc::getKeywords怎么用?PHP misc::getKeywords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在misc的用法示例。


在下文中一共展示了misc::getKeywords方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: batchAddAction

 /**
  * 新闻批量添加
  * @author yangguofeng
  */
 public function batchAddAction()
 {
     $data = [];
     if ($_FILES['news']['name']) {
         $title = explode('.', $_FILES['news']['name']);
         $news = file_get_contents($_FILES['news']['tmp_name']);
         //新闻内容转编码
         $content = strcmp(mb_detect_encoding($news, ['UTF-8', 'GBK']), 'UTF-8') === 0 ? $news : mb_convert_encoding($news, "UTF-8", "GBK");
         //关键字(如果没写关键字,在标题中取。如果没取到,标题作为关键词)
         $keywords = empty($this->getRequest()->getPost('keywords', '')) ? implode('   ', misc::getKeywords($title[0])) : $this->getRequest()->getPost('keywords', '');
         $keywords = empty($keywords) ? $title[0] : $keywords;
         $ret = $this->topic->add("topic_data", ['title' => $title[0], 'tid' => intval($this->getRequest()->getQuery('tid')), 'sid' => intval($this->getRequest()->getQuery('sid')), 'keywords' => $keywords, 'status' => 1, 'attribute' => 0, 'userid' => $this->_user['uid'], 'username' => $data['username'] = $this->_user['username'], 'description' => mb_substr(strip_tags($content), 0, 78, 'UTF-8'), 'inputtime' => $_SERVER['REQUEST_TIME'], 'content' => $content]);
         if ($ret) {
             exit($ret);
         } else {
             header("HTTP/1.1 500 Internal Server Error");
             exit(0);
         }
     }
     $this->getView()->assign('tid', intval($this->getRequest()->getQuery('tid')));
     $this->getView()->assign('sid', intval($this->getRequest()->getQuery('sid')));
 }
开发者ID:290329416,项目名称:guahao,代码行数:26,代码来源:Topicdata.php

示例2: batchAddAction

 /**
  * 新闻批量添加
  * @author cms
  */
 public function batchAddAction()
 {
     $data = [];
     $data['cid'] = $this->getRequest()->getQuery('cid');
     if ($_FILES['news']['name']) {
         //标题
         $title = explode('.', $_FILES['news']['name']);
         $data['title'] = $title[0];
         $news = file_get_contents($_FILES['news']['tmp_name']);
         //检测新闻内容并转编码
         $data['content'] = strcmp(mb_detect_encoding($news, ['UTF-8', 'GBK']), 'UTF-8') === 0 ? $news : mb_convert_encoding($news, "UTF-8", "GBK");
         unset($news);
         //关键字(如果没写关键字,在标题中取。如果没取到,标题作为关键词)
         $data['keywords'] = empty($this->getRequest()->getPost('keywords', '')) ? implode('   ', misc::getKeywords($data['title'])) : $this->getRequest()->getPost('keywords', '');
         $data['keywords'] = empty($data['keywords']) ? $title[0] : $data['keywords'];
         $ret = $this->db_document->addNews(['title' => $data['title'], 'catid' => intval($this->getRequest()->getQuery('cid')), 'keywords' => $data['keywords'], 'url' => '', 'description' => mb_substr(strip_tags($data['content']), 0, 78, 'UTF-8'), 'inputtime' => $_SERVER['REQUEST_TIME'], 'status' => 99, 'content' => $data['content']]);
         if ($ret) {
             echo json_encode(['msg' => 'ok', 'errcode' => 200], JSON_UNESCAPED_UNICODE);
             exit('ok');
         } else {
             header("HTTP/1.1 500 Internal Server Error");
             exit(0);
         }
     }
     $this->getView()->assign('data', $data);
 }
开发者ID:290329416,项目名称:guahao,代码行数:30,代码来源:Document.php


注:本文中的misc::getKeywords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。