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


PHP Manager::updateNode方法代码示例

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


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

示例1: doRelease


//.........这里部分代码省略.........
         return;
     }
     //建立TPL索引为了检测是否有空的tpl参数
     $tpl_index = array();
     foreach ($db_tpl as $v) {
         $tpl_index[$v['TemplateId']] = $v['Template'];
     }
     //获取Article
     $db_atc = $query->clear()->addTable('Article')->addWhere('ArticleId', $id, _ORM_OP_IN)->addWhere('GameType', $_SESSION['gameid'])->getArray();
     //建立Article索引,为了检测是否有错误的参数
     $atc_index = array();
     foreach ($db_atc as $v) {
         $atc_index[$v['ArticleId']] = $v;
     }
     //记录发表失败的id
     $error = array();
     $success = array();
     //生成静态页
     $date = date('Ymd');
     foreach ($enum_tpl as $tid) {
         if (empty($tpl_index[$tid])) {
             //将该tpl下的所有的文章id记录下
             $error = array_merge($error, $tpl_link[$tid]);
         } else {
             //生成临时模板文件
             $template_file = tempnam($this->app->cfg['path']['temp'], "ARTICLE");
             file_put_contents($template_file, $tpl_index[$tid]);
             //循环生成页面
             foreach ($tpl_link[$tid] as $aid) {
                 $count = $query->clear()->addTable('NodeLink')->addField('NodeId', 'Count', 'count')->addWhere('ArticleId', $aid)->addWhere('GameType', $_SESSION['gameid'])->getValue();
                 if (empty($atc_index[$aid]) || $count == 0) {
                     //文章不存在或者节点没有设置
                     $error[] = $aid;
                 } else {
                     //生成页面内容
                     $article = $atc_index[$aid];
                     /*
                     						$smarty = $this->app->page();
                     						$smarty->params['template'] = $template_file;
                     						$output = $smarty->value('Title', $article['Title'])
                     							->value('SubTitle', $article['SubTitle'])
                     							->value('Date', $article['PublishTime'])
                     							->value('Content', $article['Content'])
                     							->output(true);
                     							
                     						$html_file_path = $this->app->cfg['game'][$_SESSION['gameid']]['root'] . 'news/' . $date . '/';
                     						//如果没有建立文件夹就建立它
                     						$dirname = '';
                     						$folders = explode('/',$html_file_path);
                     						foreach ($folders as $folder) {
                     							$dirname .= $folder . '/';					
                     							if ($folder!='' && $folder!='.' && $folder!='..' && !is_dir($dirname)) {
                     								mkdir($dirname);
                     							}
                     						}
                     						chmod($html_file_path,0777);
                     						$html_file_path .= $article['ArticleId'] . '.html';
                     //写入指定文件
                     						file_put_contents($html_file_path, $output);
                     */
                     //更新数据库
                     $date = date('Ymd', strtotime($article['PublishTime']));
                     $url = $this->app->cfg['game'][$_SESSION['gameid']]['host'] . 'news/' . $date . '/';
                     if (!empty($article['SeoKey'])) {
                         $url .= $article['SeoKey'] . '-';
                     }
                     $url .= $article['ArticleId'] . '.html';
                     squid_clear($url);
                     $query->clear()->addTable('Article')->addWhere('ArticleId', $aid)->update(array('Status' => 3, 'UpdateTime' => date('Y-m-d H:i:s'), 'Url' => $url, 'TemplateId' => $tid));
                     //写日志
                     $query->clear()->addTable('Log')->insert(array('UserId' => $_SESSION['uid'], 'ArticleId' => $aid, 'UserName' => $_SESSION['name'], 'ArticleTitle' => $article['Title'], 'LogTime' => date('Y-m-d H:i:s'), 'GameType' => $_SESSION['gameid'], 'Action' => 5));
                     $success[] = $aid;
                 }
             }
             //删除临时文件
             unlink($template_file);
         }
     }
     //如果没有文章发布成功
     if (empty($success)) {
         echo json_encode(array('error' => true, 'msg' => '没有文章发布成功。请检查提交的文章和模板是否正确,并且设置了正确的节点。'));
         return;
     } else {
         //更新节点
         $nodes = $query->clear()->addTable('NodeLink')->addWhere('ArticleId', $success, _ORM_OP_IN)->addWhere('GameType', $_SESSION['gameid'])->addField('NodeId')->getColumn();
         if (!empty($nodes)) {
             $nodes = array_unique($nodes);
             importModule('Manager');
             $manager = new Manager();
             foreach ($nodes as $v) {
                 $manager->updateNode($v);
             }
         }
         if (empty($error)) {
             echo json_encode(array('error' => false, 'msg' => '文章全部发布成功。'));
         } else {
             echo json_encode(array('error' => false, 'msg' => '有一部分文章没有发布成功。', 'error' => $error));
         }
     }
 }
开发者ID:a4m,项目名称:go1den-express,代码行数:101,代码来源:candidate.php

示例2: doEdit

 /**
  * 编辑后提交
  */
 public function doEdit()
 {
     $id = intval($_POST['articleid']);
     $title = $_POST['title'];
     $title = trim($title);
     if (empty($title)) {
         $title = '[请尽快补充标题]';
     }
     $subtitle = $_POST['subtitle'];
     $link = $_POST['link'];
     $content = $_POST['FCKeditor1'];
     $desc1 = $_POST['desc1'];
     $desc2 = $_POST['desc2'];
     $desc3 = $_POST['desc3'];
     $key = $_POST['key'];
     $now = date('Y-m-d H:i:s');
     //操作数据库
     $query = $this->app->orm()->query();
     $query = $query->addTable('Article')->addValue('Sort', 0)->addValue('SeoKey', $key)->addValue('Title', $title)->addValue('SubTitle', $subtitle)->addValue('Link', $link)->addValue('Content', $content)->addValue('UpdateTime', $now)->addValue('UpdateUserId', $_SESSION['uid'])->addValue('Desc1', $desc1)->addValue('Desc2', $desc2)->addValue('Desc3', $desc3);
     if ($id > 0) {
         $action = 2;
         $bol = $query->addWhere('ArticleId', $id)->addWhere('GameType', $_SESSION['gameid'])->update();
     } else {
         $action = 1;
         $bol = $query->addValue('CreateTime', $now)->addValue('ServerTime', '0000-00-00 00:00:00')->addValue('PublishTime', '0000-00-00 00:00:00')->addValue('GameType', $_SESSION['gameid'])->addValue('ArticleUserId', $_SESSION['uid'])->addValue('TemplateId', 0)->addValue('Status', 1)->addValue('Url', '')->insert();
     }
     //导航为跳转返回做准备
     $refer = $_POST['refer'] ? $_POST['refer'] : 'original.php';
     if (!empty($bol)) {
         //上传封面
         if (empty($id)) {
             $id = $query->getLastId();
         }
         //先写日志
         $query->clear()->addTable('Log')->insert(array('UserId' => $_SESSION['uid'], 'ArticleId' => $id, 'UserName' => $_SESSION['name'], 'ArticleTitle' => $title, 'LogTime' => date('Y-m-d H:i:s'), 'GameType' => $_SESSION['gameid'], 'Action' => $action));
         //获取生成时间
         $row = $query->clear()->addTable('Article')->addWhere('ArticleId', $id)->addWhere('GameType', $_SESSION['gameid'])->addField('CreateTime')->addField('Status')->getRow();
         $date = $row['CreateTime'];
         $status = $row['Status'];
         $date = date('Ymd', strtotime($date));
         $imgpath = $this->app->cfg['path']['root'] . 'output/' . $this->app->cfg['game'][$_SESSION['gameid']]['key'] . '/images/' . $date . '/';
         $fileField = $_FILES['pic'];
         //无图片上传
         if (empty($fileField)) {
             $this->app->redirect($refer);
             return;
         }
         //上传成功
         if ($fileField['error'] == UPLOAD_ERR_OK) {
             $dirname = '';
             $folders = explode('/', $imgpath);
             foreach ($folders as $folder) {
                 $dirname .= $folder . '/';
                 if ($folder != '' && $folder != '.' && $folder != '..' && !is_dir($dirname)) {
                     mkdir($dirname);
                 }
             }
             chmod($imgpath, 0777);
             //
             //$ext = substr($fileField['name'],strrpos($fileField['name'],'.'));
             $newFile = 'thumb' . $id . '.jpg';
             //move_uploaded_file不会自己覆盖旧文件
             if (file_exists($imgpath . $newFile)) {
                 unlink($imgpath . $newFile);
             }
             if (move_uploaded_file($fileField['tmp_name'], $imgpath . $newFile)) {
                 //上传成功;
                 chmod($imgpath . $newFile, 0777);
                 //$this->app->redirect('original.php');
             } else {
                 //上传失败,移动文件失败
                 //echo $fileField['tmp_name'], $imgpath . $newFile;
                 //					/echo '上传失败,移动文件失败';
             }
             $this->app->redirect($refer);
         } else {
             //上传失败
             echo $fileField['error'];
             $this->app->redirect($refer);
         }
         //已发布的就需要同步
         if ($status == 3) {
             $atc = $query->clear()->addTable('Article')->addWhere('ArticleId', $id)->addWhere('GameType', intval($_SESSION['gameid']))->addField('Url')->addField('UpdateTime')->addField('Title')->getRow();
             squid_clear($atc['Url']);
             $nodes = $query->clear()->addTable('NodeLink')->addWhere('ArticleId', $id)->addWhere('GameType', $_SESSION['gameid'])->addField('NodeId')->getColumn();
             if (!empty($nodes)) {
                 $nodes = array_unique($nodes);
                 importModule('Manager');
                 $manager = new Manager();
                 foreach ($nodes as $v) {
                     $manager->updateNode($v, true);
                 }
             }
         }
     } else {
         //数据库失败
         echo '数据库失败';
//.........这里部分代码省略.........
开发者ID:a4m,项目名称:go1den-express,代码行数:101,代码来源:editor.php

示例3: sync

 private function sync($id)
 {
     $query = $this->app->orm()->query();
     $atc = $query->addTable('Article')->addWhere('ArticleId', $id)->addWhere('GameType', intval($_SESSION['gameid']))->addField('Url')->addField('UpdateTime')->addField('Title')->getRow();
     squid_clear($atc['Url']);
     $nodes = $query->clear()->addTable('NodeLink')->addWhere('ArticleId', $id)->addWhere('GameType', $_SESSION['gameid'])->addField('NodeId')->getColumn();
     if (!empty($nodes)) {
         $nodes = array_unique($nodes);
         importModule('Manager');
         $manager = new Manager();
         foreach ($nodes as $v) {
             $manager->updateNode($v, true);
         }
     }
 }
开发者ID:a4m,项目名称:go1den-express,代码行数:15,代码来源:release.php


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