示例#1
0
 /**
  * _setupCategoryManager
  *
  * @param   string  $dataname
  *
  * @return  void
  **/
 protected function _setupCategoryManager($dataname)
 {
     $moduleDirname = isset($this->mObject->mMaintable) ? $this->mObject->mMaintable->getDirname() : $this->mAsset->mDirname;
     $server = Xcck_Utils::getAccessController($moduleDirname);
     if ($server instanceof XoopsModule) {
         $serverDirname = $server->dirname();
     }
     //get server's role
     $handler = xoops_gethandler('module');
     if (!isset($serverDirname) || !($module = $handler->getByDirname($serverDirname))) {
         require_once XCCK_TRUST_PATH . '/class/NoneCategoryManager.class.php';
         $this->mCategoryManager = new Xcck_NoneCategoryManager(null, $moduleDirname, $dataname);
         return;
     }
     $role = $module->get('role');
     switch ($role) {
         case 'cat':
             require_once XCCK_TRUST_PATH . '/class/CatCategoryManager.class.php';
             $this->mCategoryManager = new Xcck_CatCategoryManager($serverDirname, $moduleDirname, $dataname);
             break;
         case 'group':
             require_once XCCK_TRUST_PATH . '/class/GroupCategoryManager.class.php';
             $this->mCategoryManager = new Xcck_GroupCategoryManager($serverDirname, $moduleDirname, $dataname);
             break;
         default:
             require_once XCCK_TRUST_PATH . '/class/NoneCategoryManager.class.php';
             $this->mCategoryManager = new Xcck_NoneCategoryManager($serverDirname, $moduleDirname, $dataname);
             break;
     }
 }
示例#2
0
 /**
  * _setupObject
  *
  * @param	void
  *
  * @return	void
  **/
 protected function _setupObject()
 {
     $id = $this->_getId();
     $this->mObjectHandler =& $this->_getHandler();
     $revisionHandler = Legacy_Utils::getModuleHandler('revision', $this->mAsset->mDirname);
     $revision = $revisionHandler->getLatestRevision($id, Lenum_Status::REJECTED);
     $this->mObject = Xcck_Utils::setupPageByRevision($revision);
 }
示例#3
0
 public function validateField_name()
 {
     $bookingFields = Xcck_Utils::getOrderList($this->_mDirname);
     $fieldName = $this->mFormProperties['field_name']->get();
     if ($this->mFormProperties['definition_id']->get() == 0 && in_array($fieldName, $bookingFields)) {
         $this->mErrorFlag = true;
         $this->addErrorMessage(_MD_XCCK_ERROR_INVALID_FIELD_NAME . implode(',', $bookingFields));
     }
 }
 /**
  * getModuleName
  * 
  * @param	string $dirname	//xcck dirname
  * 
  * @return	string
  **/
 public function getModuleName()
 {
     if ($this->mType === 'cat' || $this->mType === 'group') {
         $accessController = Xcck_Utils::getAccessController($this->_mDirname);
         if ($accessController instanceof XoopsModule) {
             return $accessController->name();
         }
     }
 }
示例#5
0
 public function updateStatus($pageId, $status)
 {
     $obj = $this->getLatestRevision($pageId);
     if (!$obj instanceof Xcck_RevisionObject) {
         return false;
     }
     $obj->set('status', $status);
     $handler = Legacy_Utils::getModuleHandler('page', $this->getDirname());
     $page = Xcck_Utils::setupPageByRevision($obj);
     return $handler->insert($page, true);
 }
示例#6
0
 public static function searchKeyword($dirname, $keywords, $andor = 'AND', $limit = null, $offset = null, $uid = null)
 {
     $cri = Xcck_Utils::getListCriteria($dirname);
     $cri = self::makeKeywordCriteria($cri, $dirname, $keywords, $andor);
     if ((int) $uid > 0) {
         $cri->add(new Criteria('uid', $uid));
     }
     $handler = Legacy_Utils::getModuleHandler('page', $dirname);
     $pageObjs = $handler->getObjects($cri, $limit, $offset);
     foreach ($pageObjs as $page) {
         $ret[] = array('link' => "index.php?page_id=" . $page->getShow('page_id'), 'title' => $page->getShow('title'), 'time' => $page->get('posttime'), 'uid' => $uid, "context" => '');
     }
     return $ret;
 }
示例#7
0
 /**
  * fetch
  * 
  * @param   string    $dirname
  * 
  * @return  void
  **/
 public function fetch($dirname)
 {
     $this->mNavi->fetch();
     $this->fetchSort();
     $this->mHandler = Legacy_Utils::getModuleHandler('definition', $dirname);
     $request = XCube_Root::getSingleton()->mContext->mRequest;
     if (($catId = $request->getRequest('category_id')) !== null) {
         $this->mNavi->addExtra('category_id', (int) $catId);
     }
     //get child category's data ?
     $child = false;
     if ($request->getRequest('child') === "all") {
         $child = true;
     } elseif ($request->getRequest('child') === "single") {
         $child = false;
     }
     $this->_mCriteria = Xcck_Utils::getListCriteria($dirname, (int) $catId, $child, $this->mSort, Lenum_Status::PUBLISHED);
     //Search previously defined fields
     $definedFields = array('name' => array('page_id', 'title', 'uid', 'maintable_id', 'posttime', 'updatetime'), 'type' => array(Xcck_FieldType::INT, Xcck_FieldType::STRING, Xcck_FieldType::INT, Xcck_FieldType::INT, Xcck_FieldType::DATE, Xcck_FieldType::DATE));
     foreach (array_keys($definedFields['name']) as $key) {
         if ($value = $request->getRequest($definedFields['name'][$key]) !== null) {
             $this->_setDefinedFieldRequest($definedFields['name'][$key], $definedFields['type'][$key], $value);
         }
     }
     //Search User defined fields
     foreach ($this->mDefinitions as $definition) {
         if ($value = $request->getRequest($definition->get('field_name')) !== null) {
             $value = $request->getRequest($definition->get('field_name'));
             $this->_setRequest($definition, $value);
         }
     }
     //Search by keyword: search all string and text field
     if (($value = $request->getRequest('keyword')) !== null) {
         $this->mNavi->addExtra('keywords', $value);
         Xcck_SearchUtils::makeKeywordCriteria($this->_mCriteria, $dirname, $value);
     }
     if (($value = $request->getRequest('child')) !== null) {
         $this->mNavi->addExtra('child', $value);
     }
     //filter by tag
     if (($tags = $request->getRequest('tag')) !== null) {
         $this->_setTagRequest($tags, $dirname);
     }
     XCube_DelegateUtils::call('Module.' . $dirname . '.FetchSearchFilter', $this);
 }
示例#8
0
 /**
  * execute
  * 
  * @param   void
  * 
  * @return  void
  * 
  * @public
  **/
 function execute()
 {
     $root =& XCube_Root::getSingleton();
     $render =& $this->getRenderTarget();
     $render->setTemplateName($this->_mBlock->get('template'));
     $render->setAttribute('block', $this->_mObject);
     $render->setAttribute('bid', $this->_mBlock->get('bid'));
     $render->setAttribute('dirname', $this->_mBlock->get('dirname'));
     $renderSystem =& $root->getRenderSystem($this->getRenderSystemName());
     $list = array();
     $category = Xcck_Utils::getAccessController($this->_mBlock->get('dirname'));
     if ($category) {
         XCube_DelegateUtils::call('Legacy_Category.' . $category->get('dirname') . '.GetTitleList', new XCube_Ref($list), $category->get('dirname'));
     }
     $render->setAttribute('catTitleList', $list);
     $renderSystem->renderBlock($render);
 }
示例#9
0
 /**
  * _setupObject
  * 
  * @param   void
  * 
  * @return  bool
  * 
  * @private
  **/
 protected function _setupObject()
 {
     $objects = array();
     $accessController = Xcck_Utils::getAccessController($this->_mBlock->get('dirname'));
     if (!$accessController instanceof XoopsModule) {
         return false;
     }
     $this->_mHandler = Legacy_Utils::getModuleHandler('page', $this->_mBlock->get('dirname'));
     XCube_DelegateUtils::call('Legacy_Category.' . $accessController->get('dirname') . '.GetTree', new XCube_Ref($this->_mObject), $accessController->get('dirname'), 'view', $this->getBlockOption('catId'));
     foreach (array_keys($this->_mObject) as $key) {
         $this->_mCount[$key] = $this->_mHandler->countPageByCategory($this->_mObject[$key]->get('cat_id'));
     }
     return true;
 }
示例#10
0
 public static function getBreadcrumbs($breadcrumbs, $dirname, $page = null)
 {
     $categoryDirname = null;
     //module name set
     $modHandler = xoops_gethandler('module');
     $module = $modHandler->getByDirname($dirname);
     $breadcrumbs[] = array('name' => $module->getVar('name'), 'url' => Legacy_Utils::renderUri($dirname));
     //catetgory name set
     if ($page instanceof Xcck_PageObject) {
         if ($page->get('category_id') > 0) {
             $accessController = Xcck_Utils::getAccessController($dirname);
             if ($accessController instanceof XoopsModule) {
                 $categoryDirname = $accessController->getVar('dirname');
             }
             switch ($accessController->getInfo('role')) {
                 case 'cat':
                     $catArr = array();
                     XCube_DelegateUtils::call('Legacy_Category.' . $categoryDirname . '.GetCatPath', new XCube_Ref($catArr), $categoryDirname, $page->get('category_id'), 'ASC');
                     foreach (array_keys($catArr['title']) as $key) {
                         $breadcrumbs[] = array('name' => $catArr['title'][$key], 'url' => Legacy_Utils::renderUri($dirname, 'page', 0, null, 'category_id=' . $catArr['cat_id'][$key]));
                     }
                     break;
                 case 'group':
                     $groupName = null;
                     XCube_DelegateUtils::call('Legacy_Category.' . $categoryDirname . '.GetTitle', new XCube_Ref($groupName), $categoryDirname, $page->get('category_id'));
                     $breadcrumbs[] = array('name' => $groupName, 'url' => Legacy_Utils::renderUri($dirname, 'page', 0, null, 'category_id=' . $page->get('category_id')));
                     break;
                 default:
             }
         }
         //parent page set
         $pageIdArr = array_reverse($page->mPath['page_id']);
         $titleArr = array_reverse($page->mPath['title']);
         foreach (array_keys($pageIdArr) as $key) {
             $breadcrumbs[] = array('name' => $titleArr[$key], 'url' => Legacy_Utils::renderUri($dirname, null, $pageIdArr[$key]));
         }
     }
 }
示例#11
0
 /**
  * &_createPermission
  * 
  * @param   int  $group
  * 
  * @return  XoopsGroupPerm
  **/
 private function &_createPermission($group)
 {
     $gpermHandler =& Xcck_Utils::getXoopsHandler('groupperm');
     $perm =& $gpermHandler->create();
     $perm->setVar('gperm_groupid', $group);
     $perm->setVar('gperm_itemid', $this->_mXoopsModule->getVar('mid'));
     $perm->setVar('gperm_modid', 1);
     return $perm;
 }
示例#12
0
 /**
  * fetch
  * 
  * @param   string	$dirname
  * 
  * @return  void
  **/
 public function fetch($dirname)
 {
     parent::fetch();
     $request = XCube_Root::getSingleton()->mContext->mRequest;
     if (($catId = $request->getRequest('category_id')) !== null) {
         $this->mNavi->addExtra('category_id', (int) $catId);
     }
     //show all term or show only from start to end date
     $show = $request->getRequest('show') === 'all' ? false : true;
     $status = $request->getRequest('status');
     $status = $show ? 10 : (isset($status) ? (int) $status : Lenum_Status::PUBLISHED);
     //get child category's data ?
     $child = false;
     if ($request->getRequest('child') === "all") {
         $child = true;
     } elseif ($request->getRequest('child') === "single") {
         $child = false;
     }
     $this->_mCriteria = Xcck_Utils::getListCriteria($dirname, (int) $catId, $child, $this->mSort, $status, $show);
     if (($value = $request->getRequest('page_id')) !== null) {
         $this->mNavi->addExtra('page_id', $value);
         $this->_mCriteria->add(new Criteria('page_id', $value));
     }
     if (($value = $request->getRequest('title')) !== null) {
         $this->_setTextRequest('title', $value);
     }
     if (($value = $request->getRequest('p_id')) !== null) {
         $this->mNavi->addExtra('p_id', $value);
         $this->_mCriteria->add(new Criteria('p_id', $value));
     }
     if (($value = $request->getRequest('descendant')) !== null) {
         $this->mNavi->addExtra('descendant', $value);
         $this->_mCriteria->add(new Criteria('descendant', $value));
     }
     if (($value = $request->getRequest('uid')) !== null) {
         $this->mNavi->addExtra('uid', $value);
         $this->_mCriteria->add(new Criteria('uid', $value));
     }
     if (($value = $request->getRequest('maintable_id')) !== null) {
         $this->mNavi->addExtra('maintable_id', $value);
         $this->_mCriteria->add(new Criteria('maintable_id', $value));
     }
     if (($value = $request->getRequest('status')) !== null) {
         $this->mNavi->addExtra('status', $value);
         //$this->_mCriteria->add(new Criteria('status', $value));
     }
     if (($value = $request->getRequest('posttime')) !== null) {
         $this->mNavi->addExtra('posttime', $value);
         $this->_mCriteria->add(new Criteria('posttime', $value));
     }
     if (($value = $request->getRequest('updatetime')) !== null) {
         $this->mNavi->addExtra('updatetime', $value);
         $this->_mCriteria->add(new Criteria('updatetime', $value));
     }
     //Search by keyword: search all string and text field
     if (($value = $request->getRequest('keyword')) !== null) {
         $this->mNavi->addExtra('keywords', $value);
         Xcck_SearchUtils::makeSearchCriteria($this->_mCriteria, $dirname, $value);
     }
     foreach ($this->mDefinitions as $definition) {
         $value = $request->getRequest($definition->get('field_name'));
         if (isset($value) && $value !== "") {
             if ($definition->get('field_type') == Xcck_FieldType::STRING || $definition->get('field_type') == Xcck_FieldType::TEXT) {
                 $this->_setTextRequest($definition->get('field_name'), $value);
             } else {
                 $this->mNavi->addExtra($definition->get('field_name'), $value);
                 $this->_mCriteria->add(new Criteria($definition->get('field_name'), $value));
             }
         }
     }
     if (($value = $request->getRequest('show')) !== null) {
         $this->mNavi->addExtra('show', $value);
     }
     if (($value = $request->getRequest('child')) !== null) {
         $this->mNavi->addExtra('child', $value);
     }
     if (($tags = $request->getRequest('tag')) !== null) {
         $this->_setTagRequest($tags, $dirname);
     }
     //$this->_mCriteria->addSort($this->getSort(), $this->getOrder());
 }
示例#13
0
 /**
  * updateConfigOrderByInfo
  * 
  * @param	Legacy_PreferenceInformation  &$info
  * @param	XoopsModule  &$module
  * @param	Legacy_ModuleInstallLog  &$log
  * 
  * @return	bool
  **/
 public static function updateConfigOrderByInfo(&$info, &$module, &$log)
 {
     $configHandler =& Xcck_Utils::getXoopsHandler('config');
     $cri = new CriteriaCompo();
     $cri->add(new Criteria('conf_modid', $module->get('mid')));
     $cri->add(new Criteria('conf_catid', 0));
     $cri->add(new Criteria('conf_name', $info->mName));
     $configs =& $configHandler->getConfigs($cri);
     if (!(count($configs) > 0 && is_object($configs[0]))) {
         $log->addError(_MI_XCCK_INSTALL_ERROR_CONFIG_NOT_FOUND);
         return false;
     }
     $config =& $configs[0];
     $config->set('conf_order', $info->mOrder);
     if (!$configHandler->insertConfig($config)) {
         $log->addError(XCube_Utils::formatString(_MI_XCCK_INSTALL_ERROR_CONFIG_UPDATED, $config->get('conf_name')));
         return false;
     }
     return true;
 }
示例#14
0
 /**
  * executeViewInput
  * 
  * @param   XCube_RenderTarget  &$render
  * 
  * @return  void
  **/
 public function executeViewInput(&$render)
 {
     $render->setTemplateName($this->mAsset->mDirname . '_page_edit.html');
     $render->setAttribute('actionForm', $this->mActionForm);
     $render->setAttribute('object', $this->mObject);
     $render->setAttribute('dirname', $this->mAsset->mDirname);
     $dataname = $this->_isSubtable() ? 'subtable' : 'page';
     $render->setAttribute('dataname', $dataname);
     $render->setAttribute('fields', $this->mDefinitions);
     $render->setAttribute('accessController', $this->mCategoryManager);
     $render->setAttribute('isSubtable', $this->_isSubtable());
     $render->setAttribute('defaultOrder', $this->mRoot->mContext->mModuleConfig['default_order']);
     // category fields
     //set categories of custom field
     $tree = array();
     foreach ($this->mDefinitions as $field) {
         if ($field->get('field_type') == Xcck_FieldType::CATEGORY) {
             $tree[$field->get('field_name')] = array();
             XCube_DelegateUtils::call('Legacy_Category.' . $field->get('options') . '.GetTree', new XCube_Ref($tree[$field->get('field_name')]), $field->get('options'), 'viewer');
         }
     }
     $render->setAttribute('catTree', $tree);
     //date field option
     $render->setAttribute('hours', range(1, 24));
     $render->setAttribute('minutes', range(0, 59));
     //set tag usage
     $render->setAttribute('useTag', $this->mRoot->mContext->mModuleConfig['tag_dirname'] ? true : false);
     $render->setAttribute('tag_dirname', $this->mRoot->mContext->mModuleConfig['tag_dirname']);
     //setup images
     $this->mObject->setupImages($isPost = false);
     $render->setAttribute('imageObjs', $this->mObject->mImage);
     $render->setAttribute('imageNameList', Xcck_Utils::getImageNameList($this->mAsset->mDirname));
 }
示例#15
0
 /**
  * getBlock
  * 
  * @param	Legacy_AbstractBlockProcedure  &$obj
  * @param	XoopsBlock	$block
  * 
  * @return	void
  **/
 public static function getBlock(&$obj, $block)
 {
     $moduleHandler =& Xcck_Utils::getXoopsHandler('module');
     $module =& $moduleHandler->get($block->get('mid'));
     if (is_object($module) && $module->getInfo('trust_dirname') === 'xcck') {
         require_once XCCK_TRUST_PATH . '/blocks/' . $block->get('func_file');
         $className = 'Xcck_' . substr($block->get('show_func'), 4);
         $obj = new $className($block);
     }
 }
示例#16
0
 /**
  * _uninstallBlocks
  * 
  * @param   void
  * 
  * @return  void
  **/
 private function _uninstallBlocks()
 {
     Xcck_InstallUtils::uninstallAllOfBlocks($this->_mXoopsModule, $this->mLog);
     $tplHandler =& Xcck_Utils::getXoopsHandler('tplfile');
     $cri = new Criteria('tpl_module', $this->_mXoopsModule->get('dirname'));
     if (!$tplHandler->deleteAll($cri)) {
         $this->mLog->addError(XCube_Utils::formatString(_MI_XCCK_INSTALL_ERROR_BLOCK_TPL_DELETED, $tplHandler->db->error()));
     }
 }
示例#17
0
 /**
  * save workflow
  *
  * @param XoopsSimpleObject    $obj
  *
  * @return    void
  */
 protected function _saveWorkflow()
 {
     $obj = $this->mRevisionHandler->getLatestRevision($this->mObject->get('page_id'));
     if (Xcck_Utils::getModuleConfig($obj->getDirname(), 'publish') === 'linear' && $obj->getShow('status') != Lenum_Status::DELETED) {
         XCube_DelegateUtils::call('Legacy_Workflow.AddItem', $obj->getShow('title'), $obj->getDirname(), 'page', $obj->get('page_id'), Legacy_Utils::renderUri($obj->getDirname(), 'revision', $obj->get('revision_id')));
     }
 }
示例#18
0
 /**
  * executeViewSuccess
  * 
  * @param   XCube_RenderTarget  &$render
  * 
  * @return  void
  **/
 public function executeViewSuccess(&$render)
 {
     $render->setTemplateName($this->mAsset->mDirname . '_page_view.html');
     $render->setAttribute('dirname', $this->mAsset->mDirname);
     $render->setAttribute('dataname', 'page');
     $render->setAttribute('catTitle', $this->mCategoryManager->getTitle($this->mObject->get('category_id')));
     $render->setAttribute('object', $this->mObject);
     $render->setAttribute('definitions', Legacy_Utils::getModuleHandler('definition', $this->mAsset->mDirname)->getFields());
     $render->setAttribute('accessController', $this->mCategoryManager);
     $render->setAttribute('useMap', $this->mRoot->mContext->mModuleConfig['use_map']);
     $render->setAttribute('commentDirname', $this->mRoot->mContext->mModuleConfig['comment_dirname']);
     //setup images
     $this->mObject->setupImages($isPost = false);
     $render->setAttribute('imageObjs', $this->mObject->mImage);
     $render->setAttribute('imageNameList', Xcck_Utils::getImageNameList($this->mAsset->mDirname));
     //setup contents tree
     $isHierarchical = $this->mRoot->mContext->mModuleConfig['hierarchical'];
     $render->setAttribute('isHierarchical', $isHierarchical);
     if ($isHierarchical == 1) {
         $render->setAttribute('pageTree', $this->mObjectHandler->getTree($this->mObject->getTopId()));
     }
     //setup subtable objects
     $render->setAttribute('isSubtable', $this->_isSubtable());
     $chandler = xoops_gethandler('config');
     $mhandler = xoops_gethandler('module');
     $subtableDirnameArr = Legacy_Utils::getDirnameListByTrustDirname('xcck');
     //page criteria
     $subtableArr = array();
     $cri = new CriteriaCompo();
     $cri->add(new Criteria('status', Lenum_Status::PUBLISHED));
     $cri->add(new Criteria('maintable_id', $this->mObject->get('page_id')));
     XCube_DelegateUtils::call('Module.xcck.Event.GetSubtableCriteria', new XCube_Ref($cri), $this->mAsset->mDirname);
     //deprecated
     //definition criteria
     foreach ($subtableDirnameArr as $dirname) {
         $configArr = $chandler->getConfigsByDirname($dirname);
         if ($configArr['maintable'] == $this->mAsset->mDirname) {
             $subtableCri = clone $cri;
             XCube_DelegateUtils::call('Module.' . $dirname . '.SetupSubtableCriteria', new XCube_Ref($subtableCri), $this->mAsset->mDirname);
             $module = $mhandler->getByDirname($dirname);
             $subtableArr[] = array('dirname' => $dirname, 'name' => $module->get('name'));
             $definitionArr[$dirname] = Legacy_Utils::getModuleHandler('definition', $dirname)->getFields(true);
             $pageArr[$dirname] = Legacy_Utils::getModuleHandler('page', $dirname)->getObjects($subtableCri);
         }
     }
     if (count($subtableArr) > 0) {
         $render->setAttribute('subtableArr', $subtableArr);
         $render->setAttribute('definitionArr', $definitionArr);
         $render->setAttribute('pageArr', $pageArr);
     }
     $render->setAttribute('xoops_breadcrumbs', $this->_getBreadcrumb($this->mObject));
 }
 /**
  * getOverrideFileInfo
  * 
  * @param   string  $file
  * @param   string  $prefix
  * @param   bool  $isSpDirName
  * 
  * @return  {string 'theme',string 'file',string 'dirname'}
  **/
 public static function getOverrideFileInfo($file, $prefix = null, $isSpDirName = false)
 {
     $ret = array('url' => null, 'path' => null, 'theme' => null, 'dirname' => null, 'file' => null);
     if (strpos($file, '..') !== false || strpos($prefix, '..' !== false)) {
         return $ret;
     }
     $root =& XCube_Root::getSingleton();
     $module =& $root->mContext->mXoopsModule;
     $dirName = $root->mContext->mRequest->getRequest('dirname');
     if ($isSpDirName && preg_match('/^\\w+$/', $dirName)) {
         $handler =& Xcck_Utils::getXoopsHandler('module');
         $module =& $handler->getByDirname($dirName);
     }
     $isModule = is_object($module);
     $theme = $root->mSiteConfig['Legacy']['Theme'];
     $ret['theme'] = $theme;
     $dirName = $isModule ? $module->get('dirname') : null;
     $trustDirName = $isModule ? $module->getInfo('trust_dirname') : null;
     $ret['file'] = $file;
     $file = $prefix . $file;
     switch (true) {
         case $isModule && file_exists($path = sprintf('%s/modules/%s/%s', XOOPS_THEME_PATH, $theme, $dirName, $file)):
             $ret['url'] = sprintf('%s/%s/modules/%s/%s', XOOPS_THEME_URL, $theme, $dirName, $file);
             $ret['path'] = $path;
             return $ret;
         case $isModule && file_exists($path = sprintf('%s/themes/%s/modules/%s/%s', XOOPS_TRUST_PATH, $theme, $trustDirName, $file)):
             $ret['path'] = $path;
             $ret['dirname'] = $trustDirName;
             return $ret;
         case file_exists($path = sprintf('%s/%s/%s', XOOPS_THEME_PATH, $theme, $file)):
             $ret['url'] = sprintf('%s/%s/%s', XOOPS_THEME_URL, $theme, $file);
             $ret['path'] = $path;
             $ret['dirname'] = null;
             return $ret;
         case file_exists($path = sprintf('%s/themes/%s/%s', XOOPS_TRUST_PATH, $theme, $file)):
             $ret['path'] = $path;
             $ret['dirname'] = null;
             return $ret;
         case $isModule && file_exists($path = sprintf('%s/%s/admin/templates/%s', XOOPS_MODULE_PATH, $dirName, $file)):
             $ret['url'] = sprintf('%s/%s/admin/templates/%s', XOOPS_MODULE_URL, $dirName, $file);
             $ret['path'] = $path;
             $ret['theme'] = null;
             return $ret;
         case $isModule && file_exists($path = sprintf('%s/modules/%s/admin/templates/%s', XOOPS_TRUST_PATH, $trustDirName, $file)):
             $ret['path'] = $path;
             $ret['theme'] = null;
             $ret['dirname'] = $trustDirName;
             return $ret;
         case file_exists($path = XCCK_ADMIN_RENDER_FALLBACK_PATH . '/' . $file):
             $ret['url'] = XCCK_ADMIN_RENDER_FALLBACK_URL . '/' . $file;
             $ret['path'] = $path;
             $ret['theme'] = null;
             $ret['dirname'] = null;
             return $ret;
         default:
             $ret['theme'] = null;
             $ret['dirname'] = null;
             $ret['file'] = null;
             return $ret;
     }
 }
