示例#1
0
 /**
  * Method for getting the posts via AJAX. Note AJAX suffix so it can take advantage of com_ajax
  *
  * @return   array  The details of the post created.
  *
  * @since   __DEPLOY_VERSION__
  * @throws  RuntimeException
  */
 public static function getPostsAjax()
 {
     $app = JFactory::getApplication();
     $post = $app->input->post->get('jjshout', array(), 'array');
     // Retrieve required parameter
     if (!isset($post['title'])) {
         throw new InvalidArgumentException("Couldn't assemble the necessary parameters for the module");
     }
     $helper = new ModShoutboxHelper($post['title']);
     $helper->ajax = true;
     $offset = 0;
     if (isset($post['offset'])) {
         $offset = $post['offset'];
     }
     $shouts = $helper->getShouts($offset, $helper->getParams()->get('maximum'), JText::_('SHOUT_DATABASEERRORSHOUT'));
     $htmlOutput = '';
     foreach ($shouts as $shout) {
         $htmlOutput .= $helper->renderPost($shout);
     }
     // Return the HTML representation, the id and the message contents
     $result = array('html' => $htmlOutput);
     return $result;
 }