Пример #1
0
	function execute(&$controller, &$xoopsUser)
	{
		if ($this->mObject == null) {
			return USER_FRAME_VIEW_ERROR;
		}

		$this->mActionForm->load($this->mObject);
		
		$this->mActionForm->fetch();
		$this->mActionForm->validate();
		
		if ($this->mActionForm->hasError()) {
			return $this->getDefaultView($controller, $xoopsUser);
		}
		
		//
		// Do 'recount'
		//
		$posts = 0;
		$this->mGetUserPosts->call(new XCube_Ref($posts), $this->mObject);
		
		$handler =& xoops_getmodulehandler('users');
		return $handler->insert($this->mObject) ? USER_FRAME_VIEW_SUCCESS
		                                        : USER_FRAME_VIEW_ERROR;
	}
 function setupBlock()
 {
     require_once XOOPS_LEGACY_PATH . "/admin/blocks/AdminActionSearch.class.php";
     require_once XOOPS_LEGACY_PATH . "/admin/blocks/AdminSideMenu.class.php";
     $this->mController->_mBlockChain[] = new Legacy_AdminActionSearch();
     $this->mController->_mBlockChain[] = new Legacy_AdminSideMenu();
     $this->mSetupBlock->call(new XCube_Ref($this->mController));
 }
Пример #3
0
 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, 'Profile_Action'))) {
         die;
         //< TODO
     }
     if ($this->mAction->isSecure() && !is_object($controller->mRoot->mContext->mXoopsUser)) {
         //
         // error
         //
         $controller->executeForward(XOOPS_URL . '/');
     }
     $this->mAction->prepare($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModuleConfig);
     if (!$this->mAction->hasPermission($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModuleConfig)) {
         //
         // error
         //
         $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);
     }
     $render = $controller->mRoot->mContext->mModule->getRenderTarget();
     $render->setAttribute('xoops_pagetitle', $this->mAction->getPagetitle());
     echo $viewStatus;
     die;
     switch ($viewStatus) {
         case PROFILE_FRAME_VIEW_SUCCESS:
             $this->mAction->executeViewSuccess($render);
             break;
         case PROFILE_FRAME_VIEW_ERROR:
             $this->mAction->executeViewError($controller, $controller->mRoot->mContext->mXoopsUser, $render);
             break;
         case PROFILE_FRAME_VIEW_INDEX:
             $this->mAction->executeViewIndex($controller, $controller->mRoot->mContext->mXoopsUser, $render);
             break;
         case PROFILE_FRAME_VIEW_INPUT:
             $this->mAction->executeViewInput($controller, $controller->mRoot->mContext->mXoopsUser, $render);
             break;
         case PROFILE_FRAME_VIEW_PREVIEW:
             $this->mAction->executeViewPreview($controller, $controller->mRoot->mContext->mXoopsUser, $render);
             break;
         case PROFILE_FRAME_VIEW_CANCEL:
             $this->mAction->executeViewCancel($controller, $controller->mRoot->mContext->mXoopsUser, $render);
             break;
     }
 }
Пример #4
0
 /**
  * Create cache at $this->mResult by Delegate, if cache is empty.
  */
 function _makeCache()
 {
     if (count($this->_mResults) == 0) {
         $t_themeArr = array();
         $this->mGetInstalledThemes->call(new XCube_Ref($t_themeArr));
         foreach ($t_themeArr as $theme) {
             $obj =& $this->create();
             $obj->assignVars(array('name' => $theme->mName, 'dirname' => $theme->mDirname, 'screenshot' => $theme->mScreenShot, 'description' => $theme->mDescription, 'format' => $theme->mFormat, 'render_system' => $theme->mRenderSystemName, 'version' => $theme->mVersion, 'author' => $theme->mAuthor, 'url' => $theme->mUrl, 'license' => $theme->mLicence));
             $this->_mResults[] =& $obj;
             unset($obj);
         }
     }
 }
Пример #5
0
 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;
     }
 }
Пример #6
0
 function getDefaultView(&$controll, &$xoopsUser)
 {
     $items = array();
     $this->mGetRSSItems->call(new XCube_Ref($items));
     $sortArr = array();
     foreach ($items as $item) {
         $i = intval($item['pubdate']);
         for (; isset($sortArr[$i]); $i++) {
         }
         $sortArr[$i] = $item;
     }
     krsort($sortArr);
     $this->mItems = $sortArr;
     return LEGACY_FRAME_VIEW_INDEX;
 }
Пример #7
0
 /**
  * Delete $comment and childlen of $comment.
  */
 function delete(&$comment, $force = false)
 {
     $criteria = new Criteria('com_pid', $comment->get('com_id'));
     $this->deleteAll($criteria);
     if (parent::delete($comment, $force)) {
         $this->mDeleteSuccess->call($comment);
         return true;
     } else {
         return false;
     }
 }
Пример #8
0
 function getReplaceBody(&$to_user, &$from_user)
 {
     $t_body = $this->get('body');
     //
     // TODO {X_UACTLINK}
     //
     $t_body = str_replace('{X_UID}', $to_user->get('uid'), $t_body);
     $t_body = str_replace('{X_UNAME}', $to_user->get('uname'), $t_body);
     $t_body = str_replace('{X_UEMAIL}', $to_user->get('email'), $t_body);
     $this->mGetReplaceBody->call(new XCube_Ref($t_body), $to_user, $from_user);
     return $t_body;
 }
Пример #9
0
 /**
  * Replace XoopsCodes with their equivalent HTML formatting
  *
  * @param   string  $text
  * @param   bool    $allowimage Allow images in the text?
  *                              On FALSE, uses links to images.
  * @return  string
  **/
 function &xoopsCodeDecode($text, $allowimage = 1)
 {
     $text = $this->mTextFilter->convertXCode($text, $allowimage);
     // RaiseEvent : 'MyTextSanitizer.XoopsCodePostFilter'
     //  Delegate may convert output text with quickApplyFilter rule
     //  Args :
     //      'string'       [I/O] : Text to convert;
     //      'allowimage'   [I]   : xoopsCodeDecode $allowimage parameter
     //
     $this->mXoopsCodePostFilter->call(new XCube_Ref($text), $allowimage);
     return $text;
 }