示例#20
0
 public function getCategorizedTree($categories = null)
 {
     $tree = array();
     if (!isset($categories)) {
         $categories[0] = array();
     }
     $criteria = Xcck_Utils::getListCriteria($this->getDirname());
     $criteria->add(new Criteria('p_id', 0));
     foreach (array_keys($categories) as $key) {
         $tree[$key] = array();
         $cri = clone $criteria;
         $cri->add(new Criteria('category_id', $categories[$key]->getShow('cat_id')));
         $topPageIds = $this->getIdList($cri);
         foreach ($topPageIds as $topPageId) {
             $tree[$key] = array_merge($tree[$key], $this->getTree($topPageId));
         }
     }
     return $tree;
 }
示例#21
0
function smarty_function_xcck_search_form($params, &$smarty)
{
    define('_XCCK_TAG_INPUT', '<input type="text" name="%s[%d][0]" value="%s" size="%d" />' . "\n");
    define('_XCCK_TAG_HIDDEN', '<input type="hidden" name="%s[%d][1]" value="%s" />' . "\n");
    define('_XCCK_TAG_CHECKBOX', '<input type="checkbox" name="%s" value="1"%s />' . "\n");
    define('_XCCK_TAG_DATE', '<input type="text" name="%s[%d][0]" value="%s" size="%d" maxlength="%d" class="%s" />' . "\n");
    define('_XCCK_TAG_SELECT', '<select name="%s">%s</select>' . "\n");
    define('_XCCK_TAG_OPTION', '<option value="%s"%s>%s</option>' . "\n");
    $html = null;
    //parameters
    $def = $params['def'];
    if (!isset($params['condition'])) {
        $condition = Xcck_Cond::EQ;
    } elseif ($params['condition'] === '*') {
        $condition = $params['condition'];
    } else {
        $condition = Xcck_Cond::getValue($params['condition']);
    }
    $default = isset($params['default']) ? $params['default'] : null;
    $num = isset($params['num']) ? intval($params['num']) : 0;
    $option = isset($params['option']) ? $params['option'] : null;
    //main
    switch ($def->get('field_type')) {
        case Xcck_FieldType::STRING:
        case Xcck_FieldType::TEXT:
        case Xcck_FieldType::URI:
            $html .= sprintf(_XCCK_TAG_INPUT, $def->get('field_name'), $num, $default, 20);
            if ($condition == '*') {
                $html .= Xcck_Utils::makeCondSelector($def, $num, array(Xcck_Cond::EQ, Xcck_Cond::NE, Xcck_Cond::LIKE));
            } else {
                $html .= sprintf(_XCCK_TAG_HIDDEN, $def->get('field_name'), $num, $condition);
            }
            break;
        case Xcck_FieldType::INT:
        case Xcck_FieldType::FLOAT:
            $html .= sprintf(_XCCK_TAG_INPUT, $def->get('field_name'), $num, $default, 5);
            if ($condition == '*') {
                $html .= Xcck_Utils::makeCondSelector($def, $num, array(Xcck_Cond::EQ, Xcck_Cond::NE, Xcck_Cond::LT, Xcck_Cond::LE, Xcck_Cond::GT, Xcck_Cond::GE));
            } else {
                $html .= sprintf(_XCCK_TAG_HIDDEN, $def->get('field_name'), $num, $condition);
            }
            break;
        case Xcck_FieldType::DATE:
            if ($option === 'yyyy') {
                //input year
                $html .= sprintf(_XCCK_TAG_DATE, $def->get('field_name'), $num, $default, 10, 4, 'year');
            } elseif ($option === 'yyyymm') {
                //input year-month
                $html .= sprintf(_XCCK_TAG_DATE, $def->get('field_name'), $num, $default, 10, 7, 'year');
            } elseif ($option === 'yyyymmdd') {
                //input year-month-day
                $html .= sprintf(_XCCK_TAG_DATE, $def->get('field_name'), $num, $default, 10, 10, 'datepicker');
            } elseif (isset($option['yyyy']) || $option['yyyymm']) {
                //select year
                $optionHtml = null;
                $options = isset($option['yyyy']) ? $option['yyyy'] : $option['yyyymm'];
                $selected = null;
                foreach (array_keys($options) as $k) {
                    //$k is value
                    $selected = $k == $default ? ' selected="selected"' : null;
                    $optionHtml .= sprintf(_XCCK_TAG_OPTION, $k, $selected, $option[$k]);
                }
                $html = sprintf(_XCCK_TAG_SELECT, $def->get('field_name'), $optionHtml);
                $html .= sprintf(_XCCK_TAG_HIDDEN, $def->get('field_name'), $num, $condition);
            }
            if ($condition == '*') {
                $html .= Xcck_Utils::makeCondSelector($def, $num, array(Xcck_Cond::EQ, Xcck_Cond::LIKE, Xcck_Cond::LE, Xcck_Cond::GE));
            } else {
                $html .= sprintf(_XCCK_TAG_HIDDEN, $def->get('field_name'), $num, $condition);
            }
            break;
        case Xcck_FieldType::CHECKBOX:
            $checked = isset($default) ? ' checked="checked"' : null;
            $html = sprintf(_XCCK_TAG_CHECKBOX, $def->get('field_name'), $checked);
            break;
        case Xcck_FieldType::SELECTBOX:
            $optionHtml = null;
            $options = $def->getOptions();
            foreach ($options as $opt) {
                $selected = $opt == $default ? ' selected="selected"' : null;
                $optionHtml .= sprintf(_XCCK_TAG_OPTION, $opt, $selected, $opt);
            }
            $html = sprintf(_XCCK_TAG_SELECT, $def->get('field_name'), $optionHtml);
            $html .= sprintf(_XCCK_TAG_HIDDEN, $def->get('field_name'), $num, $condition);
            break;
        case Xcck_FieldType::CATEGORY:
            $tree = null;
            $category = Xcck_Utils::getAccessController($def->getDirname());
            XCube_DelegateUtils::call('Legacy_Category.' . $category->dirname() . '.GetTree', new XCube_Ref($tree));
            require_once "function.legacy_category_select.php";
            $params = array('tree' => $tree);
            $html .= smarty_function_legacy_category_select($params, null);
            $html .= sprintf(_XCCK_TAG_HIDDEN, $def->get('field_name'), $num, $condition);
            break;
    }
    print $html;
}
示例#22
0
 /**
  * saveXoopsModule
  * 
  * @param   XoopsModule  &$module
  * 
  * @return  void
  **/
 public function saveXoopsModule(&$module)
 {
     $moduleHandler =& Xcck_Utils::getXoopsHandler('module');
     if ($moduleHandler->insert($module)) {
         $this->mLog->addReport(_MI_XCCK_INSTALL_MSG_UPDATE_FINISHED);
     } else {
         $this->mLog->addError(_MI_XCCK_INSTALL_ERROR_UPDATE_FINISHED);
     }
 }