public function get_texts_draft_of_author_url() { // Get the application object. $app = JFactory::getApplication(); $author_id = JRequest::getInt('author_id'); $pub = JRequest::getInt('published'); $user_id = JFactory::getUser()->get('id'); $texts = ideary::getTextsOfUser($author_id, $pub, 0, 10); $authorsection = JRequest::getInt('authorsection'); $textHtmlArray = array(); foreach ($texts as $index => $text) { $textHtmlArray[] = ideary::removeNewLinesFromString(ideary::generateTextContent($text, $user_id, $index, false, $authorsection)); } echo json_encode(array('texts' => $textHtmlArray)); $app->close(); }
public function get_more_texts_of_author() { // Get the application object. $app = JFactory::getApplication(); $userId = JRequest::getInt('userId'); $offset = JRequest::getInt('offset'); $text_type = JRequest::getString('text_type'); switch ($text_type) { case "published": $texts = ideary::getTextsOfUser($userId, 1, $offset); $profile = 1; $authorsection = 1; $type = 'mine'; break; case "draft": $texts = ideary::getTextsOfUser($userId, 0, $offset); $profile = 1; $authorsection = 1; $type = 'draft'; break; case "favourites": $texts = ideary::getFavArchTexts(1, $offset); $profile = 1; $authorsection = 0; $type = 'default'; break; case "applauded": $texts = ideary::getTextsApplaudedByUser($userId, $offset); $profile = 1; $authorsection = 0; $type = 'default'; break; case "archived": $texts = ideary::getFavArchTexts(0, $offset); $profile = 0; $authorsection = 0; $type = 'default'; break; } $textHtmlArray = array(); if (!empty($texts)) { foreach ($texts as $index => $text) { $textHtmlArray[] = ideary::removeNewLinesFromString(ideary::generateTextContent($text, $userId, $offset + $index, $profile, $authorsection, false, $type)); } } echo json_encode(array('texts' => $textHtmlArray)); $app->close(); }
/** * Method to display the view. * * @param string $tpl The template file to include * @since 1.6 */ public function display($tpl = null) { // Get the view data. $this->data = $this->get('Data'); $this->form = $this->get('Form'); $this->state = $this->get('State'); $this->params = $this->state->get('params'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } // Check if a user was found. if (!$this->data->id) { JError::raiseError(404, JText::_('JERROR_USERS_PROFILE_NOT_FOUND')); return false; } $app = JFactory::getApplication(); $this->user2 = JFactory::getUser(); $getUserId = $_GET['user_id'] ? $_GET['user_id'] : $this->user2->id; if ($getUserId != $this->user2->id) { $app->redirect(JRoute::_('index.php')); } // Check for layout override $active = JFactory::getApplication()->getMenu()->getActive(); if (isset($active->query['layout'])) { $this->setLayout($active->query['layout']); } $this->user = ideary::getUserInfoById($this->user2->id); $this->userData = ideary::getUserById($this->user2->id); $resultEN = strpos($this->user->params, 'en-GB'); $resultES = strpos($this->user->params, 'es-ES'); $resultPT = strpos($this->user->params, 'pt-BR'); $userextra = Ideary::getExtraUserData($_GET["id"]); if ($resultEN != false && $resultEN != null) { $currentlang = 'en-GB'; } elseif ($resultES != false && $resultES != null) { $currentlang = 'es-ES'; } elseif ($resultPT != false && $resultPT != null) { $currentlang = 'pt-BR'; } $this->assignRef('userextra', $userextra); $this->assignRef('currentlang', $currentlang); $this->userDatafinal = Ideary::getuserData($this->user->id); $this->userDatafinal = $this->userDatafinal[0]; $this->userExtraData = Ideary::getExtraUserData($this->user->id); $this->cant_pub = Ideary::getUserCantTexts($this->user->id, 1); $this->cant_draft = Ideary::getUserCantTexts($this->user->id, 0); if ($_GET["layout"] == "edit") { $this->categories = Ideary::getCategories(); $this->user_interests = Ideary::getUserInterests($this->user->id); } if ($_GET["layout"] == "userconfiguration") { $this->UserNotifSettings = Ideary::getUserNotifSettings($this->user->id); if (count($this->UserNotifSettings) > 0) { $this->UserNotifSettings = $this->UserNotifSettings[0]; } } $pub = $_GET['draft'] == 1 ? 0 : 1; $text_type = $pub ? 'published' : 'draft'; $texts = ideary::getTextsOfUser($this->user->id, $pub, 0, 10); $countAlltexts = ideary::getCountTextsByUserId($this->user->id, $pub); $this->assignRef('texts', $texts); $this->assignRef('countAlltexts', $countAlltexts); $this->assignRef('text_type', $text_type); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx')); $this->prepareDocument(); parent::display($tpl); }