Пример #10
0
 /**
  * @todo no $renderer. It should be $render.
  */
 function executeViewSuccess(&$controller, &$xoopsUser, &$renderer)
 {
     if (!$this->mInstaller->mLog->hasError()) {
         $this->mInstallSuccess->call(new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
         XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleInstall.' . ucfirst($this->mXoopsModule->get('dirname') . '.Success'), new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
     } else {
         $this->mInstallFail->call(new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
         XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleInstall.' . ucfirst($this->mXoopsModule->get('dirname') . '.Fail'), new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
     }
     $renderer->setTemplateName("module_install_success.html");
     $renderer->setAttribute('module', $this->mXoopsModule);
     $renderer->setAttribute('log', $this->mInstaller->mLog->mMessages);
 }
Пример #11
0
 /**
  * Create cache at $this->mResult by Delegate, if cache is empty.
  */
 function _makeCache()
 {
     if (count($this->_mResults) == 0) {
         $t_themeArr = array();
         $this->mGetInstalledThemes->call(new XCube_Ref($t_themeArr));
         foreach ($t_themeArr as $theme) {
             $obj =& $this->create();
             $obj->set('name', $theme->mName);
             $obj->set('dirname', $theme->mDirname);
             $obj->set('screenshot', $theme->mScreenShot);
             $obj->set('description', $theme->mDescription);
             $obj->set('format', $theme->mFormat);
             $obj->set('render_system', $theme->mRenderSystemName);
             $obj->set('version', $theme->mVersion);
             $obj->set('author', $theme->mAuthor);
             $obj->set('url', $theme->mUrl);
             $obj->set('licence', $theme->mLicense);
             $obj->set('license', $theme->mLicence);
             $this->_mResults[] =& $obj;
             unset($obj);
         }
     }
 }
Пример #12
0
 function executeViewSuccess(&$controller, &$xoopsUser, &$renderer)
 {
     if (!$this->mInstaller->mLog->hasError()) {
         $this->mUpdateSuccess->call(new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
         XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUpdate.' . ucfirst($this->mXoopsModule->get('dirname') . '.Success'), new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
     } else {
         $this->mUpdateFail->call(new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
         XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUpdate.' . ucfirst($this->mXoopsModule->get('dirname') . '.Fail'), new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
     }
     $renderer->setTemplateName("module_update_success.html");
     $renderer->setAttribute('module', $this->mXoopsModule);
     $renderer->setAttribute('log', $this->mInstaller->mLog->mMessages);
     $renderer->setAttribute('currentVersion', round($this->mInstaller->getCurrentVersion() / 100, 2));
     $renderer->setAttribute('targetVersion', round($this->mInstaller->getTargetPhase() / 100, 2));
     $renderer->setAttribute('isPhasedMode', $this->mInstaller->hasUpgradeMethod());
     $renderer->setAttribute('isLatestUpgrade', $this->mInstaller->isLatestUpgrade());
 }
Пример #13
0
 /**
  * Post XCode Convering
  *	 By default, convert content about [code][/code] tags
  *
  * @param	string	$text
  * @param	string	$xcode
  * @param	string	$image
  *
  * @return	string
  */
 function postConvertXCode($text, $xcode = 1, $image = 1)
 {
     if ($xcode != 0) {
         if (empty($this->mPostXCodePatterns)) {
             // RaiseEvent 'Legacy_TextFilter.MakePostXCodeConvertTable'
             //	Delegate may replace conversion table
             //	Args :
             //		'patterns'	   [I/O] : &Array of pattern RegExp
             //		'replacements' [I/O] : &Array[0..1] of Array of replacing string or callable
             //							   replacements[0] for $allowimage = 0;
             //							   replacements[1] for $allowimage = 1;
             //	Caution :
             //	   - Conversion table order should be reverse order with codePreConv conversion table.
             //		 So, conversion rule for[code] is defined after call delegate function.
             //	   - Conversion rule should treat input string as raw text with single quote escape.(not sanitized).
             //
             $this->mMakePostXCodeConvertTable->call(new XCube_Ref($this->mPostXCodePatterns), new XCube_Ref($this->mPostXCodeReplacements));
             for ($idx = 0; $idx < 2; ++$idx) {
                 $this->mPostXCodeHasCallback[$idx] = false;
                 foreach ($this->mPostXCodeReplacements[$idx] as $i => $replacements) {
                     if (is_callable($replacements)) {
                         !$this->mPostXCodeHasCallback[$idx] && ($this->mPostXCodeHasCallback[$idx] = true);
                         $this->mPostXCodeCallbacks[$idx][$i] = $replacements;
                         $this->mPostXCodeReplacements[$idx][$i] = null;
                     } else {
                         $this->mPostXCodeCallbacks[$idx][$i] = null;
                     }
                 }
             }
         }
         $replacementsIdx = $image == 0 ? 0 : 1;
         if ($this->mPostXCodeHasCallback[$replacementsIdx] === true) {
             foreach ($this->mPostXCodePatterns as $i => $patterns) {
                 if (is_null($this->mPostXCodeCallbacks[$replacementsIdx][$i])) {
                     $text = preg_replace($patterns, $this->mPostXCodeReplacements[$replacementsIdx][$i], $text);
                 } else {
                     $text = preg_replace_callback($patterns, $this->mPostXCodeCallbacks[$replacementsIdx][$i], $text);
                 }
             }
         } else {
             $text = preg_replace($this->mPostXCodePatterns, $this->mPostXCodeReplacements[$replacementsIdx], $text);
         }
     }
     return $text;
 }
Пример #14
0
function b_cubeUtils_whatsnew_show($options)
{
    $mGetRSSItems = new XCube_Delegate();
    $mGetRSSItems->register('Legacy_BackendAction.GetRSSItems');
    $items = array();
    $mGetRSSItems->call(new XCube_Ref($items));
    $max_item = intval($options[0]);
    if (empty($max_item)) {
        $max_item = 5;
    }
    $sortArr = array();
    $n = 0;
    foreach ($items as $item) {
        $i = intval($item['pubdate']);
        for (; isset($sortArr[$i]); $i++) {
        }
        $sortArr[$i] = $item;
    }
    krsort($sortArr);
    $result['items'] = array_slice($sortArr, 0, $max_item);
    return $result;
}
 /**
  * Post XCode Convering
  *	 By default, convert content about [code][/code] tags
  *
  * @param	string	$text
  * @param	string	$xcode
  * @param	string	$image
  *
  * @return	string
  */
 function postConvertXCode($text, $xcode = 1, $image = 1)
 {
     if ($xcode != 0) {
         if (empty($this->mPostXCodePatterns)) {
             // RaiseEvent 'Legacy_TextFilter.MakePostXCodeConvertTable'
             //	Delegate may replace conversion table
             //	Args :
             //		'patterns'	   [I/O] : &Array of pattern RegExp
             //		'replacements' [I/O] : &Array[0..1] of Array of replacing string
             //							   replacements[0] for $allowimage = 0;
             //							   replacements[1] for $allowimage = 1;
             //	Caution :
             //	   - Conversion table order should be reverse order with codePreConv conversion table.
             //		 So, conversion rule for[code] is defined after call delegate function.
             //	   - Conversion rule should treat input string as raw text with single quote escape.(not sanitized).
             //
             $this->mMakePostXCodeConvertTable->call(new XCube_Ref($this->mPostXCodePatterns), new XCube_Ref($this->mPostXCodeReplacements));
         }
         $replacementsIdx = $image == 0 ? 0 : 1;
         $text = preg_replace($this->mPostXCodePatterns, $this->mPostXCodeReplacements[$replacementsIdx], $text);
     }
     return $text;
 }
Пример #16
0
 /**
  * Gets a file path of a cache file for module contents.
  * @param Legacy_BlockCacheInformation $cacheInfo
  * @return string
  */
 function getCacheFilePath()
 {
     $filepath = null;
     $this->mGetCacheFilePath->call(new XCube_Ref($filepath), $this);
     if (!$filepath) {
         $id = md5(XOOPS_SALT . "(" . implode("_", $this->mIdentityArr) . ")" . implode("_", $this->mGroupArr));
         $filepath = XOOPS_CACHE_PATH . "/bid" . $this->mBlock->get('bid') . '_' . $id . ".cache.html";
     }
     return $filepath;
 }
Пример #17
0
 function getTotalItems()
 {
     if ($this->_mIsSpecifedTotalItems == false) {
         $this->mGetTotalItems->call(new XCube_Ref($this->mTotal));
         $this->_mIsSpecifedTotalItems = true;
     }
     return $this->mTotal;
 }
Пример #18
0
 function execute(&$controller)
 {
     if (strlen($this->mActionName) > 0 && !preg_match("/^\\w+\$/", $this->mActionName)) {
         die;
     }
     //
     // Actions of the public side in this module are hook type. So it's
     // necessary to load catalog here.
     //
     if (!$this->mAdminFlag) {
         $controller->mRoot->mLanguageManager->loadModuleMessageCatalog('legacy');
     }
     //
     // Add mode.
     //
     $this->setActionName($this->mMode . $this->mActionName);
     //
     // Create action object by mActionName
     //
     $this->mCreateAction->call(new XCube_Ref($this));
     if (!(is_object($this->mAction) && is_a($this->mAction, 'Legacy_Action'))) {
         die;
         //< TODO
     }
     if ($this->mAction->prepare($controller, $controller->mRoot->mContext->mXoopsUser) === false) {
         die;
         //< TODO
     }
     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 LEGACY_FRAME_VIEW_SUCCESS:
             $this->mAction->executeViewSuccess($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget());
             break;
         case LEGACY_FRAME_VIEW_ERROR:
             $this->mAction->executeViewError($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget());
             break;
         case LEGACY_FRAME_VIEW_INDEX:
             $this->mAction->executeViewIndex($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget());
             break;
         case LEGACY_FRAME_VIEW_INPUT:
             $this->mAction->executeViewInput($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget());
             break;
         case LEGACY_FRAME_VIEW_PREVIEW:
             $this->mAction->executeViewPreview($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget());
             break;
         case LEGACY_FRAME_VIEW_CANCEL:
             $this->mAction->executeViewCancel($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget());
             break;
     }
 }
Пример #19
0
 function triggerEvent($category, $item_id, $event, $extra_tags = array(), $user_list = array(), $module_id = null, $omit_user_id = null)
 {
     if (!isset($module_id)) {
         global $xoopsModule;
         $module =& $xoopsModule;
         $module_id = !empty($xoopsModule) ? $xoopsModule->getVar('mid') : 0;
     } else {
         $module_handler = xoops_gethandler('module');
         $module =& $module_handler->get($module_id);
     }
     // Get Config Array form xoops_version.php
     $not_config = $module->getInfo('notification');
     //
     $event_correct = false;
     foreach ($not_config['event'] as $event_config) {
         if ($event_config['name'] == $event && $event_config['category'] == $category) {
             $event_correct = true;
             break;
         }
     }
     // RaiseEvent 'XoopsNotificationHandler.Trigger' ('Legacy.Notify.Trigger')
     //  Delegate may hanldle notified event
     //  varArgs :
     //      'category'     [I] : Paramater $category of triggerEvent()
     //      'event'        [I] : Paramater $event of triggerEvent()
     //      'itemId'       [I] : Paramater $item_id of triggerEvent()
     //      'extraTags'    [I] : Paramater $extra_tags of triggerEvent()
     //      'userList'     [I] : Paramater $user_list of triggerEvent()
     //      'omitUid'      [I] : Paramater $omit_user_id of triggerEvent()
     //      'module'       [I] : Paramater $module_id of triggerEvent() , or currenr $xoopsModule
     //      'eventConfig'  [I] : $modversion['notification'] Array , defined in xoops_version.php
     //      'force_return' [O] : If force return this triggerEvents method, set it True
     //
     if ($event_correct) {
         /*
         			$varArgs  = array('category' => $category,
         							'event' => $event,
         							'itemId' => $item_id,
         							'extraTags' => $extra_tags,
         							'module' => &$module,
         							'userList' => $user_list,
         							'omitUid' => $omit_user_id,
         							'eventConfig' => $not_config,
         							'force_return' => false,
         						);*/
         $force_return = false;
         $this->mTriggerPreAction->call(new XCube_Ref($category), new XCube_Ref($event), new XCube_Ref($item_id), new XCube_Ref($extra_tags), new XCube_Ref($module), new XCube_Ref($user_list), new XCube_Ref($omit_user_id), new XCube_Ref($not_config), new XCube_Ref($force_return));
         $this->mTrigger->call($category, $event, $item_id, $extra_tags, new XCube_Ref($module), $user_list, $omit_user_id, $not_config, new XCube_Ref($force_return));
         if ($force_return) {
             return;
         }
     }
     // Check if event is enabled
     $config_handler = xoops_gethandler('config');
     $mod_config =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
     if (empty($mod_config['notification_enabled'])) {
         return false;
     }
     $category_info =& notificationCategoryInfo($category, $module_id);
     $event_info =& notificationEventInfo($category, $event, $module_id);
     if (!in_array(notificationGenerateConfig($category_info, $event_info, 'option_name'), $mod_config['notification_events']) && empty($event_info['invisible'])) {
         return false;
     }
     if (!isset($omit_user_id)) {
         global $xoopsUser;
         if (!empty($xoopsUser)) {
             $omit_user_id = $xoopsUser->getVar('uid');
         } else {
             $omit_user_id = 0;
         }
     }
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('not_modid', (int) $module_id));
     $criteria->add(new Criteria('not_category', $this->_escapeValue($category)));
     $criteria->add(new Criteria('not_itemid', (int) $item_id));
     $criteria->add(new Criteria('not_event', $this->_escapeValue($event)));
     $mode_criteria = new CriteriaCompo();
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDALWAYS), 'OR');
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE), 'OR');
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT), 'OR');
     $criteria->add($mode_criteria);
     if (!empty($user_list)) {
         $user_criteria = new CriteriaCompo();
         foreach ($user_list as $user) {
             $user_criteria->add(new Criteria('not_uid', $user), 'OR');
         }
         $criteria->add($user_criteria);
     }
     $notifications =& $this->getObjects($criteria);
     if (empty($notifications)) {
         return;
     }
     // Add some tag substitutions here
     $tags = array();
     if (!empty($not_config)) {
         if (!empty($not_config['tags_file'])) {
             $tags_file = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname') . '/' . $not_config['tags_file'];
             if (file_exists($tags_file)) {
                 include_once $tags_file;
                 if (!empty($not_config['tags_func'])) {
                     $tags_func = $not_config['tags_func'];
                     if (function_exists($tags_func)) {
                         $tags = $tags_func($category, (int) $item_id, $event);
                     }
                 }
             }
         }
         // RMV-NEW
         if (!empty($not_config['lookup_file'])) {
             $lookup_file = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname') . '/' . $not_config['lookup_file'];
             if (file_exists($lookup_file)) {
                 include_once $lookup_file;
                 if (!empty($not_config['lookup_func'])) {
                     $lookup_func = $not_config['lookup_func'];
                     if (function_exists($lookup_func)) {
                         $item_info = $lookup_func($category, (int) $item_id);
                     }
                 }
             }
         }
     }
     $tags['X_ITEM_NAME'] = !empty($item_info['name']) ? $item_info['name'] : '[' . _NOT_ITEMNAMENOTAVAILABLE . ']';
     $tags['X_ITEM_URL'] = !empty($item_info['url']) ? $item_info['url'] : '[' . _NOT_ITEMURLNOTAVAILABLE . ']';
     $tags['X_ITEM_TYPE'] = !empty($category_info['item_name']) ? $category_info['title'] : '[' . _NOT_ITEMTYPENOTAVAILABLE . ']';
     $tags['X_MODULE'] = $module->getVar('name', 'n');
     $tags['X_MODULE_URL'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/';
     $tags['X_NOTIFY_CATEGORY'] = $category;
     $tags['X_NOTIFY_EVENT'] = $event;
     $template_dir = $event_info['mail_template_dir'];
     $template = $event_info['mail_template'] . '.tpl';
     $subject = $event_info['mail_subject'];
     foreach ($notifications as $notification) {
         if (empty($omit_user_id) || $notification->getVar('not_uid') != $omit_user_id) {
             // user-specific tags
             //$tags['X_UNSUBSCRIBE_URL'] = 'TODO';
             // TODO: don't show unsubscribe link if it is 'one-time' ??
             $tags['X_UNSUBSCRIBE_URL'] = XOOPS_URL . '/notifications.php';
             $tags = array_merge($tags, $extra_tags);
             $notification->notifyUser($template_dir, $template, $subject, $tags);
         }
     }
 }
