NobuNobu
nobun****@users*****
2007年 4月 30日 (月) 16:35:42 JST
Index: xoops2jp/html/modules/legacyRender/class/AbstractDeleteAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/class/AbstractDeleteAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:42 2007 +++ xoops2jp/html/modules/legacyRender/class/AbstractDeleteAction.class.php Mon Apr 30 16:35:42 2007 @@ -0,0 +1,20 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractEditAction.class.php"; + +class LegacyRender_AbstractDeleteAction extends LegacyRender_AbstractEditAction +{ + function isEnableCreate() + { + return false; + } + + function _doExecute() + { + return $this->mObjectHandler->delete($this->mObject); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/class/AbstractEditAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/class/AbstractEditAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:42 2007 +++ xoops2jp/html/modules/legacyRender/class/AbstractEditAction.class.php Mon Apr 30 16:35:42 2007 @@ -0,0 +1,89 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyRender_AbstractEditAction extends LegacyRender_Action +{ + var $mObject = null; + var $mObjectHandler = null; + var $mActionForm = null; + + function _getId() + { + } + + function &_getHandler() + { + } + + function _setupActionForm() + { + } + + function _setupObject() + { + $id = $this->_getId(); + + $this->mObjectHandler = $this->_getHandler(); + + $this->mObject =& $this->mObjectHandler->get($id); + + if ($this->mObject == null && $this->isEnableCreate()) { + $this->mObject =& $this->mObjectHandler->create(); + } + } + + function isEnableCreate() + { + return true; + } + + function prepare(&$controller, &$xoopsUser) + { + $this->_setupActionForm(); + $this->_setupObject(); + } + + function getDefaultView(&$controller, &$xoopsUser) + { + if ($this->mObject == null) { + return LEGACYRENDER_FRAME_VIEW_ERROR; + } + + $this->mActionForm->load($this->mObject); + + return LEGACYRENDER_FRAME_VIEW_INPUT; + } + + function execute(&$controller, &$xoopsUser) + { + if ($this->mObject == null) { + return LEGACYRENDER_FRAME_VIEW_ERROR; + } + + if (xoops_getrequest('_form_control_cancel') != null) { + return LEGACYRENDER_FRAME_VIEW_CANCEL; + } + + $this->mActionForm->load($this->mObject); + + $this->mActionForm->fetch(); + $this->mActionForm->validate(); + + if($this->mActionForm->hasError()) { + return LEGACYRENDER_FRAME_VIEW_INPUT; + } + + $this->mActionForm->update($this->mObject); + + return $this->_doExecute($this->mObject) ? LEGACYRENDER_FRAME_VIEW_SUCCESS + : LEGACYRENDER_FRAME_VIEW_ERROR; + } + + function _doExecute() + { + return $this->mObjectHandler->insert($this->mObject); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/class/AbstractFilterForm.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/class/AbstractFilterForm.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:42 2007 +++ xoops2jp/html/modules/legacyRender/class/AbstractFilterForm.class.php Mon Apr 30 16:35:42 2007 @@ -0,0 +1,76 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyRender_AbstractFilterForm +{ + var $mSort = 0; + var $mSortKeys = array(); + var $_mCriteria = null; + var $mNavi = null; + + var $_mHandler = null; + + function LegacyRender_AbstractFilterForm(&$navi, &$handler) + { + $this->mNavi =& $navi; + $this->_mHandler =& $handler; + + $this->_mCriteria =& new CriteriaCompo(); + + $this->mNavi->mGetTotalItems->add(array(&$this, 'getTotalItems')); + } + + function getDefaultSortKey() + { + } + + function getTotalItems(&$total) + { + $total = $this->_mHandler->getCount($this->getCriteria()); + } + + function fetchSort() + { + $root =& XCube_Root::getSingleton(); + $this->mSort = intval($root->mContext->mRequest->getRequest('sort')); + + if (!isset($this->mSortKeys[abs($this->mSort)])) { + $this->mSort = $this->getDefaultSortKey(); + } + + $this->mNavi->mSort['sort'] = $this->mSort; + } + + function fetch() + { + $this->mNavi->fetch(); + $this->fetchSort(); + } + + function getSort() + { + $sortkey = abs($this->mNavi->mSort['sort']); + return isset($this->mSortKeys[$sortkey]) ? $this->mSortKeys[$sortkey] : null; + } + + function getOrder() + { + return ($this->mSort < 0) ? "DESC" : "ASC"; + } + + function getCriteria($start = null, $limit = null) + { + $t_start = ($start === null) ? $this->mNavi->getStart() : intval($start); + $t_limit = ($limit === null) ? $this->mNavi->getPerpage() : intval($limit); + + $criteria = $this->_mCriteria; + + $criteria->setStart($t_start); + $criteria->setLimit($t_limit); + + return $criteria; + } +} + +?> Index: xoops2jp/html/modules/legacyRender/class/AbstractListAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/class/AbstractListAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:42 2007 +++ xoops2jp/html/modules/legacyRender/class/AbstractListAction.class.php Mon Apr 30 16:35:42 2007 @@ -0,0 +1,42 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_ROOT_PATH . "/core/XCube_PageNavigator.class.php"; + +class LegacyRender_AbstractListAction extends LegacyRender_Action +{ + var $mObjects = array(); + var $mFilter = null; + + function &_getHandler() + { + } + + function &_getFilterForm() + { + } + + function _getBaseUrl() + { + } + + function &_getPageNavi() + { + $navi =& new XCube_PageNavigator($this->_getBaseUrl(), XCUBE_PAGENAVI_START); + return $navi; + } + + function getDefaultView(&$controller, &$xoopsUser) + { + $this->mFilter =& $this->_getFilterForm(); + $this->mFilter->fetch(); + + $handler =& $this->_getHandler(); + $this->mObjects =& $handler->getObjects($this->mFilter->getCriteria()); + + return LEGACYRENDER_FRAME_VIEW_INDEX; + } +} + +?> Index: xoops2jp/html/modules/legacyRender/class/ActionFrame.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/class/ActionFrame.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:42 2007 +++ xoops2jp/html/modules/legacyRender/class/ActionFrame.class.php Mon Apr 30 16:35:42 2007 @@ -0,0 +1,197 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +define ("LEGACYRENDER_FRAME_PERFORM_SUCCESS", 1); +define ("LEGACYRENDER_FRAME_PERFORM_FAIL", 2); +define ("LEGACYRENDER_FRAME_INIT_SUCCESS", 3); + +define ("LEGACYRENDER_FRAME_VIEW_NONE", 1); +define ("LEGACYRENDER_FRAME_VIEW_SUCCESS", 2); +define ("LEGACYRENDER_FRAME_VIEW_ERROR", 3); +define ("LEGACYRENDER_FRAME_VIEW_INDEX", 4); +define ("LEGACYRENDER_FRAME_VIEW_INPUT", 5); +define ("LEGACYRENDER_FRAME_VIEW_PREVIEW", 6); +define ("LEGACYRENDER_FRAME_VIEW_CANCEL", 7); + +class LegacyRender_ActionFrame +{ + var $mActionName = null; + var $mAction = null; + var $mAdminFlag = null; + + /** + * @var XCube_Delegate + */ + var $mCreateAction = null; + + function LegacyRender_ActionFrame($admin) + { + $this->mAdminFlag = $admin; + $this->mCreateAction =& new XCube_Delegate(); + $this->mCreateAction->register('LegacyRender_ActionFrame.CreateAction'); + $this->mCreateAction->add(array(&$this, '_createAction')); + } + + function setActionName($name) + { + $this->mActionName = $name; + + // + // Temp FIXME! + // + $root =& XCube_Root::getSingleton(); + $root->mContext->setAttribute('actionName', $name); + $root->mContext->mModule->setAttribute('actionName', $name); + } + + function _createAction(&$actionFrame) + { + if (is_object($actionFrame->mAction)) { + return; + } + + // + // Create action object by mActionName + // + $className = "LegacyRender_" . ucfirst($actionFrame->mActionName) . "Action"; + $fileName = ucfirst($actionFrame->mActionName) . "Action"; + if ($actionFrame->mAdminFlag) { + $fileName = XOOPS_MODULE_PATH . "/legacyRender/admin/actions/${fileName}.class.php"; + } + else { + $fileName = XOOPS_MODULE_PATH . "/legacyRender/actions/${fileName}.class.php"; + } + + if (!file_exists($fileName)) { + die(); + } + + require_once $fileName; + + if (class_exists($className)) { + $actionFrame->mAction =& new $className($actionFrame->mAdminFlag); + } + } + + function execute(&$controller) + { + if (!preg_match("/^\w+$/", $this->mActionName)) { + die(); + } + + // + // Create action object by mActionName + // + $this->mCreateAction->call(new XCube_Ref($this)); + + if (!(is_object($this->mAction) && is_a($this->mAction, 'LegacyRender_Action'))) { + die(); //< TODO + } + + $handler =& xoops_gethandler('config'); + $moduleConfig =& $handler->getConfigsByDirname('legacyRender'); + + $this->mAction->prepare($controller, $controller->mRoot->mContext->mXoopsUser, $moduleConfig); + + if (!$this->mAction->hasPermission($controller, $controller->mRoot->mContext->mXoopsUser)) { + if ($this->mAdminFlag) { + $controller->executeForward(XOOPS_URL . "/admin.php"); + } + else { + $controller->executeForward(XOOPS_URL); + } + } + + if (xoops_getenv("REQUEST_METHOD") == "POST") { + $viewStatus = $this->mAction->execute($controller, $controller->mRoot->mContext->mXoopsUser); + } + else { + $viewStatus = $this->mAction->getDefaultView($controller, $controller->mRoot->mContext->mXoopsUser); + } + + switch($viewStatus) { + case LEGACYRENDER_FRAME_VIEW_SUCCESS: + $this->mAction->executeViewSuccess($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget()); + break; + + case LEGACYRENDER_FRAME_VIEW_ERROR: + $this->mAction->executeViewError($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget()); + break; + + case LEGACYRENDER_FRAME_VIEW_INDEX: + $this->mAction->executeViewIndex($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget()); + break; + + case LEGACYRENDER_FRAME_VIEW_INPUT: + $this->mAction->executeViewInput($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget()); + break; + + case LEGACYRENDER_FRAME_VIEW_PREVIEW: + $this->mAction->executeViewPreview($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget()); + break; + + case LEGACYRENDER_FRAME_VIEW_CANCEL: + $this->mAction->executeViewCancel($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget()); + break; + } + } +} + +class LegacyRender_Action +{ + /** + * @access private + */ + var $_mAdminFlag = false; + + function LegacyRender_Action($adminFlag = false) + { + $this->_mAdminFlag = $adminFlag; + } + + function hasPermission(&$controller, &$xoopsUser) + { + return true; + } + + function prepare(&$controller, &$xoopsUser, $moduleConfig) + { + } + + function getDefaultView(&$controller, &$xoopsUser) + { + return LEGACYRENDER_FRAME_VIEW_NONE; + } + + function execute(&$controller, &$xoopsUser) + { + return LEGACYRENDER_FRAME_VIEW_NONE; + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + } + + function executeViewIndex(&$controller, &$xoopsUser, &$render) + { + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + } + + function executeViewPreview(&$controller, &$xoopsUser, &$render) + { + } + + function executeViewCancel(&$controller, &$xoopsUser, &$render) + { + } +} + +?> Index: xoops2jp/html/modules/legacyRender/class/Module.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/class/Module.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:42 2007 +++ xoops2jp/html/modules/legacyRender/class/Module.class.php Mon Apr 30 16:35:42 2007 @@ -0,0 +1,25 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyRender_Module extends Legacy_ModuleAdapter +{ + function LegacyRender_Module(&$xoopsModule) + { + parent::Legacy_ModuleAdapter($xoopsModule); + $this->mGetAdminMenu =& new XCube_Delegate(); + $this->mGetAdminMenu->register('LegacyRender_Module.getAdminMenu'); + } + + function getAdminMenu() + { + $menu = parent::getAdminMenu(); + $this->mGetAdminMenu->call(new XCube_Ref($menu)); + + ksort($menu); + + return $menu; + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/legacyRender/class/banner.php diff -u /dev/null xoops2jp/html/modules/legacyRender/class/banner.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:42 2007 +++ xoops2jp/html/modules/legacyRender/class/banner.php Mon Apr 30 16:35:42 2007 @@ -0,0 +1,41 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyRenderBannerObject extends XoopsSimpleObject +{ + var $mClient = null; + var $_mClientLoadedFlag = false; + + function LegacyRenderBannerObject() + { + $this->initVar('bid', XOBJ_DTYPE_INT, '', false); + $this->initVar('cid', XOBJ_DTYPE_INT, '0', true); + $this->initVar('imptotal', XOBJ_DTYPE_INT, '0', true); + $this->initVar('impmade', XOBJ_DTYPE_INT, '0', true); + $this->initVar('clicks', XOBJ_DTYPE_INT, '0', true); + $this->initVar('imageurl', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('clickurl', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('date', XOBJ_DTYPE_INT, time(), true); + $this->initVar('htmlbanner', XOBJ_DTYPE_BOOL, '0', true); + $this->initVar('htmlcode', XOBJ_DTYPE_TEXT, '', true); + } + + function loadBannerclient() + { + if ($this->_mClientLoadedFlag == false) { + $handler =& xoops_getmodulehandler('bannerclient', 'legacyRender'); + $this->mClient =& $handler->get($this->get('cid')); + $this->_mClientLoadedFlag = true; + } + } +} + +class LegacyRenderBannerHandler extends XoopsObjectGenericHandler +{ + var $mTable = "banner"; + var $mPrimary = "bid"; + var $mClass = "LegacyRenderBannerObject"; +} + +?> Index: xoops2jp/html/modules/legacyRender/class/bannerclient.php diff -u /dev/null xoops2jp/html/modules/legacyRender/class/bannerclient.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:42 2007 +++ xoops2jp/html/modules/legacyRender/class/bannerclient.php Mon Apr 30 16:35:42 2007 @@ -0,0 +1,106 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyRenderBannerclientObject extends XoopsSimpleObject +{ + var $mBanners = array(); + var $_mBannersLoadedFlag = false; + + /** + * @todo A name of this property is a strange. banner finish? + */ + var $mFinishBanners = array(); + var $_mFinishBannersLoadedFlag = false; + + var $mBannerCount = null; + var $_mBannerCountLoadedFlag = false; + + var $mFinishBannerCount = null; + var $_mFinishBannerCountLoadedFlag = false; + + function LegacyRenderBannerclientObject() + { + $this->initVar('cid', XOBJ_DTYPE_INT, '', false); + $this->initVar('name', XOBJ_DTYPE_STRING, '', true, 60); + $this->initVar('contact', XOBJ_DTYPE_STRING, '', true, 60); + $this->initVar('email', XOBJ_DTYPE_STRING, '', true, 60); + $this->initVar('login', XOBJ_DTYPE_STRING, '', true, 10); + $this->initVar('passwd', XOBJ_DTYPE_STRING, '', true, 10); + $this->initVar('extrainfo', XOBJ_DTYPE_TEXT, '', true); + } + + function loadBanner() + { + if ($this->_mBannersLoadedFlag == false) { + $handler =& xoops_getmodulehandler('banner', 'legacyRender'); + $this->mBanners =& $handler->getObjects(new Criteria('cid', $this->get('cid'))); + $this->_mBannersLoadedFlag = true; + } + } + + function loadBannerCount() + { + if ($this->_mBannerCountLoadedFlag == false) { + $handler =& xoops_getmodulehandler('banner', 'legacyRender'); + $this->mBannerCount = $handler->getCount(new Criteria('cid', $this->get('cid'))); + $this->_mBannerCountLoadedFlag = true; + } + } + + function &createBanner() + { + $handler =& xoops_getmodulehandler('banner', 'legacyRender'); + $obj =& $handler->create(); + $obj->set('cid', $this->get('cid')); + return $obj; + } + + function loadBannerfinish() + { + if ($this->_mFinishBannersLoadedFlag == false) { + $handler =& xoops_getmodulehandler('bannerfinish', 'legacyRender'); + $this->mFinishBanners =& $handler->getObjects(new Criteria('cid', $this->get('cid'))); + $this->_mFinishBannersLoadedFlag = true; + } + } + + function loadFinishBannerCount() + { + if ($this->_mFinishBannerCountLoadedFlag == false) { + $handler =& xoops_getmodulehandler('bannerfinish', 'legacyRender'); + $this->mFinishBannerCount = $handler->getCount(new Criteria('cid', $this->get('cid'))); + $this->_mFinishBannerCountLoadedFlag = true; + } + } + + function &createBannerfinish() + { + $handler =& xoops_getmodulehandler('bannerfinish', 'legacyRender'); + $obj =& $handler->create(); + $obj->set('cid', $this->get('cid')); + return $obj; + } +} + +class LegacyRenderBannerclientHandler extends XoopsObjectGenericHandler +{ + var $mTable = "bannerclient"; + var $mPrimary = "cid"; + var $mClass = "LegacyRenderBannerclientObject"; + + function delete(&$obj) + { + $handler =& xoops_getmodulehandler('banner', 'legacyRender'); + $handler->deleteAll(new Criteria('cid', $obj->get('cid'))); + unset($handler); + + $handler =& xoops_getmodulehandler('bannerfinish', 'legacyRender'); + $handler->deleteAll(new Criteria('cid', $obj->get('cid'))); + unset($handler); + + return parent::delete($obj); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/class/bannerfinish.php diff -u /dev/null xoops2jp/html/modules/legacyRender/class/bannerfinish.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:42 2007 +++ xoops2jp/html/modules/legacyRender/class/bannerfinish.php Mon Apr 30 16:35:42 2007 @@ -0,0 +1,37 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyRenderBannerfinishObject extends XoopsSimpleObject +{ + var $mClient = null; + var $_mClientLoadedFlag = false; + + function LegacyRenderBannerfinishObject() + { + $this->initVar('bid', XOBJ_DTYPE_INT, '', false); + $this->initVar('cid', XOBJ_DTYPE_INT, '0', true); + $this->initVar('impressions', XOBJ_DTYPE_INT, '0', true); + $this->initVar('clicks', XOBJ_DTYPE_INT, '0', true); + $this->initVar('datestart', XOBJ_DTYPE_INT, '0', true); + $this->initVar('dateend', XOBJ_DTYPE_INT, '0', true); + } + + function loadBannerclient() + { + if ($this->_mClientLoadedFlag == false) { + $handler =& xoops_getmodulehandler('bannerclient', 'legacyRender'); + $this->mClient =& $handler->get($this->get('cid')); + $this->_mClientLoadedFlag = true; + } + } +} + +class LegacyRenderBannerfinishHandler extends XoopsObjectGenericHandler +{ + var $mTable = "bannerfinish"; + var $mPrimary = "bid"; + var $mClass = "LegacyRenderBannerfinishObject"; +} + +?> Index: xoops2jp/html/modules/legacyRender/class/index.html diff -u /dev/null xoops2jp/html/modules/legacyRender/class/index.html:1.1.4.1 --- /dev/null Mon Apr 30 16:35:42 2007 +++ xoops2jp/html/modules/legacyRender/class/index.html Mon Apr 30 16:35:42 2007 @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Index: xoops2jp/html/modules/legacyRender/class/theme.php diff -u /dev/null xoops2jp/html/modules/legacyRender/class/theme.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:42 2007 +++ xoops2jp/html/modules/legacyRender/class/theme.php Mon Apr 30 16:35:42 2007 @@ -0,0 +1,146 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyRenderThemeObject extends XoopsSimpleObject +{ + var $mPackage = array(); + var $mActiveResource = true; + + function LegacyRenderThemeObject() + { + $this->initVar('id', XOBJ_DTYPE_INT, '', true); + $this->initVar('name', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('tplset_id', XOBJ_DTYPE_INT, '0', true); + $this->initVar('enable_select', XOBJ_DTYPE_BOOL, '0', true); + } + + function loadPackage() + { + $themeDir = XOOPS_THEME_PATH . "/" . $this->get('name'); + + if (file_exists($mnfFile = $themeDir . "/manifesto.ini.php")) { + $this->mPackage = parse_ini_file($mnfFile, true); + } + + if (isset($this->mPackage['Manifesto'])) { + // + // If this system can use this theme, add this to list. + // + if (isset($this->mPackage['Manifesto']) && isset($this->mPackage['Manifesto']['Depends'])) { + $this->mActiveResource = ($this->mPackage['Manifesto']['Depends'] == "Legacy_RenderSystem"); + } + } + else { + $file = XOOPS_THEME_PATH . "/" . $this->get('name') . "/theme.html"; + $this->mActiveResource = file_exists($file); + } + } + + function isActiveResource() + { + return $this->mActiveResource; + } +} + +class LegacyRenderThemeHandler extends XoopsObjectGenericHandler +{ + var $mTable = "legacyrender_theme"; + var $mPrimary = "id"; + var $mClass = "LegacyRenderThemeObject"; + + function &getByName($themeName) + { + $criteria = new Criteria('name', $themeName); + $obj =& $this->getObjects($criteria); + if (count($obj) > 0) { + return $obj[0]; + } + else { + $obj =& $this->create(); + return $obj; + } + } + + /** + * Search themes that Legacy_RenderSystem can render in file system, then register by handler. + */ + function searchThemes() + { + $themeList = array(); + + if($handler=opendir(XOOPS_THEME_PATH)) { + while(($dir=readdir($handler))!==false) { + if($dir=="." || $dir=="..") { + continue; + } + + $themeDir=XOOPS_THEME_PATH."/".$dir; + if(is_dir($themeDir)) { + $manifesto = array(); + if (file_exists($mnfFile = $themeDir . "/manifesto.ini.php")) { + $manifesto = parse_ini_file($mnfFile, true); + } + + if(count($manifesto) > 0) { + // + // If this system can use this theme, add this to list. + // + if(isset($manifesto['Manifesto']) && isset($manifesto['Manifesto']['Depends']) && preg_match('/Legacy_RenderSystem(\s|,|$)/', $manifesto['Manifesto']['Depends'])) { + $themeList[]=$dir; + } + } + else { + $file=$themeDir."/theme.html"; + if(file_exists($file)) { + $themeList[]=$dir; + } + } + } + } + closedir($handler); + } + + return $themeList; + } + + function updateThemeList() + { + $diskThemeNames = $this->searchThemes(); + $DBthemes =& $this->getObjects(); + + // + // At first, check new theme. + // + foreach ($diskThemeNames as $name) { + $findFlag = false; + foreach ($DBthemes as $theme) { + if ($theme->get('name') == $name) { + $findFlag = true; + break; + } + } + + // + // If $findFlag is false, $name is new theme that is not registered to DB, yet. + // + if (!$findFlag) { + $obj =& $this->create(); + $obj->set('name', $name); + $this->insert($obj, true); + } + } + + // + // Next, check themes that we got from DB. If it had removed from disk system, + // We also have to remove from DB. + // + foreach ($DBthemes as $theme) { + if (!in_array($theme->get('name'), $diskThemeNames)) { + $this->delete($theme, true); + } + } + } +} + +?> Index: xoops2jp/html/modules/legacyRender/class/tplfile.php diff -u /dev/null xoops2jp/html/modules/legacyRender/class/tplfile.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:42 2007 +++ xoops2jp/html/modules/legacyRender/class/tplfile.php Mon Apr 30 16:35:42 2007 @@ -0,0 +1,220 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyRenderTplfileObject extends XoopsSimpleObject +{ + /** + * @access public + * @todo mSource + */ + var $Source = null; + + var $mOverride = null; + + function LegacyRenderTplfileObject() + { + $this->initVar('tpl_id', XOBJ_DTYPE_INT, '', true); + $this->initVar('tpl_refid', XOBJ_DTYPE_INT, '0', true); + $this->initVar('tpl_module', XOBJ_DTYPE_STRING, '', true, 25); + $this->initVar('tpl_tplset', XOBJ_DTYPE_STRING, '', true, 50); + $this->initVar('tpl_file', XOBJ_DTYPE_STRING, '', true, 50); + $this->initVar('tpl_desc', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('tpl_lastmodified', XOBJ_DTYPE_INT, '0', true); + $this->initVar('tpl_lastimported', XOBJ_DTYPE_INT, '0', true); + $this->initVar('tpl_type', XOBJ_DTYPE_STRING, '', true, 20); + } + + function loadSource() + { + if (!is_object($this->Source)) { + $handler =& xoops_getmodulehandler('tplsource', 'legacyRender'); + $this->Source =& $handler->get($this->get('tpl_id')); + if (!is_object($this->Source)) { + $this->Source =& $handler->create(); + } + } + } + + /** + * Create the clone with source for the template set that is specified by $tplsetName. + * + * @param $tplsetName string + * @return object LegacyRenderTplfileObject + */ + function &createClone($tplsetName) + { + $this->loadSource(); + + $obj =& new LegacyRenderTplfileObject(); + + $obj->set('tpl_refid', $this->get('tpl_refid')); + $obj->set('tpl_module', $this->get('tpl_module')); + + $obj->set('tpl_tplset', $tplsetName); + + $obj->set('tpl_file', $this->get('tpl_file')); + $obj->set('tpl_desc', $this->get('tpl_desc')); + $obj->set('tpl_lastmodified', $this->get('tpl_lastmodified')); + $obj->set('tpl_lastimported', $this->get('tpl_lastimported')); + $obj->set('tpl_type', $this->get('tpl_type')); + + $handler =& xoops_getmodulehandler('tplsource', 'legacyRender'); + $obj->Source =& $handler->create(); + + $obj->Source->set('tpl_source', $this->Source->get('tpl_source')); + + return $obj; + } + + /** + * Load override template file object by $tplset that is the name of template-set specified. + * And, set it to mOverride. + */ + function loadOverride($tplset) + { + if ($tplset == 'default' || $this->mOverride != null) { + return; + } + + $handler =& xoops_getmodulehandler('tplfile', 'legacyRender'); + + $criteria =& new CriteriaCompo(); + $criteria->add(new Criteria('tpl_tplset', $tplset)); + $criteria->add(new Criteria('tpl_file', $this->get('tpl_file'))); + + $objs =& $handler->getObjects($criteria); + if (count($objs) > 0) { + $this->mOverride =& $objs[0]; + } + } +} + +class LegacyRenderTplfileHandler extends XoopsObjectGenericHandler +{ + var $mTable = "tplfile"; + var $mPrimary = "tpl_id"; + var $mClass = "LegacyRenderTplfileObject"; + + function insert(&$obj, $force = false) + { + if (!parent::insert($obj, $force)) { + return false; + } + + $obj->loadSource(); + + if (!is_object($obj->Source)) { + return true; + } + else { + $handler =& xoops_getmodulehandler('tplsource', 'legacyRender'); + + if ($obj->Source->isNew()) { + $obj->Source->set('tpl_id', $obj->get('tpl_id')); + } + + return $handler->insert($obj->Source, $force); + } + } + + /** + * This method load objects of two template sets by $criteria. Then, build + * the return value from the objects of 'default', and set the objects of + * $tplset to object->mOverride. + */ + function &getObjectsWithOverride($criteria, $tplset) + { + $objs =& $this->getObjects($criteria); + + $ret = array(); + + $i = 0; + foreach (array_keys($objs) as $srckey) { + if ($objs[$srckey]->get('tpl_tplset') == 'default') { + $ret[$i] =& $objs[$srckey]; + + // + // Find the same object in $tplset, set it to mOverride. + // + foreach (array_keys($objs) as $destkey) { + if ($objs[$srckey]->get('tpl_file') == $objs[$destkey]->get('tpl_file') && $objs[$destkey]->get('tpl_tplset') == $tplset) { + $ret[$i]->mOverride =& $objs[$destkey]; + } + } + + $i++; + } + } + + return $ret; + } + + function delete(&$obj, $force = false) + { + $obj->loadSource(); + + if (is_object($obj->Source)) { + $handler =& xoops_getmodulehandler('tplsource', 'legacyRender'); + if (!$handler->delete($obj->Source, $force)) { + return false; + } + } + + return parent::delete($obj, $force); + } + + /** + * This is a kind of getObjects(). Return objects that were modified recently. + * + * @param $limit int + * @return array array of the object + */ + function &getRecentModifyFile($limit = 10) + { + $criteria = new Criteria('tpl_id', 0, '>'); + + $criteria->setLimit($limit); + + $criteria->setSort('tpl_lastmodified'); + $criteria->setOrder('DESC'); + + $objs =& $this->getObjects($criteria); + + return $objs; + } + + /** + * This is a kind of getObjects(). Call getObjects() by 5 parameters and return + * the result. Parameters are guaranteed Type Safe because these are used by + * getObjects() for XoopsSimpleObject. + * + * @param $tplsetName string + * @param $type string + * @param $refId int + * @param $module string + * @param $file string + * @return array array of the object. + */ + function &find($tplsetName, $type = null, $refId = null, $module = null, $file = null) { + $criteria =& new CriteriaCompo(); + $criteria->add(new Criteria('tpl_tplset', $tplsetName)); + if ($type != null) { + $criteria->add(new Criteria('tpl_type', $type)); + } + if ($refId != null) { + $criteria->add(new Criteria('tpl_refid', $refId)); + } + if ($module != null) { + $criteria->add(new Criteria('tpl_module', $module)); + } + if ($file != null) { + $criteria->add(new Criteria('tpl_file', $file)); + } + + $objs =& $this->getObjects($criteria); + return $objs; + } +} + +?> Index: xoops2jp/html/modules/legacyRender/class/tplset.php diff -u /dev/null xoops2jp/html/modules/legacyRender/class/tplset.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:42 2007 +++ xoops2jp/html/modules/legacyRender/class/tplset.php Mon Apr 30 16:35:42 2007 @@ -0,0 +1,94 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyRenderModuletplObject extends XoopsSimpleObject +{ + function LegacyRenderModuletplObject() + { + $this->initVar('mid', XOBJ_DTYPE_INT, '', true); + $this->initVar('name', XOBJ_DTYPE_STRING, '', true, 150); + $this->initVar('dirname', XOBJ_DTYPE_STRING, '', true, 150); + $this->initVar('count', XOBJ_DTYPE_INT, 0, true); + } +} + +class LegacyRenderTplsetObject extends XoopsSimpleObject +{ + var $mModuleTemplates = array(); + + function LegacyRenderTplsetObject() + { + $this->initVar('tplset_id', XOBJ_DTYPE_INT, '', true); + $this->initVar('tplset_name', XOBJ_DTYPE_STRING, '', true, 50); + $this->initVar('tplset_desc', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('tplset_credits', XOBJ_DTYPE_TEXT, '', true); + $this->initVar('tplset_created', XOBJ_DTYPE_INT, time(), true); + } + + function loadModuletpl() + { + // + // get module list + // + $moduleHandler =& xoops_gethandler('module'); + $modules =& $moduleHandler->getObjects(); + + $tplfileHandler =& xoops_getmodulehandler('tplfile', 'legacyRender'); + + foreach ($modules as $module) { + $modtpl =& new LegacyRenderModuletplObject(); + + $modtpl->set('mid', $module->get('mid')); + $modtpl->set('dirname', $module->get('dirname')); + $modtpl->set('name', $module->get('name')); + + $criteria = new CriteriaCompo(); + $criteria->add(new Criteria('tpl_module', $module->get('dirname'))); + $criteria->add(new Criteria('tpl_tplset', $this->get('tplset_name'))); + + $count = $tplfileHandler->getCount($criteria); + $modtpl->set('count', $count); + + $this->mModuleTemplates[] =& $modtpl; + unset($modtpl); + } + } +} + +class LegacyRenderTplsetHandler extends XoopsObjectGenericHandler +{ + var $mTable = "tplset"; + var $mPrimary = "tplset_id"; + var $mClass = "LegacyRenderTplsetObject"; + + function insertClone($original, $clone) + { + if (!$this->insert($clone)) { + return false; + } + + // + // fetch all tplfile object and do cloning. + // + $handler =& xoops_getmodulehandler('tplfile', 'legacyRender'); + + $files =& $handler->getObjects(new Criteria('tpl_tplset', $original->get('tplset_name'))); + foreach ($files as $file) { + $cloneFile =& $file->createClone($clone->get('tplset_name')); + $handler->insert($cloneFile); + } + + return true; ///< TODO + } + + function delete(&$obj, $force) + { + $handler =& xoops_getmodulehandler('tplfile', 'legacyRender'); + $handler->deleteAll(new Criteria('tpl_tplset', $obj->get('tplset_name'))); + + return parent::delete($obj, $force); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/class/tplsource.php diff -u /dev/null xoops2jp/html/modules/legacyRender/class/tplsource.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:42 2007 +++ xoops2jp/html/modules/legacyRender/class/tplsource.php Mon Apr 30 16:35:42 2007 @@ -0,0 +1,21 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyRenderTplsourceObject extends XoopsSimpleObject +{ + function LegacyRenderTplsourceObject() + { + $this->initVar('tpl_id', XOBJ_DTYPE_INT, '0', true); + $this->initVar('tpl_source', XOBJ_DTYPE_TEXT, '', true); + } +} + +class LegacyRenderTplsourceHandler extends XoopsObjectGenericHandler +{ + var $mTable = "tplsource"; + var $mPrimary = "tpl_id"; + var $mClass = "LegacyRenderTplsourceObject"; +} + +?>