From: <ki...@us...> - 2009-04-04 04:40:59
|
Revision: 405 http://xc-tokai.svn.sourceforge.net/xc-tokai/?rev=405&view=rev Author: kilica Date: 2009-04-04 04:40:51 +0000 (Sat, 04 Apr 2009) Log Message: ----------- [0.16] add PollNewBlock.class.php Modified Paths: -------------- modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/blocks/PollOneBlock.class.php modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/language/ja_utf8/admin.php modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/language/ja_utf8/modinfo.php modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/language/japanese/modinfo.php modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/xoops_version.php Added Paths: ----------- modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/blocks/PollNewBlock.class.php Added: modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/blocks/PollNewBlock.class.php =================================================================== --- modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/blocks/PollNewBlock.class.php (rev 0) +++ modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/blocks/PollNewBlock.class.php 2009-04-04 04:40:51 UTC (rev 405) @@ -0,0 +1,218 @@ +<?php +/** + * @file + * @package sdoc + * @version $Id$ +**/ + +if(!defined('XOOPS_ROOT_PATH')) +{ + exit(); +} + +/** + * Sdoc_ContentBlock +**/ +class Bizpoll_PollNewBlock extends Legacy_BlockProcedure +{ + /** + * @var Sdoc_ItemsHandler + * + * @private + **/ + var $_mHandler = null; + + /** + * @var Sdoc_ItmesObject + * + * @private + **/ + var $_mObject = null; + + /** + * @var string[] + * + * @private + **/ + var $_mOptions = array(); + + var $mActionForm = null; + + /** + * prepare + * + * @param void + * + * @return bool + * + * @public + **/ + function prepare() + { + return parent::prepare() && $this->_parseOptions() && $this->_setupObject(); + } + + /** + * _parseOptions + * + * @param void + * + * @return bool + * + * @private + **/ + function _parseOptions() + { + $opts = explode('|',$this->_mBlock->get('options')); + $this->_mOptions = array( + 'catIds' => $opts[0] + ); + return true; + } + + /** + * getBlockOption + * + * @param string $key + * + * @return string + * + * @public + **/ + function getBlockOption($key) + { + return isset($this->_mOptions[$key]) ? $this->_mOptions[$key] : null; + } + + /** + * getOptionForm + * + * @param void + * + * @return string + * + * @public + **/ + function getOptionForm() + { + if(!$this->prepare()) + { + return null; + } + $form = "<label for='". $this->_mBlock->get('dirname') ."block_showCat'>"._AD_BIZPOLL_LANG_SHOW_CAT."</label> : + <input type='text' size='64' name='options[0]' id='". $this->_mBlock->get('dirname') ."block_enq' value='".$this->getBlockOption('catIds')."' />\n" ; + return $form; + } + + /** + * _setupObject + * + * @param void + * + * @return bool + * + * @private + **/ + function _setupObject() + { + $objects = array(); + + //get block options + if($this->getBlockOption('catIds')){ + $catIdArr = explode(',', $this->getBlockOption('catIds')); + } + + //get module asset for handlers + $asset = null; + XCube_DelegateUtils::call( + 'Module.bizpoll.Global.Event.GetAssetManager', + new XCube_Ref($asset), + $this->_mBlock->get('dirname') + ); + + $configHandler =& xoops_gethandler('config'); + $configArr =& $configHandler->getConfigsByDirname($this->_mBlock->get('dirname')); + + $this->_mHandler =& $asset->getObject('handler','enq'); + + $criteria = new CriteriaCompo('1', '1'); + $criteria->setSort('reg_unixtime', "DESC"); + + if($configArr['gr_id']){ + //use subcriteria for permitted ids + require_once BIZPOLL_TRUST_PATH . '/class/XcatHandler.class.php'; + $xcatHandler = new Bizpoll_XcatHandler($this->_mBlock->get('dirname')); + $catCriteria = new CriteriaCompo('1', '1'); + if($catIdArr){ //get requested categories and check permission + foreach(array_keys($catIdArr) as $key){ + if($xcatHandler->checkPermit($catIdArr[$key], 'poller')){ + $catCriteria->add(new Criteria('cat_id', $catIdArr[$key])); + } + } + if($catCriteria->getCountChildElements()==0){ + return true; + } + } + else{ //get all permit categories + $ids = $xcatHandler->getPermitCatIds(0, 'poller'); + foreach(array_keys($ids) as $key){ + $catCriteria->add(new Criteria('cat_id', $ids[$key]), 'OR'); + } + } + $criteria->add($catCriteria); + } + + $objects = $this->_mHandler->getObjects($criteria); + if(count($objects)==0){ + return true; + } + + foreach(array_keys($objects) as $key){ + //check the user already poll this enquete ? + $objects[$key]->loadMyPoll($this->_mBlock->get('dirname')); + if(intval($objects[$key]->mMyPoll->get('poll_id'))==0 && ($objects[$key]->get('end_unixtime')>time() || $objects[$key]->get('end_unxitime')==0)){ + $objects[$key]->loadChoice($this->_mBlock->get('dirname')); + $this->_mObject = $objects[$key]; + break; + } + } + + if(! $this->_mObject){ + return true; + } + + //setup action form + $this->mActionForm =& $asset->getObject('form', 'poll', false, 'edit'); + $this->mActionForm->prepare(); + $this->mActionForm->load($this->_mObject->mMyPoll); + + return true; + } + + /** + * execute + * + * @param void + * + * @return void + * + * @public + **/ + function execute() + { + if($this->_mObject){ + $root =& XCube_Root::getSingleton(); + + $render =& $this->getRenderTarget(); + $render->setTemplateName($this->_mBlock->get('template')); + $render->setAttribute('block', $this->_mObject); + $render->setAttribute('actionForm', $this->mActionForm); + $render->setAttribute('bizpollBlockDirname', $this->_mBlock->get('dirname')); + $renderSystem =& $root->getRenderSystem($this->getRenderSystemName()); + //var_dump($this->_mObject);die(); + $renderSystem->renderBlock($render); + } + } +} + +?> Modified: modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/blocks/PollOneBlock.class.php =================================================================== --- modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/blocks/PollOneBlock.class.php 2009-04-04 01:05:38 UTC (rev 404) +++ modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/blocks/PollOneBlock.class.php 2009-04-04 04:40:51 UTC (rev 405) @@ -115,7 +115,7 @@ **/ function _setupObject() { - $objects = array(); + $object = null; //get block options $enqId = $this->getBlockOption('enq_id'); @@ -133,14 +133,23 @@ $this->_mHandler =& $asset->getObject('handler','enq'); $object = $this->_mHandler->get($enqId); + if(! $object){ + return true; + } + //check the enquete end ? + if($object->get('end_unixtime')<time() && $object->get('end_unixtime')!=0){ + return true; + } + //check permission require_once BIZPOLL_TRUST_PATH . '/class/XcatHandler.class.php'; $xcatHandler = new Bizpoll_XcatHandler($this->_mBlock->get('dirname')); - if(! $xcatHandler->checkPermit($object->get('cat_id'), 'viewer')){ + if(! $xcatHandler->checkPermit($object->get('cat_id'), 'poller')){ return true; } + //check the user already poll this enquete ? $object->loadMyPoll($this->_mBlock->get('dirname')); if($object->mMyPoll->get('poll_id')>0){ return true; Modified: modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/language/ja_utf8/admin.php =================================================================== --- modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/language/ja_utf8/admin.php 2009-04-04 01:05:38 UTC (rev 404) +++ modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/language/ja_utf8/admin.php 2009-04-04 04:40:51 UTC (rev 405) @@ -8,5 +8,6 @@ define('_AD_BIZPOLL_LANG_DISPLAY_NUMBER', "表示件数"); define('_AD_BIZPOLL_LANG_SHOW_CAT', "表示対象カテゴリ"); define('_AD_BIZPOLL_LANG_ENQ_ID', "アンケートID"); - +define('_AD_BIZPOLL_LANG_POLLONE_TYPE_NEW', "最新アンケート"); +define('_AD_BIZPOLL_LANG_POLLONE_TYPE_ID', "アンケートID指定"); ?> Modified: modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/language/ja_utf8/modinfo.php =================================================================== --- modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/language/ja_utf8/modinfo.php 2009-04-04 01:05:38 UTC (rev 404) +++ modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/language/ja_utf8/modinfo.php 2009-04-04 04:40:51 UTC (rev 405) @@ -78,8 +78,10 @@ define('_MI_BIZPOLL_LANG_NOEDITOR', "エディタを使わない"); define('_MI_BIZPOLL_TITLE_IP_PERIOD', "同一IP投票禁止期間(時間)"); define('_MI_BIZPOLL_DESC_IP_PERIOD', "同一IPアドレスからのゲスト投票を禁止する時間を指定"); -define('_MI_BIZPOLL_BLOCK_NAME_ENQ', "最近のアンケート"); -define('_MI_BIZPOLL_BLOCK_DESC_ENQ', "最近のアンケート"); -define('_MI_BIZPOLL_BLOCK_NAME_POLLONE', "投票"); +define('_MI_BIZPOLL_BLOCK_NAME_ENQ', "アンケート一覧"); +define('_MI_BIZPOLL_BLOCK_DESC_ENQ', "アンケート一覧"); +define('_MI_BIZPOLL_BLOCK_NAME_POLLONE', "アンケート"); define('_MI_BIZPOLL_BLOCK_DESC_POLLONE', "複数の投票ブロックを同じページに表示させると投票できなくなります(^ ^;"); +define('_MI_BIZPOLL_BLOCK_NAME_POLLNEW', "最新のアンケート"); +define('_MI_BIZPOLL_BLOCK_DESC_POLLNEW', "複数の投票ブロックを同じページに表示させると投票できなくなります(^ ^;"); ?> Modified: modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/language/japanese/modinfo.php =================================================================== --- modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/language/japanese/modinfo.php 2009-04-04 01:05:38 UTC (rev 404) +++ modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/language/japanese/modinfo.php 2009-04-04 04:40:51 UTC (rev 405) @@ -78,8 +78,10 @@ define('_MI_BIZPOLL_LANG_NOEDITOR', "\xA5\xA8\xA5ǥ\xA3\xA5\xBF\xA4\xF2\xBBȤ\xEF\xA4ʤ\xA4"); define('_MI_BIZPOLL_TITLE_IP_PERIOD', "Ʊ\xB0\xECIP\xC5\xEAɼ\xB6ػߴ\xFC\xB4֡ʻ\xFE\xB4֡\xCB"); define('_MI_BIZPOLL_DESC_IP_PERIOD', "Ʊ\xB0\xECIP\xA5\xA2\xA5ɥ쥹\xA4\xAB\xA4\xE9\xA4Υ\xB2\xA5\xB9\xA5\xC8\xC5\xEAɼ\xA4\xF2\xB6ػߤ\xB9\xA4\xEB\xBB\xFE\xB4֤\xF2\xBB\xD8\xC4\xEA"); -define('_MI_BIZPOLL_BLOCK_NAME_ENQ', "\xBAǶ\xE1\xA4Υ\xA2\xA5\xBC\xA5\xC8"); -define('_MI_BIZPOLL_BLOCK_DESC_ENQ', "\xBAǶ\xE1\xA4Υ\xA2\xA5\xBC\xA5\xC8"); -define('_MI_BIZPOLL_BLOCK_NAME_POLLONE', "\xC5\xEAɼ"); +define('_MI_BIZPOLL_BLOCK_NAME_ENQ', "\xA5\xA2\xA5\xBC\xA5Ȱ\xEC\xCD\xF7"); +define('_MI_BIZPOLL_BLOCK_DESC_ENQ', "\xA5\xA2\xA5\xBC\xA5Ȱ\xEC\xCD\xF7"); +define('_MI_BIZPOLL_BLOCK_NAME_POLLONE', "\xA5\xA2\xA5\xBC\xA5\xC8"); define('_MI_BIZPOLL_BLOCK_DESC_POLLONE', "ʣ\xBF\xF4\xA4\xCE\xC5\xEAɼ\xA5֥\xED\xA5å\xAF\xA4\xF2Ʊ\xA4\xB8\xA5ڡ\xBC\xA5\xB8\xA4\xCBɽ\xBC\xA8\xA4\xB5\xA4\xBB\xA4\xEB\xA4\xC8\xC5\xEAɼ\xA4Ǥ\xAD\xA4ʤ\xAF\xA4ʤ\xEA\xA4ޤ\xB9(^ ^;"); +define('_MI_BIZPOLL_BLOCK_NAME_POLLNEW', "\xBAǿ\xB7\xA4Υ\xA2\xA5\xBC\xA5\xC8"); +define('_MI_BIZPOLL_BLOCK_DESC_POLLNEW', "ʣ\xBF\xF4\xA4\xCE\xC5\xEAɼ\xA5֥\xED\xA5å\xAF\xA4\xF2Ʊ\xA4\xB8\xA5ڡ\xBC\xA5\xB8\xA4\xCBɽ\xBC\xA8\xA4\xB5\xA4\xBB\xA4\xEB\xA4\xC8\xC5\xEAɼ\xA4Ǥ\xAD\xA4ʤ\xAF\xA4ʤ\xEA\xA4ޤ\xB9(^ ^;"); ?> Modified: modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/xoops_version.php =================================================================== --- modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/xoops_version.php 2009-04-04 01:05:38 UTC (rev 404) +++ modules_bizpoll/trunk/xoops_trust_path/modules/bizpoll/xoops_version.php 2009-04-04 04:40:51 UTC (rev 405) @@ -214,7 +214,7 @@ 'visible_any' => false ), 2 => array( - 'func_num' => 1, + 'func_num' => 2, 'file' => 'PollOneBlock.class.php', 'class' => 'PollOneBlock', 'name' => _MI_BIZPOLL_BLOCK_NAME_POLLONE, @@ -225,6 +225,18 @@ 'can_clone' => true, 'visible_any' => false ), + 3 => array( + 'func_num' => 3, + 'file' => 'PollNewBlock.class.php', + 'class' => 'PollNewBlock', + 'name' => _MI_BIZPOLL_BLOCK_NAME_POLLNEW, + 'description' => _MI_BIZPOLL_BLOCK_DESC_POLLNEW, + 'options' => '', + 'template' => '{dirname}_block_pollone.html', + 'show_all_module' => true, + 'can_clone' => true, + 'visible_any' => false + ), ##[cubson:block] ##[/cubson:block] ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |