Minahito
minah****@users*****
2006年 2月 2日 (木) 18:29:00 JST
Index: xoops2jp/html/modules/comment/class/comments.php diff -u xoops2jp/html/modules/comment/class/comments.php:1.1.2.1 xoops2jp/html/modules/comment/class/comments.php:removed --- xoops2jp/html/modules/comment/class/comments.php:1.1.2.1 Thu Nov 24 18:40:01 2005 +++ xoops2jp/html/modules/comment/class/comments.php Thu Feb 2 18:29:00 2006 @@ -1,268 +0,0 @@ -<?php - -if (!defined('XOOPS_ROOT_PATH')) - exit(); - -class CommentCommentsObject extends XoopsObject -{ - function CommentCommentsObject() - { - parent::XoopsObject(); - $this->initVar('id', XOBJ_DTYPE_INT, 0, false); - $this->initVar('pid', XOBJ_DTYPE_INT, 0, false); - $this->initVar('root_id', XOBJ_DTYPE_INT, 0, false); - $this->initVar('obj_id', XOBJ_DTYPE_INT, 0, false); - $this->initVar('icon', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('created_time', XOBJ_DTYPE_INT, time(), false); - $this->initVar('modified_time', XOBJ_DTYPE_INT, time(), false); - $this->initVar('uid', XOBJ_DTYPE_INT, 0, true); - $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, true, 255, true); - $this->initVar('message', XOBJ_DTYPE_TXTAREA, null, true, null, true); - $this->initVar('status', XOBJ_DTYPE_INT, 0, false); - - // - // Compatibility flags. - // - $this->initVar('ip', XOBJ_DTYPE_TXTBOX, null, false); - - $this->initVar('sig', XOBJ_DTYPE_INT, 0, false); - $this->initVar('exparams', XOBJ_DTYPE_OTHER, null, false, 255); - - $this->initVar('dohtml', XOBJ_DTYPE_INT, 0, false); - $this->initVar('dosmiley', XOBJ_DTYPE_INT, 1, false); - $this->initVar('doxcode', XOBJ_DTYPE_INT, 1, false); - $this->initVar('doimage', XOBJ_DTYPE_INT, 0, false); - $this->initVar('dobr', XOBJ_DTYPE_INT, 1, false); - } - - /** - * Create a responce comment object, and return it. - * @return XoopsComment - */ - function createChild() - { - $ret=new CommentCommentsObject(); - $ret->setNew(); - $ret->setVar('pid',$this->getVar('id')); - $ret->setVar('root_id',$this->getVar('root_id')); - $ret->setVar('obj_id',$this->getVar('obj_id')); - $ret->setVar('exparams',$this->getVar('exparams')); - - return $ret; - } -} - -class CommentCommentsHandler extends XoopsObjectHandler -{ - function &create($isNew=true) - { - $ret=new CommentCommentsObject(); - if($isNew) - $ret->setNew(); - - return $ret; - } - - function &get($id) - { - $ret=false; - - $sql="SELECT * FROM ".$this->db->prefix("comment_comments")." WHERE id=".intval($id); - $result=$this->db->query($sql); - if(!$result) - return $ret; - - if($this->db->getRowsNum($result)==1) { - $ret = new CommentCommentsObject(); - $ret->assignVars($this->db->fetchArray($result)); - return $ret; - } - - return $ret; - } - - function insert(&$comment,$force=false) - { - if(!is_a($comment,"CommentCommentsObject")) - return false; - - if(!$comment->isDirty()) - return true; - - if(!$comment->cleanVars()) - return false; - - $fields=array( - "id" => $comment->getProperty('id'), - "pid" => $comment->getProperty('pid'), - "root_id" => $comment->getProperty('root_id'), - "obj_id" => $comment->getProperty('obj_id'), - "icon" => $this->db->quoteString($comment->getProperty('icon')), - "created_time" => $comment->getProperty('created_time'), - "modified_time" => $comment->getProperty('modified_time'), - "uid" => $comment->getProperty('uid'), - "title" => $this->db->quoteString($comment->getProperty('title')), - "message" => $this->db->quoteString($comment->getProperty('message')), - "status" => $comment->getProperty('status'), - "ip" => $this->db->quoteString($comment->getProperty('ip')), - "sig" => $comment->getProperty('sig'), - "exparams" => $this->db->quoteString($comment->getProperty('exparams')), - "dohtml" => $comment->getProperty('dohtml'), - "dosmiley" => $comment->getProperty('dosmiley'), - "doxcode" => $comment->getProperty('doxcode'), - "doimage" => $comment->getProperty('doimage'), - "dobr" => $comment->getProperty('dobr') - ); - - // - // Generate SQL - // Because XoopsObject Handler is deprecated, we keep this helper to base class. - // - $sql=null; - $isNewFlag=$comment->isNew(); - if($isNewFlag) { - $sql="INSERT INTO ".$this->db->prefix("comment_comments"). - " ( ".implode(",",array_keys($fields))." ) ". - " VALUES ( ".implode(",",array_values($fields))." )"; - } - else { - $set=array(); - foreach($fields as $key=>$value) { - $set[]= $key . "=" . $value; - } - $sql="UPDATE ".$this->db->prefix("comment_comments"). - " SET ".implode(",",$set)." WHERE id=".$fields['id']; - } - - if($force) { - $result=$this->db->queryF($sql); - } - else { - $result=$this->db->query($sql); - } - if(!$result) - return false; - - if($isNewFlag) { - $comment->setVar('id',$this->db->getInsertId()); - $comment->unsetNew(); - } - - return true; - } - - function delete(&$comment) - { - if(!is_a($comment,"CommentCommentsObject")) - return false; - - $sql="DELETE FORM ".$this->db->prefix("comment_comments")." WHERE id=".$comment->getVar('id'); - $result=$this->db->query($sql); - - return $result ? true : false; - } - - /** - * This function does not impletement about 'is_as_key'. - */ - function &getObjects($criteria=null,$id_as_key=false) - { - $ret=array(); - $start = 0; - $limit = 0; - - $sql="SELECT * FROM ".$this->db->prefix("comment_comments"); - if(isset($criteria)&&is_a($criteria,"CriteriaElemenet")) { - $sql.=" ".$$criteria->renderWhere(); - $sort = ($criteria->getSort() != null) ? $criteria->getSort() : "id"; - $sql.=" ORDER BY ".$sort." ".$criteria->getOrder(); - $start=$criteria->getStart(); - $limit=$criteria->getLimit(); - } - - $result=$this->db->query($sql,$limit,$start); - if(!$result) - return $ret; - - while($row=$this->db->fetchArray($result)) { - $comment=new CommentCommentsObject(); - $comment->assignVars($row); - $ret[]=&$comment; - unset($comment); - } - - return $ret; - } - - /** - * Returns comment objects by object id. - * @param $objectId int - * @param $start int - * @param $limit int - */ - function getObjectsByObjId($objectId,$start=0,$limit=0) - { - $ret=array(); - - // TODO SORT!! - $sql="SELECT * FROM ".$this->db->prefix("comment_comments")." WHERE obj_id=".intval($objectId); - - $result=$this->db->query($sql,$limit,$start); - if(!$result) - return $ret; - - while($row=$this->db->fetchArray($result)) { - $comment=new CommentCommentsObject(); - $comment->assignVars($row); - $ret[]=&$comment; - unset($comment); - } - - return $ret; - } - - function getCount($criteria=null) - { - $sql="SELECT COUNT(*) FROM ".$this->db->prefix("comment_comments"); - if(isset($criteria)&&is_a($criteria,"CriteriaElement")) { - $sql.=" ".$criteria->renderWhere(); - } - - $result=$this->db->query($sql); - if(!$result) - return 0; - - list($count)=$this->db->fetchRow($result); - return $count; - } - - function getChildObjects(&$comment) - { - $ret=array(); - - $table=$this->db->prefix("comment_comments"); - $sql="SELECT * FROM ${table} WHERE pid=" . $comment->getVar("id") . - " AND id<>".$comment->getVar("id"); - $result=$this->db->query($sql); - while($row=$this->db->fetchArray($result)) { - $comment=new CommentCommentsObject(); - $comment->assignVars($row); - $ret[]=&$comment; - unset($comment); - } - - return $ret; - } - - function deleteWithChild(&$comment) - { - foreach($this->getChildObjects($comment) as $child) { - $this->deleteWithChild($child); - } - $this->delete($comment); - - return true; // TODO - } -} - -?> \ No newline at end of file Index: xoops2jp/html/modules/comment/class/CommentActionFrame.class.php diff -u xoops2jp/html/modules/comment/class/CommentActionFrame.class.php:1.1.2.2 xoops2jp/html/modules/comment/class/CommentActionFrame.class.php:removed --- xoops2jp/html/modules/comment/class/CommentActionFrame.class.php:1.1.2.2 Fri Nov 25 00:19:50 2005 +++ xoops2jp/html/modules/comment/class/CommentActionFrame.class.php Thu Feb 2 18:29:00 2006 @@ -1,173 +0,0 @@ -<?php -// $Id: CommentActionFrame.class.php,v 1.1.2.2 2005/11/24 15:19:50 minahito Exp $ -// ------------------------------------------------------------------------ // -// XOOPS - PHP Content Management System // -// Copyright (c) 2005 XOOPS Cube.org // -// <http://www.xoopscube.org/> // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // - -require_once XOOPS_ROOT_PATH."/class/XCube_ActionStrategy.class.php"; - -define ("COMMENT_FRAME_PERFORM_SUCCESS",1); -define ("COMMENT_FRAME_PERFORM_FAIL",2); -define ("COMMENT_FRAME_INIT_SUCCESS",3); - -define ("COMMENT_FRAME_VIEW_NONE",1); -define ("COMMENT_FRAME_VIEW_SUCCESS",1); -define ("COMMENT_FRAME_VIEW_ERROR",2); -define ("COMMENT_FRAME_VIEW_INDEX",3); -define ("COMMENT_FRAME_VIEW_INPUT",4); - -/** - * This is simple frame work for misc page controller. - * @package user - */ -class CommentActionFrame extends XCube_ActionStrategy -{ - var $mActionName=""; - var $mAction; - - var $mAdminFlag=false; - - function CommentActionFrame($admin=false) - { - $this->mAdminFlag=$admin; - } - - function setActionName($name) - { - $this->mActionName=$name; - } - - function execute(&$controller) - { - if(!preg_match("/^\w+$/",$this->mActionName)) - die(); - - // - // Create action object by mActionName - // - $className="Comment".ucfirst($this->mActionName)."Action"; - $fileName=null; - if($this->mAdminFlag) { - $fileName=XOOPS_MODULE_PATH."/comment/admin/actions/${className}.class.php"; - } - else { - $fileName=XOOPS_MODULE_PATH."/comment/actions/${className}.class.php"; - } - if(!file_exists($fileName)) - die(); // TODO - - require_once $fileName; - if(class_exists($className)) - $this->mAction=new $className(); - - if(!is_object($this->mAction)) - die(); // TODO - - $this->mAction->prepare($controller,$controller->getXoopsUser()); - - if(xoops_getenv("REQUEST_METHOD")=="POST") { - $viewStatus=$this->mAction->execute($controller,$controller->getXoopsUser()); - } - else { - $viewStatus=$this->mAction->getDefaultView($controller,$controller->getXoopsUser()); - } - - switch($viewStatus) { - case COMMENT_FRAME_VIEW_SUCCESS: - $this->mAction->executeViewSuccess($controller,$controller->getXoopsUser(),$controller->mRenderSystem); - break; - - case COMMENT_FRAME_VIEW_ERROR: - $this->mAction->executeViewError($controller,$controller->getXoopsUser(),$controller->mRenderSystem); - break; - - case COMMENT_FRAME_VIEW_INDEX: - $this->mAction->executeViewIndex($controller,$controller->getXoopsUser(),$controller->mRenderSystem); - break; - - case COMMENT_FRAME_VIEW_INPUT: - $this->mAction->executeViewInput($controller,$controller->getXoopsUser(),$controller->mRenderSystem); - break; - } - } -} - -class CommentAction -{ - var $mClient; - - function CommentAction() - { - } - - function prepare(&$controller,&$xoopsUser) - { - $controller->mRoot->mLanguageManager->loadModuleLanguage("comment"); - $this->_processService($controller); - } - - /** - * @param $controller Base_Controller - * @param $xoopsUser XoopsUserObject - */ - function getDefaultView(&$controller,&$xoopsUser) - { - return COMMENT_FRAME_VIEW_NONE; - } - - function execute() - { - return COMMENT_FRAME_VIEW_NONE; - } - - function _processService($controller) - { - $service=&$controller->mRoot->mServiceManager->searchXCubeService('Comment'); - if($service==null) { - die(); // FIXME - } - - $this->mClient=new XCube_ServiceClient($service); - $parameters=array('rule'=>$controller->mModuleController->getConfig('com_rule')); - $result=&$this->mClient->call("setConfig",$parameters); - } - - function executeViewSuccess(&$controller,&$xoopsUser,&$renderSystem) - { - } - - function executeViewError(&$controller,&$xoopsUser,&$renderSystem) - { - } - - function executeViewIndex(&$controller,&$xoopsUser,&$renderSystem) - { - } - - function executeViewInput(&$controller,&$xoopsUser,&$renderSystem) - { - } -} - -?> \ No newline at end of file