⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class.newsstory.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
		        global $xoopsUser, $xoopsModule;		        $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;		        $gperm_handler =& xoops_gethandler('groupperm');		        $topics = $gperm_handler->getItemIds('news_view', $groups, $xoopsModule->getVar('mid'));		        $topics = implode(',', $topics);		        $sql .= " AND topicid IN (".$topics.")";		    }		}		$result = $db->query($sql);		list($count) = $db->fetchRow($result);		return $count;	}	function topic_title()	{		return $this->newstopic->topic_title();	}	function adminlink()	{		$ret = "&nbsp;[ <a href='".XOOPS_URL."/modules/news/submit.php?op=edit&amp;storyid=".$this->storyid()."'>"._EDIT."</a> | <a href='".XOOPS_URL."/modules/news/admin/index.php?op=delete&amp;storyid=".$this->storyid()."'>"._DELETE."</a> ]&nbsp;";		return $ret;	}	function imglink()	{		$ret = '';		if ($this->newstopic->topic_imgurl() != '' && file_exists(XOOPS_ROOT_PATH."/modules/news/images/topics/".$this->newstopic->topic_imgurl())) {			$ret = "<a href='".XOOPS_URL."/modules/news/index.php?storytopic=".$this->topicid()."'><img src='".XOOPS_URL."/modules/news/images/topics/".$this->newstopic->topic_imgurl()."' alt='".$this->newstopic->topic_title()."' hspace='10' vspace='10' align='".$this->topicalign()."' /></a>";		}		return $ret;	}	function textlink()	{		$ret = "<a href='".XOOPS_URL."/modules/news/index.php?storytopic=".$this->topicid()."'>".$this->newstopic->topic_title()."</a>";		return $ret;	}	function prepare2show()	{	    global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig;	    $story = array();	    $story['id'] = $this->storyid();	    $story['poster'] = $this->uname();	    if ( $story['poster'] != false ) {	        $story['poster'] = "<a href='".XOOPS_URL."/userinfo.php?uid=".$this->uid()."'>".$story['poster']."</a>";	    }	    else {			if($xoopsModuleConfig['displayname']!=3) {				$story['poster'] = $xoopsConfig['anonymous'];			}	    }	    $story['posttimestamp'] = $this->published();	    $story['posttime'] = formatTimestamp($story['posttimestamp']);	    $story['text'] = $this->hometext();	    $introcount = strlen($story['text']);	    $fullcount = strlen($this->bodytext());	    $totalcount = $introcount + $fullcount;	    $morelink = '';	    if ( $fullcount > 1 ) {	        $morelink .= '<a href="'.XOOPS_URL.'/modules/news/article.php?storyid='.$this->storyid().'';	        $morelink .= '">'._NW_READMORE.'</a> | ';	        $morelink .= sprintf(_NW_BYTESMORE,$totalcount);	        if (XOOPS_COMMENT_APPROVENONE != $xoopsModuleConfig['com_rule']) {	            $morelink .= ' | ';	        }	    }	    if (XOOPS_COMMENT_APPROVENONE != $xoopsModuleConfig['com_rule']) {	        $ccount = $this->comments();	        $morelink .= '<a href="'.XOOPS_URL.'/modules/news/article.php?storyid='.$this->storyid().'';	        $morelink2 = '<a href="'.XOOPS_URL.'/modules/news/article.php?storyid='.$this->storyid().'';	        if ( $ccount == 0 ) {	            $morelink .= '">'._NW_COMMENTS.'</a>';	        }	        else {	            if ( $fullcount < 1 ) {	                if ( $ccount == 1 ) {	                    $morelink .= '">'._NW_READMORE.'</a> | '.$morelink2.'">'._NW_ONECOMMENT.'</a>';	                }	                else {	                    $morelink .= '">'._NW_READMORE.'</a> | '.$morelink2.'">';	                    $morelink .= sprintf(_NW_NUMCOMMENTS, $ccount);	                    $morelink .= '</a>';	                }	            }	            else {	                if ( $ccount == 1 ) {	                    $morelink .= $morelink2.'">'._NW_ONECOMMENT.'</a>';	                }	                else {	                    $morelink .= '">';	                    $morelink .= sprintf(_NW_NUMCOMMENTS, $ccount);	                    $morelink .= '</a>';	                }	            }	        }	    }	    $story['morelink'] = $morelink;	    $story['adminlink'] = '';	    $approveprivilege = 0;	    $gperm_handler =& xoops_gethandler('groupperm');	    if (is_object($xoopsUser)) {	        $groups = $xoopsUser->getGroups();	    } else {	        $groups = XOOPS_GROUP_ANONYMOUS;	    }	    if ($gperm_handler->checkRight("news_approve", $this->topicid(), $groups, $xoopsModule->getVar('mid'))) {	        $approveprivilege = 1;	    }	    if ($approveprivilege) {	        $story['adminlink'] = $this->adminlink();	    }	    $story['mail_link'] = 'mailto:?subject='.sprintf(_NW_INTARTICLE,$xoopsConfig['sitename']).'&amp;body='.sprintf(_NW_INTARTFOUND, $xoopsConfig['sitename']).':  '.XOOPS_URL.'/modules/news/article.php?storyid='.$this->storyid();	    $story['imglink'] = '';	    $story['align'] = '';	    if ( $this->topicdisplay()) {	        $story['imglink'] = $this->imglink();	        $story['align'] = $this->topicalign();	    }	    $story['title'] = "<a href='".XOOPS_URL."/modules/news/article.php?storyid=".$this->storyid()."'>".$this->title()."</a>";	    $story['hits'] = $this->counter();	    return $story;	}	function uname()	{		$module_handler =& xoops_gethandler('module');		$module =& $module_handler->getByDirname("news");		$config_handler =& xoops_gethandler('config');		if ($module) {		    $moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));		    $option= $moduleConfig['displayname'];		} else {		    $option= 1;		}		switch($option) {			case 1:		// Username				return XoopsUser::getUnameFromId($this->uid());			case 2:		// Display full name (if it is not empty)			     $thisuser = new XoopsUser($this->uid());			     $return = $thisuser->getVar('name');			     if ($return == "") {			         $return = $thisuser->getVar('uname');			     }				 return $return;			case 3:		// Nothing				return '';		}	}	function store($approved=false)	{		$myts =& MyTextSanitizer::getInstance();		$title =$myts->censorString($this->title);		$title = $myts->makeTboxData4Save($title);		$hostname=$myts->makeTboxData4Save($this->hostname);		$type=$myts->makeTboxData4Save($this->type);		$hometext =$myts->censorString($this->hometext);		$hometext = $myts->makeTareaData4Save($hometext);		$bodytext =$myts->censorString($this->bodytext);		$bodytext = $myts->makeTareaData4Save($bodytext);		if ( !isset($this->nohtml) || $this->nohtml != 1 ) {			$this->nohtml = 0;		}		if ( !isset($this->nosmiley) || $this->nosmiley != 1 ) {			$this->nosmiley = 0;		}		if ( !isset($this->notifypub) || $this->notifypub != 1 ) {			$this->notifypub = 0;		}		if( !isset($this->topicdisplay) || $this->topicdisplay != 0 ) {			$this->topicdisplay = 1;		}		$expired = !empty($this->expired) ? $this->expired : 0;		if ( !isset($this->storyid) ) {			//$newpost = 1;			$newstoryid = $this->db->genId($this->table."_storyid_seq");			$created = time();			$published = ( $this->approved ) ? intval($this->published) : 0;			$published=intval($published);			$sql = sprintf("INSERT INTO %s (storyid, uid, title, created, published, expired, hostname, nohtml, nosmiley, hometext, bodytext, counter, topicid, ihome, notifypub, story_type, topicdisplay, topicalign, comments) VALUES (%u, %u, '%s', %u, %u, %u, '%s', %u, %u, '%s', '%s', %u, %u, %u, %u, '%s', %u, '%s', %u)", $this->table, $newstoryid, intval($this->uid()), $title, $created, $published, $expired, $hostname, intval($this->nohtml()), intval($this->nosmiley()), $hometext, $bodytext, 0, intval($this->topicid()), intval($this->ihome()), intval($this->notifypub()), $type, intval($this->topicdisplay()), $this->topicalign, intval($this->comments()));		} else {			if ( $this->approved ) {				$sql = sprintf("UPDATE %s SET title = '%s', published = %u, expired = %u, nohtml = %u, nosmiley = %u, hometext = '%s', bodytext = '%s', topicid = %u, ihome = %u, topicdisplay = %u, topicalign = '%s', comments = %u WHERE storyid = %u", $this->table, $title, intval($this->published()), $expired, intval($this->nohtml()), intval($this->nosmiley()), $hometext, $bodytext, intval($this->topicid()), intval($this->ihome()), intval($this->topicdisplay()), $this->topicalign, intval($this->comments()), intval($this->storyid()));			} else {				$sql = sprintf("UPDATE %s SET title = '%s', published = %u, expired = %u, nohtml = %u, nosmiley = %u, hometext = '%s', bodytext = '%s', topicid = %u, ihome = %u, topicdisplay = %u, topicalign = '%s', comments = %u WHERE storyid = %u", $this->table, $title, intval($this->published()), $expired, intval($this->nohtml()), intval($this->nosmiley()), $hometext, $bodytext, intval($this->topicid()), intval($this->ihome()), intval($this->topicdisplay()), $this->topicalign, intval($this->comments()), intval($this->storyid()));			}			$newstoryid = intval($this->storyid());		}		if (!$result = $this->db->query($sql)) {			return false;		}		if ( empty($newstoryid) ) {			$newstoryid = $this->db->getInsertId();			$this->storyid = $newstoryid;		}		return $newstoryid;	}}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -