PageRenderTime 80ms CodeModel.GetById 40ms RepoModel.GetById 1ms app.codeStats 0ms

/application/controllers/ContentController.php

https://github.com/gauravk90/site
PHP | 1373 lines | 805 code | 249 blank | 319 comment | 129 complexity | abf71e7807e9140d819ef76aecb4a0d3 MD5 | raw file
  1. <?php
  2. /**
  3. * ContentController -> Viewing content
  4. *
  5. * Copyright (c) <2009>, Joel Peltonen <joel.peltonen@cs.tamk.fi>
  6. * Copyright (c) <2009>, Pekka Piispanen <pekka.piispanen@cs.tamk.fi>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
  12. * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
  16. * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. *
  18. * License text found in /license/
  19. */
  20. /**
  21. * ContentController - class
  22. *
  23. * @package controllers
  24. * @author Joel Peltonen & Pekka Piispanen
  25. * @copyright 2009 Joel Peltonen & Pekka Piispanen
  26. * @license GPL v2
  27. * @version 1.0
  28. */
  29. class ContentController extends Oibs_Controller_CustomController
  30. {
  31. /**
  32. * init
  33. *
  34. * Initialization of content controller
  35. *
  36. */
  37. public function init()
  38. {
  39. parent::init();
  40. $ajaxContext = $this->_helper->getHelper('AjaxContext');
  41. $ajaxContext->addActionContext('list', 'xml')->initContext();
  42. $this->baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
  43. $this->view->title = 'content-title';
  44. } // end of init()
  45. /**
  46. * indexAction
  47. *
  48. * Content index -- redicrects user to help/guidelines for adding content
  49. */
  50. public function indexAction()
  51. {
  52. //$this->view->title = "Massidea.org";
  53. //if (!$this->view->authenticated){
  54. $url = $this->_urlHelper->url(array('controller' => 'help',
  55. 'action' => 'guidelines',
  56. 'language' => $this->view->language),
  57. 'lang_default', true);
  58. $this->_redirect($url);
  59. //}
  60. }
  61. /**
  62. * listAction
  63. *
  64. * Lists content by content type.
  65. *
  66. */
  67. public function listAction()
  68. {
  69. $url = $this->_urlHelper->url(array('controller' => 'index',
  70. 'language' => $this->view->language),
  71. 'lang_default', true);
  72. // Get cache from registry
  73. $cache = Zend_Registry::get('cache');
  74. // Set array for content data
  75. $data = array();
  76. // Get requests
  77. $params = $this->getRequest()->getParams();
  78. // Get content type
  79. $cty = isset($params['type']) ? $params['type'] : 'all';
  80. if($cty != "idea" && $cty != "finfo" && $cty != "problem") $this->_redirect($url);
  81. // Get page nummber and items per page
  82. $page = isset($params['page']) ? $params['page'] : 1;
  83. $count = isset($params['count']) ? $params['count'] : 15;
  84. // Get list oreder value
  85. $order = isset($params['order']) ? $params['order'] : 'created';
  86. $ind = isset($params['ind']) ? $params['ind'] : 0;
  87. // Get current language id
  88. // $languages = new Default_Model_Languages();
  89. // $idLngInd = $languages->getLangIdByLangName($this->view->language);
  90. // Get recent content by type
  91. $contentModel = new Default_Model_Content();
  92. $data = $contentModel->listRecent($cty, $page, $count, $order, $this->view->language, $ind);
  93. $results = array();
  94. // gather other content data and insert to results array
  95. if(isset($data[0])) {
  96. $contentHasTagModel = new Default_Model_ContentHasTag();
  97. // $contentRatingsModel = new Default_Model_ContentRatings();
  98. $i = 0;
  99. foreach ($data as $content) {
  100. $results[$i] = $content;
  101. $results[$i]['tags'] = $contentHasTagModel
  102. ->getContentTags($content['id_cnt']);
  103. //$results[$i]['ratingdata'] = $contentRatingsModel
  104. // ->getPercentagesById($content['id_cnt']);
  105. $i++;
  106. }
  107. }
  108. // Get total content count
  109. $contentCount = $contentModel->getContentCountByContentType($cty, $this->view->language);
  110. // Calculate total page count
  111. $pageCount = ceil($contentCount / $count);
  112. // Most viewed content
  113. $mostViewedData = $contentModel->getMostViewedType($cty, $page, $count, 'views', 'en', $ind);
  114. // Get all industries
  115. //$industries = new Default_Model_Industries();
  116. //$this->view->industries = $industries->getNamesAndIdsById($ind, $idLngInd);
  117. // Get industry data by id
  118. //$this->view->industryParent = $industries->getById($ind);
  119. // Load most popular tags from cache
  120. if(!$result = $cache->load('IndexTags')) {
  121. $tagsModel = new Default_Model_Tags();
  122. $tags = $tagsModel->getPopular(20);
  123. /*
  124. // resize tags
  125. foreach ($tags as $k => $tag) {
  126. $size = round(50 + ($tag['count'] * 30));
  127. if ($size > 300) {
  128. $size = 300;
  129. }
  130. $tags[$k]['tag_size'] = $size;
  131. }
  132. */
  133. // Action helper for tags
  134. $tags = $this->_helper->tagsizes->tagCalc($tags);
  135. //Action helper for define is tag running number divisible by two
  136. $tags = $this->_helper->tagsizes->isTagDivisibleByTwo($tags);
  137. // Save most popular tags data to cache
  138. $cache->save($tags, 'IndexTags');
  139. } else {
  140. $tags = $result;
  141. }
  142. // Custom pagination to fix memory error on large amount of data
  143. /*
  144. $paginator = new Zend_View();
  145. $paginator->setScriptPath('../application/views/scripts');
  146. $paginator->pageCount = $pageCount;
  147. $paginator->currentPage = $page;
  148. $paginator->pagesInRange = 10;
  149. */
  150. // Send to view
  151. $this->view->tags = $tags;
  152. //$this->view->contentPaginator = $paginator;
  153. $this->view->contentData = $results;
  154. $this->view->type = $cty;
  155. $this->view->count = $count;
  156. $this->view->page = $page;
  157. $this->view->contentCount = $contentCount;
  158. $this->view->ind = $ind;
  159. $this->view->mostViewedData = $mostViewedData;
  160. // RSS type for the layout
  161. $this->view->rsstype = $cty;
  162. } // end of listAction()
  163. /**
  164. * addAction
  165. *
  166. * Adds new content by content type.
  167. *
  168. */
  169. public function addAction()
  170. {
  171. // Get authentication
  172. $auth = Zend_Auth::getInstance();
  173. // If user has identity
  174. if ($auth->hasIdentity()) {
  175. // Get requests
  176. $params = $this->getRequest()->getParams();
  177. // Get content type
  178. $contentType = isset($params['contenttype']) ? $params['contenttype'] : '';
  179. $relatesToId = isset($params['relatestoid']) ? $params['relatestoid'] : 0;
  180. // Get all content types from the database
  181. $modelContentTypes = new Default_Model_ContentTypes();
  182. //$contentTypes = $modelContentTypes->getAllNamesAndIds();
  183. $validContentType = $modelContentTypes->contentTypeExists($contentType);
  184. /*
  185. // Setting the variable first to be true
  186. $invalidContentType = true;
  187. // If set content type exists in database, invalidContentType
  188. // is set to false
  189. foreach($contentTypes as $cty){
  190. if($contentType == $cty['key_cty']) {
  191. $invalidContentType = false;
  192. }
  193. }
  194. */
  195. // Variable $relatesToId is set to 0, just in case that user is not
  196. // adding idea and there's no relatesto_id set
  197. $content = new Default_Model_Content();
  198. if(!$validContentType) {
  199. $message = 'content-add-contenttype-missing-or-invalid';
  200. $url = $this->_urlHelper->url(array('controller' => 'msg',
  201. 'action' => 'index',
  202. 'language' => $this->view->language),
  203. 'lang_default', true);
  204. $this->flash($message, $url);
  205. } elseif($relatesToId != 0) {
  206. /*if($relatesToId == 0) {
  207. $message = 'content-add-relatesto-id-missing';
  208. $url = $this->_urlHelper->url(array('controller' => 'msg',
  209. 'action' => 'index',
  210. 'language' => $this->view->language),
  211. 'lang_default', true);
  212. $this->flash($message, $url);
  213. } */
  214. // Checking if the content that idea is related to exists
  215. $contentExists = $content->checkIfContentExists($relatesToId);
  216. if(!$contentExists) {
  217. $message = 'content-add-invalid-related-content';
  218. $url = $this->_urlHelper->url(array('controller' => 'msg',
  219. 'action' => 'index',
  220. 'language' => $this->view->language),
  221. 'lang_default', true);
  222. $this->flash($message, $url);
  223. }
  224. }
  225. $this->view->contenttype = $this->view->translate($contentType);
  226. $this->view->short_contenttype = $contentType;
  227. $this->view->relatesToId = $relatesToId;
  228. if($relatesToId != 0) {
  229. $relatesToTypeId = $content->getContentTypeIdByContentId($relatesToId);
  230. $this->view->relatesToType = $modelContentTypes->getTypeById($relatesToTypeId);
  231. $this->view->relatesToHeader = $content->getContentHeaderByContentId($relatesToId);
  232. }
  233. // Content type id is needed when adding content to database
  234. $contentTypeId = $modelContentTypes->getIdByType($contentType);
  235. // Cacheing of formData
  236. $cache = Zend_Registry::get('cache');
  237. $formDataCacheTag = 'formData_'.$contentType.'_'.$this->view->language;
  238. if (!($formData = $cache->load($formDataCacheTag) ) || $relatesToId != 0) {
  239. // Creating array for form data
  240. $formData = array();
  241. // Adding data to formData
  242. $formData['content_type'] = $contentTypeId;
  243. $formData['content_relatesto_id'] = $relatesToId;
  244. // Content classifications
  245. $modelFutureinfoClasses = new Default_Model_FutureinfoClasses();
  246. $futureinfoClasses = $modelFutureinfoClasses->getAllNamesAndIds();
  247. $formData['FutureinfoClasses'] = array();
  248. $formData['FutureinfoClasses'][0] = $this->view->translate("content-add-select-finfo-classification");
  249. foreach($futureinfoClasses as $fic) {
  250. $formData['FutureinfoClasses'][$fic['id_fic']] = $fic['name_fic'];
  251. } // end foreach
  252. if(empty($formData['FutureinfoClasses'])) {
  253. $formData['FutureinfoClasses'] = array(0 => '----');
  254. }
  255. $modelInnovationTypes = new Default_Model_InnovationTypes();
  256. $innovationTypes = $modelInnovationTypes->getAllNamesAndIds();
  257. $formData['InnovationTypes'] = array();
  258. $formData['InnovationTypes'][0] =
  259. $this->view->translate("content-add-select-innovation");
  260. foreach($innovationTypes as $ivt) {
  261. $formData['InnovationTypes'][$ivt['id_ivt']] =
  262. $ivt['name_ivt'];
  263. } // end foreach
  264. if(empty($formData['InnovationTypes'])) {
  265. $formData['InnovationTypes'] = array(0 => '----');
  266. }
  267. $languages = New Default_Model_Languages();
  268. $idLngInd = $languages->getLangIdByLangName($this->view->language);
  269. $allLanguages = $languages->getAllNamesAndIds();
  270. $formData['languages'] = array();
  271. $formData['languages'][0] = $this->view->translate("content-add-select-language");
  272. foreach($allLanguages as $lng) {
  273. $formData['languages'][$lng['id_lng']] = $lng['name_lng'];
  274. }
  275. $modelIndustries = new Default_Model_Industries();
  276. $industries = $modelIndustries->getNamesAndIdsById(0, $idLngInd);
  277. $formData['Industries'] = array();
  278. $formData['Industries'][0] =
  279. $this->view->translate("content-add-select-industry");
  280. foreach($industries as $ind) {
  281. $formData['Industries'][$ind['id_ind']] = $ind['name_ind'];
  282. } // end foreach
  283. if(empty($formData['Industries'])) {
  284. $formData['Industries'] = array(0 => '----');
  285. }
  286. // The id of first industry listed is needed when listing the
  287. // divisions for the first time
  288. $firstIndustryId = $modelIndustries->getIndustryId();
  289. $divisions = $modelIndustries->getNamesAndIdsById(
  290. $firstIndustryId, $idLngInd
  291. );
  292. $formData['Divisions'] = array();
  293. $formData['Divisions'][0] = $this->view->translate("content-add-select-division-no-industry");
  294. $formData['Groups'] = array();
  295. $formData['Groups'][0] = $this->view->translate("content-add-select-group-no-division");
  296. $formData['Classes'] = array();
  297. $formData['Classes'][0] = $this->view->translate("content-add-select-class-no-group");
  298. $cache->save($formData, $formDataCacheTag);
  299. }
  300. $formCacheTag = 'form_'.$contentType.'_'.$this->view->language;
  301. // Form for content adding, cacheing if not cached.
  302. // Generate new form if is post because cache will save post parameters and fail
  303. if ($this->getRequest()->isPost()) {
  304. $form = new Default_Form_AddContentForm(null, $formData, $this->view->language, $contentType);
  305. }
  306. elseif (!($form = $cache->load($formCacheTag)) ) {
  307. $form = new Default_Form_AddContentForm(null, $formData, $this->view->language, $contentType);
  308. $cache->save($form, $formCacheTag);
  309. }
  310. $this->view->form = $form;
  311. // Get requests
  312. if($this->getRequest()->isPost()) {
  313. // Get content data
  314. $data = $this->getRequest()->getPost();
  315. // If form data is valid, handle database insertions
  316. if ($form->isValid($data)) {
  317. // If form data is going to be published
  318. if(isset($data['content_publish']) && $data['content_publish'] != '') {
  319. $data['publish'] = 1;
  320. $message_error = 'content-publish-not-successful';
  321. }
  322. // If form data is going to be saved
  323. elseif(isset($data['content_save']) && $data['content_save'] != '') {
  324. $data['publish'] = 0;
  325. $message_error = 'content-save-not-successful';
  326. }
  327. // Content keywords
  328. /* FIXED: split() is deprecated in PHP 5.3.0 -> and removed in
  329. * PHP 6.0, so changed to explode(). Also trim(array) doesn't
  330. * trim array values, so this is done with foreach now.
  331. */
  332. $keywords = array();
  333. foreach(explode(',', $data['content_keywords']) as $keyword) {
  334. if(trim($keyword) != "") {
  335. $keywords[] = strip_tags(trim($keyword));
  336. }
  337. }
  338. $data['content_keywords'] = array_unique($keywords);
  339. // Related companies
  340. $relatedCompanies = array();
  341. foreach(explode(',', $data['content_related_companies']) as $relatedCompany) {
  342. if(trim($relatedCompany) != "") {
  343. $relatedCompanies[] = strip_tags(trim($relatedCompany));
  344. }
  345. }
  346. $data['content_related_companies'] = array_unique($relatedCompanies);
  347. // Get user id
  348. $data['User']['id_usr'] = $auth->getIdentity()->user_id;
  349. if($data['content_division'] == 0) {
  350. $data['content_industry_id'] = $data['content_industry'];
  351. } elseif($data['content_group'] == 0) {
  352. $data['content_industry_id'] = $data['content_division'];
  353. } elseif($data['content_class'] == 0) {
  354. $data['content_industry_id'] = $data['content_group'];
  355. } elseif($data['content_class'] != 0) {
  356. $data['content_industry_id'] = $data['content_class'];
  357. }
  358. $languages = new Default_Model_Languages();
  359. if($data['content_language'] == 0) {
  360. $data['content_language'] = $this->view->language;
  361. }
  362. else {
  363. $data['content_language'] = $languages->getLangNameByLangId($data['content_language']);
  364. }
  365. $data['files'] = $_FILES['content_file_upload'];
  366. // Add a new content
  367. $content = new Default_Model_Content();
  368. $add = $content->addContent($data);
  369. if(!$add) {
  370. $add_successful = false;
  371. } else {
  372. $add_successful = true;
  373. } // end if
  374. $url = $this->_urlHelper->url(array('controller' => 'msg',
  375. 'action' => 'index',
  376. 'language' => $this->view->language),
  377. 'lang_default', true);
  378. if($add_successful) {
  379. if($data['publish'] == 1) {
  380. $url = $this->_urlHelper->url(array('content_id' => $add,
  381. 'language' => $this->view->language),
  382. 'content_shortview', true);
  383. $this->_redirect($url);
  384. }
  385. else {
  386. $userpage = $this->_urlHelper->url(array('controller' => 'account',
  387. 'action' => 'view',
  388. 'user' => $auth->getIdentity()->username,
  389. 'language' => $this->view->language),
  390. 'lang_default', true);
  391. $savedTab = $this->_urlHelper->url(array('controller' => 'account',
  392. 'action' => 'view',
  393. 'user' => $auth->getIdentity()->username,
  394. 'type' => 'saved',
  395. 'language' => $this->view->language),
  396. 'lang_default', true);
  397. $message_ok = $this->view->translate('content-save-successful');
  398. $message_ok .= ' ('.$content->getContentHeaderByContentId($add).')';
  399. $message_ok .= '<br /><br />' . $this->view->translate('content-save-successful2');
  400. $message_ok .= ' <a href="'.$userpage.'">'.$this->view->translate('content-save-successful3').'</a>';
  401. $message_ok .= ' ' . $this->view->translate('content-save-successful4');
  402. $message_ok .= ' <a href="'.$savedTab.'">'.$this->view->translate('content-save-successful5').'</a>.';
  403. $this->flash($message_ok, $url);
  404. }
  405. }
  406. else {
  407. $this->flash($message_error, $url);
  408. }
  409. }
  410. } // end if
  411. } else {
  412. // If not logged, redirecting to system message page
  413. $message = 'content-add-not-logged';
  414. $url = $this->_urlHelper->url(array('controller' => 'msg',
  415. 'action' => 'index',
  416. 'language' => $this->view->language),
  417. 'lang_default', true);
  418. $this->flash($message, $url);
  419. } // end if
  420. } // end of addAction()
  421. /**
  422. * makelinksAction
  423. *
  424. * Make content link to content.
  425. *
  426. */
  427. public function makelinksAction() {
  428. // Get authentication
  429. $auth = Zend_Auth::getInstance();
  430. $absoluteBaseUrl = strtolower(trim(array_shift(explode('/', $_SERVER['SERVER_PROTOCOL'])))) .
  431. '://' . $_SERVER['HTTP_HOST'] . Zend_Controller_Front::getInstance()->getBaseUrl();
  432. // If user has identity
  433. if ($auth->hasIdentity())
  434. {
  435. // Get requests
  436. $params = $this->getRequest()->getParams();
  437. // Get content type
  438. $contenttype = isset($params['contenttype']) ? $params['contenttype'] : '';
  439. $relatestoid = isset($params['parentid']) ? $params['parentid'] : '';
  440. $linkedcontentid = isset($params['childid']) ? $params['childid'] : '';
  441. if($this->validateLinking($contenttype, $relatestoid, $linkedcontentid)) {
  442. $model_cnt_has_cnt = new Default_Model_ContentHasContent();
  443. $model_cnt_has_cnt->addContentToContent($relatestoid, $linkedcontentid);
  444. // Send email to owner of content about a new link
  445. // if user allows linking notifications
  446. $userModel = new Default_Model_User();
  447. $owner = $userModel->getContentOwner($relatestoid);
  448. $notificationsModel = new Default_Model_Notifications();
  449. $notifications = $notificationsModel->getNotificationsById($owner['id_usr']);
  450. if (in_array('link', $notifications)) {
  451. $cntModel = new Default_Model_Content();
  452. $originalHeader = $cntModel->getContentHeaderByContentId($relatestoid);
  453. $linkedHeader = $cntModel->getContentHeaderByContentId($linkedcontentid);
  454. $senderId = $auth->getIdentity()->user_id;
  455. $senderName = $auth->getIdentity()->username;
  456. $emailNotification = new Oibs_Controller_Plugin_Email();
  457. $emailNotification->setNotificationType('link')
  458. ->setSenderId($auth->getIdentity()->user_id)
  459. ->setReceiverId($owner['id_usr'])
  460. ->setParameter('URL', $absoluteBaseUrl."/en")
  461. ->setParameter('SENDER-NAME', $senderName)
  462. ->setParameter('LINKED-ID', $linkedcontentid)
  463. ->setParameter('LINKED-TITLE', $linkedHeader)
  464. ->setParameter('ORIGINAL-ID', $relatestoid)
  465. ->setParameter('ORIGINAL-TITLE', $originalHeader);
  466. if ($emailNotification->isValid()) {
  467. $emailNotification->send();
  468. } else {
  469. //echo $emailNotification->getErrorMessage(); die;
  470. }
  471. }
  472. $url = $this->_urlHelper->url(array('controller' => 'view',
  473. 'action' => $relatestoid,
  474. 'language' => $this->view->language),
  475. 'lang_default', true);
  476. $message = "content-linked-successfully";
  477. $this->flash($message, $url);
  478. }
  479. }
  480. else {
  481. // If not logged, redirecting to system message page
  482. $message = 'content-link-not-logged';
  483. $url = $this->_urlHelper->url(array('controller' => 'msg',
  484. 'action' => 'index',
  485. 'language' => $this->view->language),
  486. 'lang_default', true);
  487. $this->flash($message, $url);
  488. }
  489. }
  490. /**
  491. * removelinksAction
  492. *
  493. * Remove content link from content.
  494. *
  495. * @author Mikko Korpinen
  496. */
  497. public function removelinksAction() {
  498. // Get authentication
  499. $auth = Zend_Auth::getInstance();
  500. // If user has identity
  501. if ($auth->hasIdentity())
  502. {
  503. // Get requests
  504. $params = $this->getRequest()->getParams();
  505. // Get content type
  506. $contenttype = isset($params['contenttype'])
  507. ? $params['contenttype'] : '';
  508. $relatestoid = isset($params['parentid'])
  509. ? $params['parentid'] : '';
  510. $linkedcontentid = isset($params['childid'])
  511. ? $params['childid'] : '';
  512. $id_usr = $auth->getIdentity()->user_id;
  513. $model_content = new Default_Model_Content();
  514. $isOwner = $model_content->checkIfUserIsOwner($relatestoid,$id_usr);
  515. if($isOwner) {
  516. $model_cnt_has_cnt = new Default_Model_ContentHasContent();
  517. $model_cnt_has_cnt->removeContentFromContent($relatestoid, $linkedcontentid);
  518. }
  519. //$message = 'content-unlink-successful';
  520. // TODO:
  521. // Tell the user that the unlink was created.
  522. // Redirect back to the user page
  523. $redirectUrl = $this->_urlHelper->url(array('controller' => 'content',
  524. 'action' => 'unlink',
  525. 'relatestoid' => $relatestoid,
  526. 'language' => $this->view->language),
  527. 'unlinkcontent', true);
  528. $this->_redirector->gotoUrl($redirectUrl);
  529. /*
  530. $url = $this->_urlHelper->url(array('controller' => 'msg',
  531. 'action' => 'index',
  532. 'language' => $this->view->language),
  533. 'lang_default', true);
  534. $this->flash($message, $url); */
  535. } else {
  536. // If not logged, redirecting to system message page
  537. $message = 'content-link-not-logged';
  538. $url = $this->_urlHelper->url(array('controller' => 'msg',
  539. 'action' => 'index',
  540. 'language' => $this->view->language),
  541. 'lang_default', true);
  542. $this->flash($message, $url);
  543. }
  544. }
  545. /**
  546. * linkAction
  547. *
  548. * Get user contents which are related to particular content type
  549. *
  550. * @author ???
  551. * @author 2010 Mikko Korpinen
  552. *
  553. */
  554. public function linkAction() {
  555. // Get authentication
  556. $auth = Zend_Auth::getInstance();
  557. // If user has identity
  558. if ($auth->hasIdentity())
  559. {
  560. // Get requests
  561. $params = $this->getRequest()->getParams();
  562. // Get content type
  563. $contenttype = isset($params['contenttype']) ? $params['contenttype'] : '';
  564. $relatestoid = isset($params['relatestoid']) ? $params['relatestoid'] : '';
  565. if($this->validateLinking($contenttype, $relatestoid, -1)) {
  566. $model_content_types = new Default_Model_ContentTypes();
  567. $model_cnt_has_cnt = new Default_Model_ContentHasContent();
  568. $id_usr = $auth->getIdentity()->user_id;
  569. $id_cty = $model_content_types->getIdByType($contenttype);
  570. $userModel = new Default_Model_User();
  571. $userContents = $userModel->getUserContent($id_usr);
  572. $contents = array();
  573. // If user have not this types content then set false
  574. $hasUserContents = true;
  575. if(!$this->checkIfArrayHasKeyWithValue($userContents, "id_cty_cnt", $id_cty)) {
  576. $this->view->linkingContentType = $contenttype;
  577. $hasUserContents = false;
  578. } else {
  579. foreach($userContents as $content) {
  580. if(!$model_cnt_has_cnt->checkIfContentHasContent($relatestoid, $content['id_cnt']) &&
  581. !$model_cnt_has_cnt->checkIfContentHasContent($content['id_cnt'], $relatestoid)) {
  582. if($content['id_cty_cnt'] == $id_cty && $content['id_cnt'] != $relatestoid) {
  583. $contents[] = $content;
  584. }
  585. }
  586. }
  587. $this->view->relatesToId = $relatestoid;
  588. $this->view->linkingContentType = $contenttype;
  589. $this->view->contents = $contents;
  590. $this->view->hasUserContents = $hasUserContents;
  591. }
  592. }
  593. } else {
  594. // If not logged, redirecting to system message page
  595. $message = 'content-link-not-logged';
  596. $url = $this->_urlHelper->url(array('controller' => 'msg',
  597. 'action' => 'index',
  598. 'language' => $this->view->language),
  599. 'lang_default', true);
  600. $this->flash($message, $url);
  601. }
  602. }
  603. /**
  604. * unlinkAction
  605. *
  606. * Get user contents which are related to particular content
  607. *
  608. * @author 2010 Mikko Korpinen
  609. *
  610. */
  611. public function unlinkAction() {
  612. // Get authentication
  613. $auth = Zend_Auth::getInstance();
  614. // If user has identity
  615. if ($auth->hasIdentity())
  616. {
  617. // Get requests
  618. $params = $this->getRequest()->getParams();
  619. $relatestoid = isset($params['relatestoid'])
  620. ? $params['relatestoid'] : '';
  621. $id_usr = $auth->getIdentity()->user_id;
  622. $contenttype = '';
  623. $contents = array();
  624. $model_content = new Default_Model_Content();
  625. $contentexists = $model_content->checkIfContentExists($relatestoid);
  626. $isOwner = $model_content->checkIfUserIsOwner($relatestoid,$id_usr);
  627. if ($contentexists && $isOwner) {
  628. $relatesToContent = $model_content->getDataAsSimpleArray($relatestoid);
  629. $this->view->relatesToContentTitle = $relatesToContent['title_cnt'];
  630. $model_content_types = new Default_Model_ContentTypes();
  631. $model_cnt_has_cnt = new Default_Model_ContentHasContent();
  632. $contenttype = $model_content_types->getTypeById($relatesToContent['id_cty_cnt']);
  633. $contentContents = $model_cnt_has_cnt->getContentContents($relatestoid);
  634. }
  635. if(!$isOwner) $contentexists = false;
  636. $this->view->contentexists = $contentexists;
  637. $this->view->relatesToId = $relatestoid;
  638. $this->view->linkingContentType = $contenttype;
  639. $this->view->contents = $contentContents;
  640. } else {
  641. // If not logged, redirecting to system message page
  642. $message = 'content-link-not-logged';
  643. $url = $this->_urlHelper->url(array('controller' => 'msg',
  644. 'action' => 'index',
  645. 'language' => $this->view->language),
  646. 'lang_default', true);
  647. $this->flash($message, $url);
  648. }
  649. }
  650. /**
  651. * This function validates linking before linking is made
  652. *
  653. */
  654. public function validateLinking($contenttype, $relatestoid, $linkedcontentid = -1) {
  655. // Get all content types from the database
  656. $model_content_types = new Default_Model_ContentTypes();
  657. $model_content = new Default_Model_Content();
  658. $model_cnt_has_usr = new Default_Model_ContentHasUser();
  659. $model_cnt_has_cnt = new Default_Model_ContentHasContent();
  660. $content_types = $model_content_types->getAllNamesAndIds();
  661. // Setting the variable first to be true
  662. $invalid_contenttype = true;
  663. // If set content type exists in database, invalid_contenttype
  664. // is set to false
  665. foreach($content_types as $cty){
  666. if($contenttype == $cty['key_cty']) {
  667. $invalid_contenttype = false;
  668. }
  669. }
  670. // Setting the variable first to be true
  671. $invalid_relatestoid = true;
  672. // If related content exists in the database, invalid_relatestoid
  673. // is set to false
  674. if($model_content->checkIfContentExists($relatestoid)) {
  675. $invalid_relatestoid = false;
  676. $relatesToContent = $model_content->getDataAsSimpleArray($relatestoid);
  677. $this->view->relatesToContentTitle = $relatesToContent['title_cnt'];
  678. $this->view->relatesToContentTitle = $relatesToContent['title_cnt'];
  679. $this->view->relatesToContentContentType = $model_content_types->getTypeById($relatesToContent['id_cty_cnt']);
  680. }
  681. if(!$invalid_contenttype && !$invalid_relatestoid) {
  682. if($linkedcontentid == -1) {
  683. return true;
  684. } else {
  685. $linkedContent = $model_content->getContentRow($linkedcontentid);
  686. if($linkedContent['published_cnt'] != 0) {
  687. if($model_content->checkIfContentExists($linkedcontentid)) {
  688. // User can not link content with themselves
  689. if ($relatestoid == $linkedcontentid) {
  690. $message = 'content-link-themselves';
  691. $url = $this->_urlHelper->url(array('controller' => 'msg',
  692. 'action' => 'index',
  693. 'language' => $this->view->language),
  694. 'lang_default', true);
  695. $this->flash($message, $url);
  696. }
  697. $auth = Zend_Auth::getInstance();
  698. $id_usr = $auth->getIdentity()->user_id;
  699. // If user owns the content that is going to be linked, returning true
  700. if($model_cnt_has_usr->contentHasOwner($id_usr, $linkedcontentid)) {
  701. return true;
  702. } else {
  703. $message = 'content-link-not-content-owner';
  704. $url = $this->_urlHelper->url(array('controller' => 'msg',
  705. 'action' => 'index',
  706. 'language' => $this->view->language),
  707. 'lang_default', true);
  708. $this->flash($message, $url);
  709. }
  710. } else {
  711. $message = 'content-link-linked-content-not-exist';
  712. $url = $this->_urlHelper->url(array('controller' => 'msg',
  713. 'action' => 'index',
  714. 'language' => $this->view->language),
  715. 'lang_default', true);
  716. $this->flash($message, $url);
  717. }
  718. } else {
  719. $message = 'content-link-not-published';
  720. $url = $this->_urlHelper->url(array('controller' => 'msg',
  721. 'action' => 'index',
  722. 'language' => $this->view->language),
  723. 'lang_default', true);
  724. $this->flash($message, $url);
  725. }
  726. }
  727. } else {
  728. if($invalid_contenttype) {
  729. $message = 'content-link-invalid-contenttype';
  730. $url = $this->_urlHelper->url(array('controller' => 'msg',
  731. 'action' => 'index',
  732. 'language' => $this->view->language),
  733. 'lang_default', true);
  734. $this->flash($message, $url);
  735. } elseif($invalid_relatestoid) {
  736. $message = 'content-link-invalid-relatestoid';
  737. $url = $this->_urlHelper->url(array('controller' => 'msg',
  738. 'action' => 'index',
  739. 'language' => $this->view->language),
  740. 'lang_default', true);
  741. $this->flash($message, $url);
  742. }
  743. }
  744. }
  745. public function previewAction()
  746. {
  747. // Get authentication
  748. $auth = Zend_Auth::getInstance();
  749. // Disable layout to be rendered
  750. $this->_helper->layout->disableLayout();
  751. // If user has authenticated
  752. if($auth->hasIdentity())
  753. {
  754. // Get user data
  755. $userId = $auth->getIdentity()->user_id;
  756. $userName = $auth->getIdentity()->username;
  757. $userModel = new Default_Model_User();
  758. $userData = $userModel->getSimpleUserDataById($userId);
  759. // Get requests
  760. if($this->getRequest()->isPost())
  761. {
  762. // Get POST data and convert it to UTF-8 compatible html entities
  763. $rawpostData = $this->getRequest()->getPost();
  764. foreach($rawpostData as $key => $value)
  765. $postData[$key] = htmlentities($value, ENT_QUOTES, "UTF-8");
  766. // Set today's date and time
  767. $today = date('Y-m-d H:i:m');
  768. // Get content type of the specific content viewed
  769. $contentTypesModel = New Default_Model_ContentTypes();
  770. $contentType = $contentTypesModel->getTypeById($postData['content_type']);
  771. // Reformat preview data
  772. $contentData =
  773. array('id_cnt' => 'preview',
  774. 'id_cty_cnt' => $postData['content_type'],
  775. 'title_cnt' => (isset($postData['content_header'])) ? $postData['content_header'] : '',
  776. 'lead_cnt' => (isset($postData['content_textlead'])) ? $postData['content_textlead'] : '',
  777. 'language_cnt' => (isset($postData['content_language'])) ? $postData['content_language'] : '',
  778. 'body_cnt' => (isset($postData['content_text'])) ? $postData['content_text'] : '',
  779. 'research_question_cnt' => (isset($postData['content_research'])) ? $postData['content_research'] : '',
  780. 'opportunity_cnt' => (isset($postData['content_opportunity'])) ? $postData['content_opportunity'] : '',
  781. 'threat_cnt' => (isset($postData['content_threat'])) ? $postData['content_threat'] : '',
  782. 'solution_cnt' => (isset($postData['content_solution'])) ? $postData['content_solution'] : '',
  783. 'references_cnt' => (isset($postData['content_references'])) ? $postData['content_references'] : '',
  784. 'views_cnt' => 0,
  785. 'published_cnt' => 1,
  786. 'created_cnt' => $today,
  787. 'modified_cnt' => $today,
  788. 'id_usr' => $userId,
  789. 'login_name_usr' => $userName,
  790. 'key_cty' => $postData['content_type'],
  791. 'name_cty' => $contentType
  792. );
  793. // Reformat tags
  794. $rawtags = explode(",", $postData['content_keywords']);
  795. $tags = null;
  796. foreach($rawtags as $rawtag)
  797. $tags[count($tags)]['name_tag'] = $rawtag;
  798. // Get form
  799. $form = new Default_Form_PreviewContentForm();
  800. // Inject previewdata to view
  801. $this->view->previewMode = 1;
  802. $this->view->files = null;
  803. $this->view->id = 'preview';
  804. //$this->view->industries = $industries;
  805. //$this->view->userImage = $userImage;
  806. //$this->view->commentPaginator = $paginator;
  807. //$this->view->commentData = $commentsSorted;
  808. //$this->view->user_can_comment = $user_can_comment;
  809. $this->view->contentData = $contentData;
  810. //$this->view->modified = $contentData['modified_cnt'];
  811. $this->view->userData = $userData;
  812. //$this->view->moreFromUser = $moreFromUser;
  813. $this->view->views = $contentData['views_cnt'];
  814. //$this->view->rating = $rating;
  815. $this->view->tags = $tags;
  816. //$this->view->links = $links;
  817. //$this->view->parents = $parents;
  818. //$this->view->parent_siblings = $parent_siblings;
  819. //$this->view->children = $children;
  820. //$this->view->children_siblings = $children_siblings;
  821. //$this->view->rivals = $rivals;
  822. //$this->view->comments = $commentCount;
  823. $this->view->contentType = $contentType;
  824. //$this->view->count = $count;
  825. $this->view->form = $form;
  826. //$this->view->favourite = $favourite;
  827. // Inject title to view
  828. $this->view->title = $this->view->translate('index-home') . " - " . $contentData['title_cnt'];
  829. }
  830. }
  831. else
  832. {
  833. $message = 'content-preview-not-logged-in';
  834. $url = $this->_urlHelper->url(array('controller' => 'msg',
  835. 'action' => 'index',
  836. 'language' => $this->view->language),
  837. 'lang_default', true);
  838. $this->flash($message, $url);
  839. }
  840. }
  841. /**
  842. * editAction
  843. *
  844. * Edit content
  845. *
  846. */
  847. public function editAction()
  848. {
  849. // Get authentication
  850. $auth = Zend_Auth::getInstance();
  851. // If user has identity
  852. if ($auth->hasIdentity()) {
  853. // Get requests
  854. $params = $this->getRequest()->getParams();
  855. // Get session data
  856. $previewSession = new Zend_Session_Namespace('contentpreview');
  857. // If preview
  858. $backFromPreview = isset($previewSession->backFromPreview) ? $previewSession->backFromPreview : 0;
  859. $preview = isset($params['preview']) ? 1:0;
  860. if($preview)
  861. {
  862. $previewSession->unsetAll();
  863. $previewSession->previewData = $params;
  864. $backToUrl = $this->getRequest()->getRequestUri();
  865. $previewSession->backToUrl = $backToUrl;
  866. $url = $this->_urlHelper->url(array('controller' => 'content',
  867. 'action' => 'preview',
  868. 'language' => $this->view->language),
  869. 'lang_default', true);
  870. $this->_redirect($url);
  871. }
  872. // Get content type
  873. $contentId = isset($params['content_id'])
  874. ? $params['content_id'] : 0;
  875. $userId = $auth->getIdentity()->user_id;
  876. $cntHasUsr = New Default_Model_ContentHasUser();
  877. $userIsOwner = $cntHasUsr->contentHasOwner($userId, $contentId);
  878. if($userIsOwner) {
  879. if($contentId != 0) {
  880. $content = New Default_Model_Content();
  881. $data = $content->getDataAsSimpleArray($contentId);
  882. // Creating array for form data
  883. $formData = array();
  884. // Adding content type to form
  885. $formData['content_type'] = $data['id_cty_cnt'];
  886. // Adding content id to form
  887. $formData['content_id'] = $contentId;
  888. $formData['content_header'] = stripslashes($data['title_cnt']);
  889. $modelCntHasTag = New Default_Model_ContentHasTag();
  890. $keywords = $modelCntHasTag->getContentTags($data['id_cnt']);
  891. $tags = "";
  892. $tagCount = count($keywords);
  893. for($i = 0; $i < $tagCount; $i++) {
  894. $tags .= $keywords[$i]['name_tag'];
  895. if ($i != $tagCount - 1) {
  896. $tags .= ', ';
  897. }
  898. }
  899. $formData['content_keywords'] = stripslashes($tags);
  900. $formData['content_textlead'] = stripslashes($data['lead_cnt']);
  901. $formData['content_text'] = stripslashes($data['body_cnt']);
  902. $modelCntHasRec = New Default_Model_ContentHasRelatedCompany();
  903. $relComps = $modelCntHasRec->getContentRelComps($data['id_cnt']);
  904. $recs = "";
  905. $recCount = count($relComps);
  906. for($i = 0; $i < $recCount; $i++) {
  907. $recs .= $relComps[$i]['name_rec'];
  908. if ($i != $recCount - 1) {
  909. $recs .= ', ';
  910. }
  911. }
  912. $formData['content_related_companies'] = stripslashes($recs);
  913. $formData['content_research'] = $data['research_question_cnt'];
  914. $formData['content_opportunity'] = $data['opportunity_cnt'];
  915. $formData['content_threat'] = $data['threat_cnt'];
  916. $formData['content_solution'] = $data['solution_cnt'];
  917. $formData['published_cnt'] = $data['published_cnt'];
  918. $formData['content_references'] = $data['references_cnt'];
  919. $languages = New Default_Model_Languages();
  920. $idLngInd = $languages->getLangIdByLangName($this->view->language);
  921. $allLanguages = $languages->getAllNamesAndIds();
  922. $formData['languages'] = array();
  923. $formData['languages'][0] = $this->view->translate("content-add-select-language");
  924. foreach($allLanguages as $lng) {
  925. $formData['languages'][$lng['id_lng']] = $lng['name_lng'];
  926. }
  927. $finfoClasses = new Default_Model_FutureinfoClasses();
  928. $allClasses = $finfoClasses->getAllNamesAndIds();
  929. $formData['FutureinfoClasses'] = array();
  930. $formData['FutureinfoClasses'][0] = $this->view->translate("content-add-select-finfo-classification");
  931. foreach($allClasses as $class) {
  932. $formData['FutureinfoClasses'][$class['id_fic']] = $class['name_fic'];
  933. }
  934. // Getting innovation types from the database
  935. $modelInnovationTypes = new Default_Model_InnovationTypes();
  936. $innovationTypes = $modelInnovationTypes->getAllNamesAndIds();
  937. // Getting the innovation type of the content
  938. $modelCntHasIvt = new Default_Model_ContentHasInnovationTypes();
  939. $formData['selected_ivt'] =
  940. $modelCntHasIvt->getInnovationTypeIdOfContent($data['id_cnt']);
  941. // Adding all innovation types to form
  942. $formData['InnovationTypes'] = array();
  943. $formData['InnovationTypes'][0] =
  944. $this->view->translate("content-add-select-innovation");
  945. foreach($innovationTypes as $ivt) {
  946. $formData['InnovationTypes'][$ivt['id_ivt']] =
  947. $ivt['name_ivt'];
  948. } // end foreach
  949. if(empty($formData['InnovationTypes'])) {
  950. $formData['InnovationTypes'] = array(0 => '----');
  951. }
  952. $languages = New Default_Model_Languages();
  953. $idLngInd = $languages->getLangIdByLangName($this->view->language);
  954. // Getting language of the content
  955. $formData['content_language'] = $languages->getLangIdByLangName($data['language_cnt']);
  956. // Getting the industry of the content
  957. $modelCntHasInd = new Default_Model_ContentHasIndustries();
  958. $cntInd = $modelCntHasInd->getIndustryIdOfContent($data['id_cnt']);
  959. // Getting industries from the database
  960. $modelIndustries = new Default_Model_Industries();
  961. $industries = $modelIndustries->getNamesAndIdsById(0, $idLngInd);
  962. // Getting all industries of the content
  963. $industryIds = $modelIndustries->getAllContentIndustryIds($cntInd);
  964. $formData['industryIds'] = $industryIds;
  965. // Adding all industries of the content to form
  966. $formData['selected_industry'] = $industryIds[0];
  967. $formData['selected_division'] = $industryIds[1];
  968. $formData['selected_group'] = $industryIds[2];
  969. $formData['selected_class'] = $industryIds[3];
  970. // Adding all industries to form
  971. $formData['Industries'] = array();
  972. $formData['Industries'][0] =
  973. $this->view->translate("content-add-select-industry");
  974. foreach($industries as $ind) {
  975. $formData['Industries'][$ind['id_ind']] = $ind['name_ind'];
  976. } // end foreach
  977. if(empty($formData['Industries'])) {
  978. $formData['Industries'] = array(0 => '----');
  979. }
  980. // Adding all divisions to form
  981. $formData['Divisions'] = array();
  982. $formData['Divisions'][0] = $this->view->translate("content-add-select-division-no-industry");
  983. if($industryIds[0] != 0) {
  984. $divisions = $modelIndustries
  985. ->getNamesAndIdsById($industryIds[0], $idLngInd);
  986. foreach($divisions as $div) {
  987. $formData['Divisions'][$div['id_ind']] = $div['name_ind'];
  988. } // end foreach
  989. }
  990. // Adding all groups to form
  991. $formData['Groups'] = array();
  992. $formData['Groups'][0] = $this->view->translate("content-add-select-group-no-division");
  993. if($industryIds[1] != 0) {
  994. $groups = $modelIndustries->getNamesAndIdsById($industryIds[1], $idLngInd);
  995. foreach($groups as $grp) {
  996. $formData['Groups'][$grp['id_ind']] = $grp['name_ind'];
  997. } // end foreach
  998. }
  999. $formData['Classes'] = array();
  1000. $formData['Classes'][0] = $this->view->translate("content-add-select-class-no-group");
  1001. // If there's no group selected
  1002. if($industryIds[2] != 0) {
  1003. $classes = $modelIndustries->getNamesAndIdsById($industryIds[2], $idLngInd);
  1004. foreach($classes as $class) {
  1005. $formData['Classes'][$class['id_ind']] = $class['name_ind'];
  1006. } // end foreach
  1007. }
  1008. $modelContentTypes = new Default_Model_ContentTypes();
  1009. $contentType = $modelContentTypes->getTypeById($data['id_cty_cnt']);
  1010. $this->view->short_contenttype = $contentType;
  1011. $title_cnt = $content->getContentHeaderByContentId($data['id_cnt']);
  1012. $this->view->contentHeader = $title_cnt;
  1013. // Get contents filenames from database
  1014. $filesModel = new Default_Model_Files();
  1015. $filenames = $filesModel->getFilenamesByCntId($contentId);
  1016. $formData['filenames'] = $filenames;
  1017. // Form for content adding
  1018. $form = new Default_Form_EditContentForm(null, $formData, $contentId, $contentType, $this->view->language);
  1019. $form->populate($formData);
  1020. $this->view->form = $form;
  1021. $url = $this->_urlHelper->url(array('controller' => 'msg',
  1022. 'action' => 'index',
  1023. 'language' => $this->view->language),
  1024. 'lang_default', true);
  1025. // populate form
  1026. if($backFromPreview)
  1027. {
  1028. // Get previewdata and populate it to form
  1029. $previewData = $previewSession->previewData;
  1030. $form->populate($previewData);
  1031. // Delete session data
  1032. $previewSession->unsetAll();
  1033. }
  1034. // If posted
  1035. if($this->getRequest()->isPost()) {
  1036. // Get content data
  1037. $data = $this->getRequest()->getPost();
  1038. // Content id
  1039. $data['content_id'] = $contentId;
  1040. // If form data is valid, handle database insertions
  1041. if($form->isValid($data)) {
  1042. // If form data is going to be published
  1043. if(isset($data['content_publish'])) {
  1044. $data['publish'] = 1;
  1045. $message_error = 'content-publish-not-successful';
  1046. }
  1047. // If form data is going to be saved
  1048. elseif(isset($data['content_save'])) {
  1049. $data['publish'] = 0;
  1050. $message_error = 'content-save-not-successful';
  1051. }
  1052. // Content keywords
  1053. /* FIXED: split() is deprecated in PHP 5.3.0 -> and removed in
  1054. * PHP 6.0, so changed to explode(). Also trim(array) doesn't
  1055. * trim array values, so this is done with foreach now.
  1056. */
  1057. $keywords = array();
  1058. foreach(explode(',', $data['content_keywords']) as $keyword) {
  1059. if(trim($keyword) != "") {
  1060. $keywords[] = strip_tags(trim($keyword));
  1061. }
  1062. }
  1063. $data['content_keywords'] = array_unique($keywords);
  1064. // Related companies
  1065. $relatedCompanies = array();
  1066. foreach(explode(',', $data['content_related_companies']) as $relatedCompany) {
  1067. if(trim($relatedCompany) != "") {
  1068. $relatedCompanies[] = strip_tags(trim($relatedCompany));
  1069. }
  1070. }
  1071. $data['content_related_companies'] = array_unique($relatedCompanies);
  1072. // Get user id
  1073. $data['User']['id_usr'] = $auth->getIdentity()->user_id;
  1074. /*
  1075. if($data['content_division'] == 0) {
  1076. $data['content_industry_id'] = $data['content_industry'];
  1077. } elseif($data['content_group'] == 0) {
  1078. $data['content_industry_id'] = $data['content_division'];
  1079. } elseif($data['content_class'] == 0) {
  1080. $data['content_industry_id'] = $data['content_group'];
  1081. } elseif($data['content_class'] != 0) {
  1082. $data['content_industry_id'] = $data['content_class'];
  1083. }*/
  1084. if($data['content_language'] == 0) {
  1085. $data['content_language'] = $this->view->language;
  1086. } else {
  1087. $data['content_language'] = $languages->getLangNameByLangId($data['content_language']);
  1088. }
  1089. //echo "<pre>"; print_r($data); echo "</pre>"; die();
  1090. $data['files'] = $_FILES['content_file_upload'];
  1091. // Edit content
  1092. $content = new Default_Model_Content();
  1093. $oldData = $content->getContentRow($contentId);
  1094. $edit = $content->editContent($data);
  1095. $url = $this->_urlHelper->url(array('controller' => 'msg',
  1096. 'action' => 'index',
  1097. 'language' => $this->view->language),
  1098. 'lang_default', true);
  1099. if($edit) {
  1100. //$favourite = new Default_Model_UserHasFavourites();
  1101. //$favouriteEdited = $favourite->setFavouriteModifiedTrue($edit);
  1102. if($oldData['published_cnt'] == 1) {
  1103. $url = $this->_urlHelper->url(array('content_id' => $edit,
  1104. 'language' => $this->view->language),
  1105. 'content_shortview', true);
  1106. $this->_redirect($url);
  1107. } else {
  1108. $message_ok = $this->view->translate('content-save-successful');
  1109. $message_ok .= ' ('.$content->getContentHeaderByContentId($edit).')';
  1110. $message_ok .= '<br /><br />' . $this->view->translate('content-save-successful2');
  1111. $userpage = $this->_urlHelper->url(array('controller' => 'account',
  1112. 'action' => 'view',
  1113. 'user' => $auth->getIdentity()->username,
  1114. 'language' => $this->view->language),
  1115. 'lang_default', true);
  1116. $message_ok .= ' <a href="'.$userpage.'">'.$this->view->translate('content-save-successful3').'</a>';
  1117. $message_ok .= ' ' . $this->view->translate('content-save-successful4');
  1118. $this->flash($message_ok, $url);
  1119. }
  1120. } else {
  1121. $this->flash($m