Пример #20
0
    public static function getJS(&$params)
    {
        static $finder, $isAdmin, $isUser, $inSpecialGroup, $confCss, $confHeadCss, $xoopsUrl, $moduleUrl, $uploadTo, $imgSize;
        self::$cnt++;
        $params['name'] = trim($params['name']);
        $params['class'] = isset($params['class']) ? trim($params['class']) : '';
        $params['cols'] = isset($params['cols']) ? intval($params['cols']) : self::DHTMLTAREA_DEFAULT_COLS;
        $params['rows'] = isset($params['rows']) ? intval($params['rows']) : self::DHTMLTAREA_DEFAULT_ROWS;
        $params['value'] = isset($params['value']) ? $params['value'] : '';
        $params['id'] = isset($params['id']) ? trim($params['id']) : self::DHTMLTAREA_DEFID_PREFIX . $params['name'];
        $params['editor'] = isset($params['editor']) ? trim($params['editor']) : 'bbcode';
        $params['toolbar'] = isset($params['toolbar']) ? trim($params['toolbar']) : null;
        $params['style'] = isset($params['style']) ? trim($params['style']) : '';
        $params['allowhtml'] = !empty($params['allowhtml']);
        $params['switcher'] = isset($params['switcher']) ? trim($params['switcher']) : null;
        $params['onload'] = isset($params['onload']) ? trim($params['onload']) : null;
        $params['onready'] = isset($params['onready']) ? trim($params['onready']) : null;
        if (!empty($params['editor']) && $params['editor'] !== 'none' && (!$params['class'] || !preg_match('/\\b' . preg_quote($params['editor']) . '\\b/', $params['class']))) {
            if (!$params['class']) {
                $params['class'] = $params['editor'];
            } else {
                $params['class'] .= ' ' . $params['editor'];
            }
        }
        // rlazy registering & call pre build delegate
        if (defined('XOOPS_CUBE_LEGACY')) {
            $delegate = new XCube_Delegate();
            $delegate->register('Ckeditor4.Utils.PreBuild_ckconfig');
            $delegate->call(new XCube_Ref($params));
        } else {
            self::doFilter('config', 'PreBuild', $params);
        }
        $script = '';
        if ($params['editor'] !== 'plain' && $params['editor'] !== 'none') {
            $editor = $params['editor'] === 'html' ? 'html' : 'bbcode';
            $conf = self::getModuleConfig();
            $imageUploadJS = '';
            if (is_null($finder)) {
                // Get X-elFinder module
                $mHandler =& self::getXoopsHandler('module');
                $mObj = $mHandler->getByDirname($conf['xelfinder']);
                $finder = is_object($mObj) ? $conf['xelfinder'] : '';
                if ($finder) {
                    require_once XOOPS_TRUST_PATH . '/modules/xelfinder/class/xelFinderMisc.class.php';
                    $xelMisc = new xelFinderMisc($finder);
                    if (!empty($conf['uploadHash'])) {
                        $uploadTo = trim($conf['uploadHash']);
                    } else {
                        if (!($uploadTo = $xelMisc->getUserHome())) {
                            $uploadTo = $xelMisc->getGroupHome();
                        }
                        if ($uploadTo) {
                            $uploadTo = $xelMisc->getHash($uploadTo);
                        }
                    }
                    $imgSize = intval($conf['imgShowSize']) ? 200 : intval($conf['imgShowSize']);
                } else {
                    $uploadTo = false;
                }
                if (defined('XOOPS_CUBE_LEGACY')) {
                    $root =& XCube_Root::getSingleton();
                    $xoopsUser = $root->mContext->mXoopsUser;
                    $inAdminPanel = $root->mContext->mBaseRenderSystemName === 'Legacy_AdminRenderSystem';
                } else {
                    global $xoopsUser;
                    $inAdminPanel = defined('_AD_NORIGHT');
                    // html/language/[LANG]/admin.php
                }
                // Check in a group
                $isAdmin = false;
                $isUser = false;
                $mGroups = array(XOOPS_GROUP_ANONYMOUS);
                if (is_object($xoopsUser)) {
                    if ($xoopsUser->isAdmin(self::getMid())) {
                        $isAdmin = true;
                    }
                    $isUser = true;
                    $mGroups = $xoopsUser->getGroups();
                }
                $inSpecialGroup = array_intersect($mGroups, !empty($conf['special_groups']) ? $conf['special_groups'] : array());
                // xoopsUrl
                $xoopsUrl = XOOPS_URL;
                // moduleUrl
                $moduleUrl = defined('XOOPS_MODULE_URL') ? XOOPS_MODULE_URL : XOOPS_URL . '/modules';
                // make CSS data
                $confCss = array();
                $confHeadCss = 'false';
                $conf['contentsCss'] = trim($conf['contentsCss']);
                if ($conf['contentsCss']) {
                    foreach (preg_split('/[\\r\\n]+/', $conf['contentsCss']) as $_css) {
                        $_css = trim($_css);
                        if (!$inAdminPanel && $_css === '<head>') {
                            $confHeadCss = 'true';
                        } else {
                            if ($_css) {
                                $confCss[] = $_css;
                            }
                        }
                    }
                }
                // themes contents.css
                $_themeCss = '/themes/' . $GLOBALS['xoopsConfig']['theme_set'] . '/ckeditor4/contents.css';
                if (is_file(XOOPS_ROOT_PATH . $_themeCss)) {
                    $confCss[] = XOOPS_URL . $_themeCss;
                }
                // editor_reset.css
                $confCss[] = $moduleUrl . '/ckeditor4/templates/editor_reset.css';
            }
            // Make config
            $config = array();
            $modeconf = array('html' => array(), 'bbcode' => array());
            $config['contentsCss'] = array();
            $config['removePlugins'] = 'save,newpage,forms,preview,print';
            $config['extraPlugins'] = '';
            if (defined('XOOPS_CUBE_LEGACY')) {
                $delegate->register('Ckeditor4.Utils.PreParseBuild_ckconfig');
                $delegate->call(new XCube_Ref($config), $params);
                if ($config['contentsCss'] && !is_array($config['contentsCss'])) {
                    $config['contentsCss'] = array($config['contentsCss']);
                }
            } else {
                self::doFilter('config', 'PreParseBuild', $config, $params);
            }
            // Parse params
            if (!is_null($params['toolbar'])) {
                $config['toolbar'] = $params['toolbar'];
            }
            $config['xoopscodeXoopsUrl'] = XOOPS_URL . '/';
            if ($finder) {
                $config['filebrowserBrowseUrl'] = $moduleUrl . '/' . $finder . '/manager.php?cb=ckeditor';
                if ($uploadTo) {
                    $config['filebrowserBrowseUrl'] .= '&start=' . $uploadTo;
                    $config['uploadUrl'] = $config['filebrowserUploadUrl'] = $moduleUrl . '/' . $finder . '/connector.php';
                    if (!isset($_SESSION['XELFINDER_CTOKEN'])) {
                        $_SESSION['XELFINDER_CTOKEN'] = md5(session_id() . XOOPS_ROOT_PATH . (defined(XOOPS_SALT) ? XOOPS_SALT : XOOPS_DB_PASS));
                    }
                    $imageUploadJS = <<<EOD

\tckon("instanceReady",function(e){
\t\tvar editor = e.editor;
\t\teditor.widgets.registered.uploadimage.onUploaded = function(img){
\t\t\tvar self = this;
\t\t\tgetShowImgSize(img.url, function(s,r) {
\t\t\t\tvar elm,
\t\t\t\t\ttag = '<img src="'+encodeURI(img.url)+'" width="'+s.width+'" height="'+s.height+'"></img>';
\t\t\t\tif (r) {
\t\t\t\t\ttag = '<a href="'+encodeURI(img.url)+'" target="_blank">'+tag+'</a>';
\t\t\t\t}
\t\t\t\tself.replaceWith(tag);
\t\t\t\teditor.getSelection().removeAllRanges();
\t\t\t});
\t\t}
\t});
\tckon("fileUploadRequest",function(e){
\t\tvar fileLoader = e.data.fileLoader,
\t\t\tformData = new FormData(),
\t\t\txhr = fileLoader.xhr;
\t\txhr.open('POST', fileLoader.uploadUrl, true);
\t\tformData.append('cmd', 'upload');
\t\tformData.append('overwrite', 0);
\t\tformData.append('target', '{$uploadTo}');
\t\tformData.append('ctoken', '{$_SESSION['XELFINDER_CTOKEN']}');
\t\tformData.append('upload[]', fileLoader.file, fileLoader.fileName);
\t\tfileLoader.xhr.send(formData);
\t});
\tckon("fileUploadResponse",function(e){
\t\te.stop();
\t\tvar data = e.data,
\t\t\tres = JSON.parse(data.fileLoader.xhr.responseText);
\t\tif (!res.added || res.added.length < 1) {
\t\t\tdata.message = 'Can not upload.';
\t\t\te.cancel();
\t\t} else {
\t\t\tvar file   = res.added[0],
\t\t\t\tparser = document.createElement('a');
\t\t\tparser.href = '{$xoopsUrl}';
\t\t\tdata.url = file.url? file.url : 
\t\t\t\t(data.url = file._localpath? file._localpath.replace(/^R/, '{$xoopsUrl}') : '');
\t\t\tdata.url = data.url.replace(parser.protocol+'//'+parser.host, '');
\t\t}
\t});
EOD;
                }
            }
            $config['removePlugins'] = $config['removePlugins'] ? ',' . trim($config['removePlugins'], ',') : '';
            // build bbcode conf
            $modeconf['bbcode']['fontSize_sizes'] = 'xx-small;x-small;small;medium;large;x-large;xx-large';
            $modeconf['bbcode']['extraPlugins'] = (trim($conf['extraPlugins']) ? 'xoopscode,' . trim($conf['extraPlugins']) : 'xoopscode') . ($config['extraPlugins'] ? ',' . trim($config['extraPlugins'], ',') : '');
            $modeconf['bbcode']['enterMode'] = 2;
            $modeconf['bbcode']['shiftEnterMode'] = 2;
            if ($editor !== 'bbcode' || !isset($config['toolbar'])) {
                $modeconf['bbcode']['toolbar'] = trim($conf['toolbar_bbcode']);
            } else {
                $modeconf['bbcode']['toolbar'] = $config['toolbar'];
            }
            // build html conf
            $modeconf['html']['fontSize_sizes'] = '8/8px;9/9px;10/10px;11/11px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;26/26px;28/28px;36/36px;48/48px;72/72px';
            $modeconf['html']['extraPlugins'] = trim($conf['extraPlugins']) . ($config['extraPlugins'] ? ',' . trim($config['extraPlugins'], ',') : '');
            $modeconf['html']['enterMode'] = (int) $conf['enterMode'];
            $modeconf['html']['shiftEnterMode'] = (int) $conf['shiftEnterMode'];
            if ($editor !== 'html' || !isset($config['toolbar'])) {
                if ($isAdmin) {
                    $modeconf['html']['toolbar'] = trim($conf['toolbar_admin']);
                } else {
                    if ($inSpecialGroup) {
                        $modeconf['html']['toolbar'] = trim($conf['toolbar_special_group']);
                    } else {
                        if ($isUser) {
                            $modeconf['html']['toolbar'] = trim($conf['toolbar_user']);
                        } else {
                            $modeconf['html']['toolbar'] = trim($conf['toolbar_guest']);
                        }
                    }
                }
                if (strtolower($modeconf['html']['toolbar']) === 'full') {
                    $modeconf['html']['toolbar'] = null;
                }
            } else {
                $modeconf['html']['toolbar'] = $config['toolbar'];
            }
            $config['customConfig'] = trim($conf['customConfig']);
            if ($conf['allowedContent']) {
                $config['allowedContent'] = true;
            }
            $config['autoParagraph'] = (bool) $conf['autoParagraph'];
            $config['contentsCss'] = array_merge($config['contentsCss'], $confCss);
            self::setCKConfigSmiley($config);
            $modeSource = 0;
            $params['value'] = str_replace('&lt;!--ckeditor4FlgSource--&gt;', '', $params['value'], $modeSource);
            if ($modeSource) {
                $config['startupMode'] = 'source';
            }
            // set $modeconf as $config['_modeconf'] for delegate
            $config['_modeconf'] = $modeconf;
            // lazy registering & call post build delegate
            if (defined('XOOPS_CUBE_LEGACY')) {
                $delegate->register('Ckeditor4.Utils.PostBuild_ckconfig');
                $delegate->call(new XCube_Ref($config), $params);
            } else {
                self::doFilter('config', 'PostBuild', $config, $params);
            }
            // restore $modeconf from $config['_modeconf']
            $modeconf = $config['_modeconf'];
            unset($config['_modeconf']);
            // merge editor config
            $config = array_merge($config, $modeconf[$editor]);
            // Make config json
            $config_json = array();
            foreach ($config as $key => $val) {
                if (!is_string($val) || !$val || $val[0] !== '[') {
                    $val = json_encode($val);
                }
                $config_json[] = '"' . $key . '":' . $val;
            }
            $config_json = '{' . join($config_json, ',') . '}';
            foreach (array('html', 'bbcode') as $mode) {
                $name = 'config_json_' . $mode;
                ${$name} = array();
                foreach ($modeconf[$mode] as $key => $val) {
                    if (!is_string($val) || !$val || $val[0] !== '[') {
                        $val = json_encode($val);
                    }
                    array_push(${$name}, '"' . $key . '":' . $val);
                }
                ${$name} = '{' . join(${$name}, ',') . '}';
            }
            // allow html
            $allowhtml = $params['allowhtml'] || $editor === 'html' ? 'true' : 'false';
            // Make Script
            $id = $params['id'];
            // build switcher
            if (is_null($params['switcher'])) {
                // default switcher
                $switcher = <<<EOD

\t// local func
\tvar ck,ta = \$("#{$id}"),
\tset = function(name, check, disable) {
\t\tvar elm = eval(name+"_c");
\t\tif (elm) {
\t\t\t(check !== null) && elm.prop("checked", check);
\t\t\t(disable !== null) && elm.prop("disabled", disable);
\t\t}
\t},
\tfind_c = function(name){
\t\tvar f = ta.closest("form");
\t\tvar elm = f.find('input[type="checkbox"][name="do'+name+'"]');
\t\t(elm.length === 1) || (elm = f.find('input[type="checkbox"][name\$="'+name+'"]'));
\t\t(elm.length === 1) || (elm = f.find('input[type="checkbox"][name*="'+name+'"]'));
\t\treturn (elm.length === 1) ? elm : null;
\t},
\t// checkbox
\thtml_c = find_c('html'),
\tbbcode_c = find_c('xcode'),
\tbr_c = find_c('br');
\t// dohtml checkbox
\tif (html_c) {
\t\thtml_c.change(function(){
\t\t\tif (!\$(this).is(":focus")) return;
\t\t\tvar obj = CKEDITOR.instances.{$id};
\t\t\tobj && obj.destroy();
\t\t\tbr_c && br_c.prop("disabled", false);
\t\t\tif (\$(this).is(":checked")) {
\t\t\t\tset("bbcode", false);
\t\t\t\tset("br", false , true);
\t\t\t\tta.data("editor", "html");
\t\t\t\tck = CKEDITOR.replace("{$id}", \$.extend({}, ta.data("ckconfig"), ta.data("ckconfig_html")));
\t\t\t} else if (!bbcode_c || bbcode_c.is(":checked")) {
\t\t\t\tset("br", true, true);
\t\t\t\tta.data("editor", "bbcode");
\t\t\t\tck = CKEDITOR.replace("{$id}", \$.extend({}, ta.data("ckconfig"), ta.data("ckconfig_bbcode")));
\t\t\t} else {
\t\t\t\treturn;
\t\t\t}
\t\t\tta.data("ckon_restore")();
\t\t});
\t}
\t// doxcode checkbox
\tif (bbcode_c) {
\t\tbbcode_c.change(function(){
\t\t\tif (!\$(this).is(":focus")) return;
\t\t\tvar obj = CKEDITOR.instances.{$id},
\t\t\tconf = ta.data("ckconfig"),
\t\t\tchange = false;
\t\t\tif (\$(this).is(":checked")) {
\t\t\t\tif (!html_c || (html_c && !html_c.is(":checked"))) {
\t\t\t\t\tchange = 'bbcode';
\t\t\t\t\tconf = \$.extend(conf, ta.data("ckconfig_bbcode"));
\t\t\t\t}
\t\t\t} else if ((!html_c && ta.data("allowhtml")) || (html_c && html_c.is(":checked"))) {
\t\t\t\tif (ta.data("editor") != "html") {
\t\t\t\t\tchange = 'html';
\t\t\t\t\tconf = \$.extend(conf, ta.data("ckconfig_html"));
\t\t\t\t}
\t\t\t} else {
\t\t\t\tchange = 'none';
\t\t\t}
\t\t\tif (change) {
\t\t\t\tobj && obj.destroy();
\t\t\t\tta.data("editor", change);
\t\t\t\tif (change != "none") {
\t\t\t\t\tset("br", (change == 'bbcode'), true);
\t\t\t\t\tck = CKEDITOR.replace("{$id}", conf);
\t\t\t\t\tta.data("ckon_restore")();
\t\t\t\t} else {
\t\t\t\t\tset("br", null, false);
\t\t\t\t}
\t\t\t}
\t\t});
\t}
\t// form submit
\tta.closest("form").bind("submit", function(){
\t\tvar e = ta.data("editor");
\t\tset("br", ((e == "bbcode")? true : ((e == "html")? false : null)), false);
\t});
\t// custom block editor (legacy or alysys)
\tvar html_s = ta.closest("form").find("select[name='c_type'],[name='ctypes[0]']");
\tif (html_s && html_s.length == 1) {
\t\thtml_s.change(function(){
\t\t\tvar obj = CKEDITOR.instances.{$id}, conf;
\t\t\tconf = ta.data("ckconfig");
\t\t\tobj && obj.destroy();
\t\t\tconf = (\$(this).val() == "H")? \$.extend(conf, ta.data("ckconfig_html")) : \$.extend(conf, ta.data("ckconfig_bbcode"));
\t\t\tif (\$(this).val() != "P") {
\t\t\t\tconf =\t(\$(this).val() == "T")? \$.extend(conf, {removePlugins:'smiley,'+conf.removePlugins}) : \$.extend(conf, {removePlugins: conf.removePlugins.replace('smiley,', '')});
\t\t\t\tck = CKEDITOR.replace("{$id}", conf);
\t\t\t\tta.data("ckon_restore")();
\t\t\t}
\t\t});
\t}
EOD;
            } else {
                // custom switcher (by params)
                $switcher = 'try{ ' . $params['switcher'] . ' } catch(e) { console && console.log(e); }';
            }
            $onload = $params['onload'] ? 'try{ ' . $params['onload'] . ' } catch(e) { console && console.log(e); }' : '';
            $onready = $params['onready'] ? 'try{ ' . $params['onready'] . ' } catch(e) { console && console.log(e); }' : '';
            if (self::$cnt === 1) {
                $script_1st = <<<EOD

\tif (typeof xoopsInsertText != 'undefined') {
\t\tvar xit = xoopsInsertText;
\t\txoopsInsertText = function(obj, str){
\t\t\tif (obj.id && CKEDITOR.instances[obj.id]) {
\t\t\t\tCKEDITOR.instances[obj.id].insertText(str);
\t\t\t} else {
\t\t\t\txit(obj, str);
\t\t\t}
\t\t}
\t}
\tif (typeof xoopsCodeSmilie != 'undefined') {
\t\tvar xcs = xoopsCodeSmilie;
\t\txoopsCodeSmilie = function(id, str){
\t\t\tif (CKEDITOR.instances[id]) {
\t\t\t\tCKEDITOR.instances[id].insertText(str);
\t\t\t} else {
\t\t\t\txcs(id, str);
\t\t\t}
\t\t}
\t}
EOD;
                if ($finder) {
                    $script_1st .= <<<EOD

\tgetShowImgSize = function(url, callback) {
\t\tvar ret = {};
\t\t\$('<img/>').attr('src', url).on('load', function() {
\t\t\tvar w = this.naturalWidth,
\t\t\t\th = this.naturalHeight,
\t\t\t\ts = {$imgSize},
\t\t\t\tresized = false;
\t\t\tif (w > s || h > s) {
\t\t\t\tresized = true;
\t\t\t\tif (w > h) {
\t\t\t\t\th = Math.round(h * (s / w));
\t\t\t\t\tw = s;
\t\t\t\t} else {
\t\t\t\t\tw = Math.round(w * (s / h));
\t\t\t\t\th = s;
\t\t\t\t}
\t\t\t}
\t\t\tcallback({width: w, height: h}, resized);
\t\t});
\t};
\tCKEDITOR.on('dialogDefinition', function (event) {
\t\tvar editor = event.editor,
\t\t\tdialogDefinition = event.data.definition,
\t\t\ttabCount = dialogDefinition.contents.length,
\t\t\tuploadButton, submitButton, inputId,
\t\t\t// elFinder configs
\t\t\telfDirHashMap = { // Dialog name / elFinder holder hash Map
\t\t\t\timage : '',
\t\t\t\tflash : '',
\t\t\t\tfiles : '',
\t\t\t\tlink  : '',
\t\t\t\tfb    : '{$uploadTo}' // fallback target
\t\t\t},
\t\t\tcustomData = { ctoken: '{$_SESSION['XELFINDER_CTOKEN']}' }; // any custom data to post
\t\tfor (var i = 0; i < tabCount; i++) {
\t\t\tuploadButton = dialogDefinition.contents[i].get('upload');
\t\t\tsubmitButton = dialogDefinition.contents[i].get('uploadButton');
\t\t\tif (uploadButton !== null && submitButton !== null) {
\t\t\t\tuploadButton.hidden = false;
\t\t\t\tsubmitButton.hidden = false;
\t\t\t\tuploadButton.onChange = function() {
\t\t\t\t\tinputId = this.domId;
\t\t\t\t}
\t\t\t\tsubmitButton.onClick = function(e) {
\t\t\t\t\tdialogName = CKEDITOR.dialog.getCurrent()._.name;
\t\t\t\t\tvar target = elfDirHashMap[dialogName]? elfDirHashMap[dialogName] : elfDirHashMap['fb'],
\t\t\t\t\t\tname   = \$('#'+inputId),
\t\t\t\t\t\tbtn    = \$('#'+this.domId),
\t\t\t\t\t\tinput  = name.find('iframe').contents().find('form').find('input:file'),
\t\t\t\t\t\tspinner= \$('<img src="{$xoopsUrl}/common/elfinder/img/spinner-mini.gif" width="16" height="16" style="vertical-align:middle"/>'),
\t\t\t\t\t\terror  = function(err) {
\t\t\t\t\t\t\talert(err.replace('<br>', '\\n'));
\t\t\t\t\t\t};
\t\t\t\t\tif (input.val() && ! btn.hasClass('cke_button_disabled')) {
\t\t\t\t\t\tvar fd = new FormData();
\t\t\t\t\t\tfd.append('cmd', 'upload');
\t\t\t\t\t\tfd.append('overwrite', 0); // disable upload overwrite to make to increment file name
\t\t\t\t\t\tfd.append('target', target);
\t\t\t\t\t\t\$.each(customData, function(key, val) {
\t\t\t\t\t\t\tfd.append(key, val);
\t\t\t\t\t\t});
\t\t\t\t\t\tfd.append('upload[]', input[0].files[0]);
\t\t\t\t\t\tbtn.addClass('cke_button_disabled').append(spinner);
\t\t\t\t\t\t\$.ajax({
\t\t\t\t\t\t\turl: editor.config.filebrowserUploadUrl,
\t\t\t\t\t\t\ttype: 'POST',
\t\t\t\t\t\t\tdata: fd,
\t\t\t\t\t\t\tprocessData: false,
\t\t\t\t\t\t\tcontentType: false,
\t\t\t\t\t\t\tdataType: 'json'
\t\t\t\t\t\t})
\t\t\t\t\t\t.done(function( data ) {
\t\t\t\t\t\t\tif (data.added && data.added[0]) {
\t\t\t\t\t\t\t\tvar url = data.added[0].url;
\t\t\t\t\t\t\t\tvar dialog = CKEDITOR.dialog.getCurrent();
\t\t\t\t\t\t\t\tif (dialogName == 'image') {
\t\t\t\t\t\t\t\t\tvar urlObj = 'txtUrl'
\t\t\t\t\t\t\t\t} else if (dialogName == 'flash') {
\t\t\t\t\t\t\t\t\tvar urlObj = 'src'
\t\t\t\t\t\t\t\t} else if (dialogName == 'files' || dialogName == 'link') {
\t\t\t\t\t\t\t\t\tvar urlObj = 'url'
\t\t\t\t\t\t\t\t} else {
\t\t\t\t\t\t\t\t\treturn;
\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\tdialog.selectPage('info');
\t\t\t\t\t\t\t\tdialog.setValueOf('info', urlObj, url);
\t\t\t\t\t\t\t\tif (dialogName == 'image') {
\t\t\t\t\t\t\t\t\tgetShowImgSize(url, function(s,r) {
\t\t\t\t\t\t\t\t\t\tif (r) {
\t\t\t\t\t\t\t\t\t\t\ttry {
\t\t\t\t\t\t\t\t\t\t\t\tdialog.setValueOf('info', 'txtWidth', s.width);
\t\t\t\t\t\t\t\t\t\t\t\tdialog.setValueOf('info', 'txtHeight', s.height);
\t\t\t\t\t\t\t\t\t\t\t\tdialog.preview.\$.style.width = s.width+'px';
\t\t\t\t\t\t\t\t\t\t\t\tdialog.preview.\$.style.height = s.height+'px';
\t\t\t\t\t\t\t\t\t\t\t\tdialog.setValueOf('Link', 'txtUrl', url);
\t\t\t\t\t\t\t\t\t\t\t\tdialog.setValueOf('Link', 'cmbTarget', '_blank');
\t\t\t\t\t\t\t\t\t\t\t} catch(e) {}
\t\t\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\t\t});
\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t} else {
\t\t\t\t\t\t\t\terror(data.error || data.warning || 'errUploadFile');
\t\t\t\t\t\t\t}
\t\t\t\t\t\t})
\t\t\t\t\t\t.fail(function() {
\t\t\t\t\t\t\terror('errUploadFile');
\t\t\t\t\t\t})
\t\t\t\t\t\t.always(function() {
\t\t\t\t\t\t\tinput.val('');
\t\t\t\t\t\t\tspinner.remove();
\t\t\t\t\t\t\tbtn.removeClass('cke_button_disabled');
\t\t\t\t\t\t});
\t\t\t\t\t}
\t\t\t\t\treturn false;
\t\t\t\t}
\t\t\t}
\t\t} 
\t});
EOD;
                }
            } else {
                $script_1st = '';
            }
            $script = <<<EOD

(function(){
\t{$onload}{$script_1st}
\tvar ckconfig_{$id},ckconfig_html_{$id},ckconfig_bbcode_{$id};// for compat
\tvar ck,
\tconf = {$config_json},
\tid = "{$id}",
\tta = \$("#{$id}")
\t.data("editor", "{$editor}")
\t.data("allowhtml", {$allowhtml})
\t.data("ckconfig_html", {$config_json_html})
\t.data("ckconfig_bbcode", {$config_json_bbcode})
\t.data("ckon", function(name,func){
\t\tvar ckev = (ta.data("ckev") || {});
\t\tckev[name] = (ckev[name] || []);
\t\tckev[name].push(func);
\t\tta.data("ckev", ckev);
\t\tCKEDITOR.instances[id].on(name, func);
\t})
\t.data("ckon_restore", function(){
\t\tvar ck = CKEDITOR.instances[id];
\t\t\$.each(ta.data("ckev"), function(name, fs){
\t\t\t\$.each(fs, function(i, func){ ck.on(name, func); });
\t\t});
\t});
\tif (! conf.width) conf.width = ta.parent().width() + 'px';
\tvar headCss = \$.map(\$("head link[rel='stylesheet']").filter("[media!='print'][media!='handheld']"), function(o){ return o.href; });
\tif ({$confHeadCss} && headCss) conf.contentsCss = headCss.concat(conf.contentsCss);
\tta.data("ckconfig", conf);
\tckconfig_{$id} = conf;
\tckconfig_html_{$id} = ta.data("ckconfig_html");
\tckconfig_bbcode_{$id} = ta.data("ckconfig_bbcode");
\tck = CKEDITOR.replace("{$id}", conf);
\tvar ckon = ta.data("ckon");
\tckon("focus",function(e){ta.trigger("focus");});
\tckon("blur",function(e){
\t\te.editor.updateElement();
\t\tta.trigger("blur");
\t});
\tckon("instanceReady",function(e){{$onready}});
\tckon("getData",function(e){
\t\tif (e.editor.mode == 'source') e.data.dataValue += '<!--ckeditor4FlgSource-->';
\t});
\tckon("setData",function(e){
\t\te.data.dataValue = e.data.dataValue.replace('<!--ckeditor4FlgSource-->', '');
\t});{$imageUploadJS}
\tta.closest("form").find("input").on("mousedown", function(){
\t\tck && ck.updateElement();
\t});
\t{$switcher}
})();
EOD;
        }
        return $script;
    }
Пример #21
0
 function getDefaultView(&$controller, &$xoopsUser)
 {
     $moduleHandler =& xoops_gethandler('module');
     $this->mModuleObject =& $moduleHandler->getByDirname($this->_mDirname);
     $language = $controller->mRoot->mContext->getXoopsConfig('language');
     //
     // TODO We must change the following lines to ActionForm.
     //
     $helpfile = xoops_getrequest('file') ? xoops_getrequest('file') : $this->mModuleObject->getHelp();
     //
     // Smarty
     //
     $smarty = null;
     $this->mCreateHelpSmarty->call(new XCube_Ref($smarty));
     $smarty->setDirname($this->_mDirname);
     //
     // file check
     //
     // TODO We should not access files in language directory directly.
     //
     $template_dir = XOOPS_MODULE_PATH . "/" . $this->_mDirname . "/language/{$language}/help";
     if (!file_exists($template_dir . "/" . $helpfile)) {
         $template_dir = XOOPS_MODULE_PATH . "/" . $this->_mDirname . "/language/english/help";
         if (!file_exists($template_dir . "/" . $helpfile)) {
             $this->mErrorMessage = _AD_LEGACY_ERROR_NO_HELP_FILE;
             return LEGACY_FRAME_VIEW_ERROR;
         }
     }
     $controller->mRoot->mContext->setAttribute('legacy_help_dirname', $this->_mDirname);
     $smarty->template_dir = $template_dir;
     $this->mContents = $smarty->fetch("file:" . $helpfile);
     return LEGACY_FRAME_VIEW_SUCCESS;
 }
 /**
  * Gets a file path of a cache file for module contents.
  * @param Legacy_BlockCacheInformation $cacheInfo
  * @return string
  */
 function getCacheFilePath()
 {
     $filepath = null;
     $this->mGetCacheFilePath->call(new XCube_Ref($filepath), $this);
     if (!$filepath) {
         $id = md5(XOOPS_SALT . '(' . implode('_', $this->mIdentityArr) . ')' . implode('_', $this->mGroupArr));
         $filepath = $this->getCacheFileBase($this->mBlock->get('bid'), $id);
     }
     return $filepath;
 }
 function &createServer(&$service)
 {
     $server = null;
     $this->mCreateServer->call(new XCube_Ref($server), new XCube_Ref($service));
     return $server;
 }
Пример #24
0
 /**
  * Sets up a principal object to the root object. In other words, restores
  * the principal object from session or other.
  */
 function _setupUser()
 {
     $this->mSetupUser->call(new XCube_Ref($this->mRoot->mContext->mUser), new XCube_Ref($this), new XCube_Ref($this->mRoot->mContext));
 }
 function update()
 {
     $updateSuccess = new XCube_Delegate();
     $updateSuccess->register('Legacy_ModuleUpdateAction.UpdateSuccess');
     $updateFail = new XCube_Delegate();
     $updateFail->register('Legacy_ModuleUpdateAction.UpdateFail');
     $module = get_module($this->name);
     $dirname = $module->get('dirname');
     $installer = Legacy_ModuleInstallUtils::createUpdater($dirname);
     $installer->setCurrentXoopsModule($module);
     // Load the manifesto, and set it as the target object.
     $module->loadInfoAsVar($dirname);
     $module->set('name', $module->get('name'));
     $installer->setTargetXoopsModule($module);
     $installer->executeUpgrade();
     if ($installer->mLog->hasError() === false) {
         $updateSuccess->call(new XCube_Ref($module), new XCube_Ref($installer->mLog));
         XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUpdate.' . ucfirst($dirname . '.Success'), new XCube_Ref($module), new XCube_Ref($installer->mLog));
         $success = true;
     } else {
         $updateFail->call(new XCube_Ref($module), new XCube_Ref($installer->mLog));
         XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUpdate.' . ucfirst($dirname . '.Fail'), new XCube_Ref($module), new XCube_Ref($installer->mLog));
         $success = false;
     }
     /*		foreach ($installer->mLog->mMessages as $message)
     		{
     			echo sprintf('[%s] update: %s', date('Y-m-d H:i:s'), $message['message']), PHP_EOL; // TODO >> observer
     		}
     */
     return $success;
 }
Пример #26
0
    /**
     * This member function works to redirect as well as redirect_header().
     * But, this member function handles raw values which hasn't been converted
     * by htmlspecialchars(). Therefore, if user calls this function with the
     * wrong value, some problems may be raised. If you can't understand the
     * difference, use not this function but redirect_header().
     * 
     * @param string $url		   redirect URL. Don't use user's variables or request.
     * @param int	 $time		   waiting time (sec)
     * @param string $message	   This string doesn't include tags.
     * @param bool	 $addRedirect  A value indicationg whether this method adds URL automatically for user.php.
     * 
     * @todo We'll change this function to delegate.
     * @remark This method encode $url and $message directly without its template, to share the template with old function.
     */
    function executeRedirect($url, $time = 1, $message = null, $addRedirect = true)
    {
        global $xoopsConfig, $xoopsRequestUri;
        //
        // Check the following by way of caution.
        //
        if (preg_match("/(javascript|vbscript):/si", $url)) {
            $url = XOOPS_URL;
        }
        $displayMessage = "";
        if (is_array($message)) {
            foreach (array_keys($message) as $key) {
                $message[$key] = htmlspecialchars($message[$key], ENT_QUOTES);
            }
            $displayMessage = implode("<br/>", $message);
        } else {
            $displayMessage = $message;
        }
        $url = htmlspecialchars($url, ENT_QUOTES);
        // XOOPS2 Compatibility
        if ($addRedirect && strstr($url, 'user.php')) {
            $this->_mNotifyRedirectToUser->call(new XCube_Ref($url));
        }
        if (defined('SID') && (!isset($_COOKIE[session_name()]) || $xoopsConfig['use_mysession'] && $xoopsConfig['session_name'] != '' && !isset($_COOKIE[$xoopsConfig['session_name']]))) {
            if (strpos($url, XOOPS_URL) === 0) {
                if (!strstr($url, '?')) {
                    $connector = '?';
                } else {
                    $connector = '&amp;';
                }
                if (strstr($url, '#')) {
                    $urlArray = explode('#', $url);
                    $url = $urlArray[0] . $connector . SID;
                    if (!empty($urlArray[1])) {
                        $url .= '#' . $urlArray[1];
                    }
                } else {
                    $url .= $connector . SID;
                }
            }
        }
        if (!defined('XOOPS_CPFUNC_LOADED')) {
            require_once XOOPS_ROOT_PATH . '/class/template.php';
            $xoopsTpl = new XoopsTpl();
            $xoopsTpl->assign('xoops_sitename', htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES));
            $xoopsTpl->assign('sitename', htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES));
            $xoopsTpl->assign('langcode', _LANGCODE);
            $xoopsTpl->assign('charset', _CHARSET);
            $xoopsTpl->assign('time', $time);
            $xoopsTpl->assign('url', $url);
            $xoopsTpl->assign('message', $displayMessage);
            $xoopsTpl->assign('lang_ifnotreload', sprintf(_IFNOTRELOAD, $url));
            $GLOBALS['xoopsModuleUpdate'] = 1;
            $xoopsTpl->display('db:system_redirect.html');
        } else {
            header('Content-Type:text/html; charset=' . _CHARSET);
            echo '
			<html>
			<head>
			<title>' . htmlspecialchars($xoopsConfig['sitename']) . '</title>
			<meta http-equiv="Content-Type" content="text/html; charset=' . _CHARSET . '" />
			<meta http-equiv="Refresh" content="' . $time . '; url=' . $url . '" />
			<style type="text/css">
					body {background-color : #fcfcfc; font-size: 12px; font-family: Trebuchet MS,Verdana, Arial, Helvetica, sans-serif; margin: 0px;}
					.redirect {width: 70%; margin: 110px; text-align: center; padding: 15px; border: #e0e0e0 1px solid; color: #666666; background-color: #f6f6f6;}
					.redirect a:link {color: #666666; text-decoration: none; font-weight: bold;}
					.redirect a:visited {color: #666666; text-decoration: none; font-weight: bold;}
					.redirect a:hover {color: #999999; text-decoration: underline; font-weight: bold;}
			</style>
			</head>
			<body>
			<div align="center">
			<div class="redirect">
			<span style="font-size: 16px; font-weight: bold;">' . $displayMessage . '</span>
			<hr style="height: 3px; border: 3px #E18A00 solid; width: 95%;" />
			<p>' . sprintf(_IFNOTRELOAD, $url) . '</p>
			</div>
			</div>
			</body>
			</html>';
        }
        exit;
    }