Example #1
0
 /**
  * The plugin main function. Generates all content.
  * @param  string $content The content
  * @param  array  $conf    The plugin configuration vars
  * @return string          The plugin content
  */
 function main($content, $conf)
 {
     /* Initialize base object */
     $this->init($conf);
     $this->pi_USER_INT_obj = $this->conf['cache'] ? 0 : 1;
     $this->config['code'] = $this->cObj->stdWrap($this->conf['code'], $this->conf['code.']);
     $this->tx_mmforum_postfunctions = GeneralUtility::makeInstance('tx_mmforum_postfunctions', $conf, $this->cObj);
     /* Evaluate flexform values */
     $this->evalConfigValues();
     /* Store a reference to the global configuration array */
     $conf =& $this->conf;
     /* Load template file */
     $this->templateFile = $conf['templateFile'];
     /* Load plugin code */
     $codes = GeneralUtility::trimExplode(',', $this->config['code'] ? $this->config['code'] : $this->conf['defaultCode'], 1);
     if (!count($codes)) {
         $codes = array('');
     }
     /* Include RSS feed to header */
     $this->tx_mmforum_rss->setHTMLHeadData('all');
     /* Change page title */
     if ($this->conf['substitutePagetitle']) {
         $this->createPageTitle();
     }
     foreach ($codes as $theCode) {
         list($theCode, $cat, $aFlag) = explode('/', $theCode);
         $theCode = (string) strtoupper(trim($theCode));
         $this->theCode = $theCode;
         switch ($theCode) {
             case 'HAVEALOOK':
                 $content = $this->tx_mmforum_havealook->edit($this);
                 break;
             case 'FAVORITES':
                 $content = $this->favorites($content, $conf);
                 break;
             case 'POSTALERTLIST':
                 $content = $this->tx_mmforum_postalert->list_alerts($conf);
                 break;
             case 'LIST_POSTS':
                 $content = $this->post_history($conf);
                 break;
             case 'LATEST':
                 $content = $this->list_latest($conf);
                 break;
             case 'USERLIST':
                 $content = $this->list_users();
                 break;
             case 'POSTQUEUE':
                 $content = $this->list_postqueue();
                 break;
             case 'RSS':
                 $content = $this->list_rss();
                 break;
             case 'FEADMIN':
                 $content = $this->frontendAdministration();
                 break;
             default:
                 // Include hook to add own content and do change the action to direct it differently
                 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['preDispatchHook'])) {
                     foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['preDispatchHook'] as $_classRef) {
                         $_params = array('content' => &$content, 'conf' => &$conf);
                         $_procObj =& GeneralUtility::getUserObj($_classRef);
                         $_procObj->preDispatchHook($_params, $this);
                     }
                 }
                 if ($this->redirectTo) {
                     HttpUtility::redirect($this->redirectTo);
                 }
                 switch ($this->piVars['action']) {
                     case 'list_unread':
                         $content = $this->list_unread($content, $conf);
                         break;
                     case 'list_unans':
                         $content = $this->list_unanswered($content, $conf);
                         break;
                     case 'list_cat':
                         $content = $this->list_category($content, $conf);
                         break;
                     case 'list_topic':
                         $content = $this->list_topic($content, $conf);
                         break;
                     case 'list_post':
                         $content = $this->tx_mmforum_postfunctions->list_post($content, $conf, '');
                         break;
                     case 'new_topic':
                         $content = $this->new_topic($content, $conf);
                         break;
                     case 'new_post':
                         $content = $this->new_post($content, $conf);
                         break;
                     case 'send_mail':
                         /** @noinspection PhpDeprecationInspection */
                         $content = $this->send_mail($content, $conf);
                         break;
                     case 'forum_view_profil':
                     case 'view_profile':
                         $content = $this->view_profil($content, $conf);
                         break;
                     case 'post_del':
                         $content = $this->tx_mmforum_postfunctions->post_del($content, $conf);
                         break;
                     case 'post_edit':
                         $content = $this->post_edit($content, $conf);
                         break;
                     case 'change_userdata':
                         $content = $this->change_userdata($content, $conf);
                         break;
                     case 'reset_read':
                         $content = $this->reset_unreadpost($content, $conf);
                         break;
                     case 'set_havealook':
                         $content = $this->tx_mmforum_havealook->set($this);
                         break;
                     case 'del_havealook':
                         $content = $this->tx_mmforum_havealook->delete($this);
                         break;
                     case 'set_havealookforum':
                         $content = tx_mmforum_havealookforum::set($this);
                         break;
                     case 'del_havealookforum':
                         $content = tx_mmforum_havealookforum::delete($this);
                         break;
                     case 'set_favorite':
                         $content = $this->set_favorite();
                         break;
                     case 'del_favorite':
                         $content = $this->del_favorite();
                         break;
                     case 'open_topic':
                         $this->open_topic($content, $conf);
                         break;
                     case 'post_alert':
                         $content = $this->tx_mmforum_postalert->post_alert($conf);
                         break;
                     case 'list_prefix':
                         $content = $this->list_prefix($content, $conf, $this->piVars['list_prefix']['prfx']);
                         break;
                     case 'post_history':
                         $content = $this->post_history($conf);
                         break;
                     case 'get_attachment':
                         $content = $this->getAttachment($conf);
                         break;
                     default:
                         if (empty($content)) {
                             $content = $this->list_forum($content, $conf);
                         }
                         break;
                 }
                 if ($this->piVars['solve']) {
                     $content = $this->topic_solve();
                 }
                 if ($this->piVars['unsolve']) {
                     $content = $this->topic_unsolve();
                 }
                 $content = $this->page_header($conf) . $content;
                 break;
         }
     }
     // Include hooks
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['mainContentHook'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['mainContentHook'] as $_classRef) {
             $_procObj =& GeneralUtility::getUserObj($_classRef);
             $content = $_procObj->mainContentHook($content, $this);
         }
     }
     $content .= $this->page_footer($conf);
     return $this->pi_wrapInBaseClass($content);
 }