Minahito
minah****@users*****
2006年 8月 1日 (火) 19:28:30 JST
Index: xoops2jp/html/modules/base/admin/actions/ActSearchAction.class.php diff -u xoops2jp/html/modules/base/admin/actions/ActSearchAction.class.php:1.1.2.6 xoops2jp/html/modules/base/admin/actions/ActSearchAction.class.php:1.1.2.7 --- xoops2jp/html/modules/base/admin/actions/ActSearchAction.class.php:1.1.2.6 Mon Jul 31 19:31:40 2006 +++ xoops2jp/html/modules/base/admin/actions/ActSearchAction.class.php Tue Aug 1 19:28:30 2006 @@ -5,21 +5,22 @@ require_once XOOPS_BASE_PATH."/class/Legacy_ModuleAdapter.class.php"; require_once XOOPS_BASE_PATH."/admin/forms/ActionSearchForm.class.php"; -class ActionSearchEventArgs +class Legacy_ActionSearchArgs { var $mKeywords; var $mRecords; - function ActionSearchEventArgs($words) + function Legacy_ActionSearchArgs($words) { $this->setKeywords($words); } function setKeywords($words) { - foreach(explode(" ",$words) as $word) { - if(strlen($word)>0) - $this->mKeywords[]=$word; + foreach (explode(" ", $words) as $word) { + if( strlen($word) > 0) { + $this->mKeywords[] = $word; + } } } @@ -28,9 +29,9 @@ return $this->mKeywords; } - function addRecord($moduleName,$url,$title,$desc=null) + function addRecord($moduleName, $url, $title, $desc = null) { - $this->mRecords[]=new ActionSearchRecord($moduleName,$url,$title,$desc); + $this->mRecords[] =& new Legacy_ActionSearchRecord($moduleName, $url, $title, $desc); } function &getRecords() @@ -43,23 +44,28 @@ */ function hasRecord() { - return count($this->mRecords)>0; + return count($this->mRecords) > 0; } } -class ActionSearchRecord +/** + * An item on one search record. This is a class as a structure. + * + * @todo we may change it to Array. + */ +class Legacy_ActionSearchRecord { var $mModuleName; var $mActionUrl; var $mTitle; var $mDescription; - function ActionSearchRecord($moduleName,$url,$title,$desc=null) + function Legacy_ActionSearchRecord($moduleName, $url, $title, $desc=null) { - $this->mModuleName=$moduleName; - $this->mActionUrl=$url; - $this->mTitle=$title; - $this->mDescription=$desc; + $this->mModuleName = $moduleName; + $this->mActionUrl = $url; + $this->mTitle = $title; + $this->mDescription = $desc; } } @@ -71,10 +77,10 @@ */ class Legacy_ActSearchAction extends Legacy_Action { - var $mModules=array(); - var $mModuleRecords=null; - var $mRecords=null; - var $mActionForm; + var $mModules = array(); + var $mModuleRecords = null; + var $mRecords = null; + var $mActionForm = null; var $mSearchAction = null; @@ -86,11 +92,12 @@ $this->mSearchAction->register('Legacy_ActSearchAction.SearchAction'); } - function prepare(&$controller,&$xoopsUser) + function prepare(&$controller, &$xoopsUser) { - parent::prepare(&$controller,&$xoopsUser); + parent::prepare(&$controller, &$xoopsUser); $db=&$controller->getDB(); + // // TODO : We don't use handler and write sql directly. // @@ -98,21 +105,23 @@ "WHERE {mod}.mid={perm}.gperm_itemid AND {perm}.gperm_name='module_admin' AND {perm}.gperm_groupid IN ({groups}) ". "ORDER BY {mod}.weight"; - $replaceMap=array("mod"=>$db->prefix("modules"), - "perm"=>$db->prefix("group_permission"), - "groups"=>implode(",",$xoopsUser->getGroups())); - - $sql=XCube_Utils::formatMessageByMap($sql,$replaceMap); - - $result=$db->query($sql); - while($row=$db->fetchArray($result)) { - $xoopsModule = new XoopsModule(); + $replaceMap = array( + "mod"=>$db->prefix("modules"), + "perm"=>$db->prefix("group_permission"), + "groups"=>implode(",",$xoopsUser->getGroups()) + ); + + $sql = XCube_Utils::formatMessageByMap($sql,$replaceMap); + + $result = $db->query($sql); + while ($row = $db->fetchArray($result)) { + $xoopsModule =& new XoopsModule(); $xoopsModule->assignVars($row); - $adapter=new Legacy_ModuleAdapter($xoopsModule); + $adapter =& new Legacy_ModuleAdapter($xoopsModule); $adapter->prepareAdmin($controller); - $this->mModules[]=&$adapter; + $this->mModules[] =& $adapter; unset($xoopsModule); unset($adapter); @@ -125,27 +134,28 @@ return $permHandler->checkRight('module_admin', -1, $xoopsUser->getGroups()); } - function getDefaultView(&$controller,&$xoopsUser) + function getDefaultView(&$controller, &$xoopsUser) { $this->_processActionForm(); return LEGACY_FRAME_VIEW_INPUT; } - function execute(&$controller,&$xoopsUser) + function execute(&$controller, &$xoopsUser) { $this->_processActionForm(); $this->mActionForm->fetch(); $this->mActionForm->validate(); - if($this->mActionForm->hasError()) + if($this->mActionForm->hasError()) { return LEGACY_FRAME_VIEW_INPUT; + } - $eventArgs=new ActionSearchEventArgs($this->mActionForm->getVar('keywords')); - $this->mSearchAction->call(new XCube_Ref($eventArgs)); + $searchArgs =& new Legacy_ActionSearchArgs($this->mActionForm->get('keywords')); + $this->mSearchAction->call(new XCube_Ref($searchArgs)); - if($eventArgs->hasRecord()) { - $this->mRecords=&$eventArgs->getRecords(); + if ($searchArgs->hasRecord()) { + $this->mRecords =& $searchArgs->getRecords(); return LEGACY_FRAME_VIEW_SUCCESS; } else { @@ -155,21 +165,21 @@ function _processActionForm() { - $this->mActionForm=new ActionSearchForm(); + $this->mActionForm =& new Legacy_ActionSearchForm(); $this->mActionForm->prepare(); } - function executeViewSuccess(&$controller,&$xoopsUser,&$renderSystem) + function executeViewSuccess(&$controller, &$xoopsUser, &$render) { - $renderSystem->setTemplateName("legacy_admin_actionsearch_success.html"); - $renderSystem->setAttribute("records",$this->mRecords); - $renderSystem->setAttribute("actionForm",$this->mActionForm); + $render->setTemplateName("legacy_admin_actionsearch_success.html"); + $render->setAttribute("records", $this->mRecords); + $render->setAttribute("actionForm", $this->mActionForm); } - function executeViewInput(&$controller,&$xoopsUser,&$renderSystem) + function executeViewInput(&$controller, &$xoopsUser, &$render) { - $renderSystem->setTemplateName("legacy_admin_actionsearch_input.html"); - $renderSystem->setAttribute("actionForm",$this->mActionForm); + $render->setTemplateName("legacy_admin_actionsearch_input.html"); + $render->setAttribute("actionForm", $this->mActionForm); } }