PageRenderTime 52ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/application/models/display_model.php

https://bitbucket.org/gradido/gradido-easy/
PHP | 1556 lines | 901 code | 329 blank | 326 comment | 251 complexity | ca68b77a65449d2657864598706f21dd MD5 | raw file
Possible License(s): GPL-2.0, Apache-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. /**
  3. * Name: Display Model
  4. *
  5. * Author: Bernd Hueckstaedt
  6. * akademie@joytopia.net
  7. * @BerndHueckstaedt
  8. *
  9. *
  10. *
  11. * Created: 10.08.2010
  12. *
  13. * Description: Display Gradido Messages
  14. *
  15. *
  16. * Requirements: PHP5 or above
  17. *
  18. */
  19. // CI 2.0 Compatibility
  20. if(!class_exists('CI_Model')) { class CI_Model extends Model {} }
  21. class Display_model extends CI_Model
  22. {
  23. public $display_single;
  24. public $offset;
  25. public $ad_count = 0;
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. $this->load->library('gradido');
  30. $this->load->library('gradido_market');
  31. $this->load->library('oembed');
  32. $this->load->model('gradido_model');
  33. $this->load->config('ion_auth');
  34. $this->load->model('user_model');
  35. $this->load->model('banner_model');
  36. $this->init_vars();
  37. }
  38. private function init_vars()
  39. {
  40. }
  41. //-----------------------------------------------------------------------------------------
  42. /**
  43. * make_message_view
  44. *
  45. * @input int $i
  46. * @input int $row
  47. *
  48. * @return string the output of the single message view
  49. *
  50. * @author Bernd
  51. *
  52. **/
  53. public function make_message_view($i, $row)
  54. {
  55. if($this->gradido->display)
  56. {
  57. //////////////////////////////////////////
  58. // other's userimage, link it etc.
  59. //////////////////////////////////////////
  60. $this->other($row);
  61. $this->other_image($row);
  62. $this->message_head($row);
  63. //////////////////////////////////////////
  64. // Message
  65. //////////////////////////////////////////
  66. if ($this->gradido->display_single)
  67. {
  68. $this->full_message($row);
  69. if ($row->type == 2 && $row->mode <= 2)
  70. $view = 's_my_topics_full';
  71. else
  72. $view = $this->config->item('currency2') ? 's_message_full_c2' : 's_message_full';
  73. }
  74. //elseif (0 == $i && 0 == $this->gradido->offset) // first message on first page
  75. elseif (0 == $i) // first message on each page
  76. {
  77. // first message
  78. $this->short_message($row, $i);
  79. if ($row->type == 2 && $row->mode <= 2 && $row->abbrev == 1)
  80. $view ='s_my_topics_first';
  81. elseif ($row->type == 2 && $row->mode <= 2)
  82. $view ='s_my_topics_full';
  83. else
  84. $view = $this->config->item('currency2') ? 's_message_first_c2' : 's_message_first';
  85. }
  86. else
  87. {
  88. $this->short_message($row, $i);
  89. if ($row->type == 2 && $row->mode <= 2 && $row->abbrev == 1)
  90. $view ='s_my_topics_single';
  91. elseif ($row->type == 2 && $row->mode <= 2)
  92. $view ='s_my_topics_full';
  93. else
  94. $view = $this->config->item('currency2') ? 's_message_single_c2' : 's_message_single';
  95. }
  96. }
  97. $this->gradido->data['message'] .= $this->edit_links($row);
  98. // show the back link (backlink, back_link)
  99. if ($this->gradido->display_single && $this->session->userdata('list_uri') && ! $this->gradido->code)
  100. {
  101. $this->gradido->data['message'] .= br(2).anchor($this->session->userdata('list_uri'), '>>> '.lang('gradido.nav_back').' >>>').br(2);
  102. }
  103. return $this->load->view('messages/'.$view, $this->gradido->data, true)."\n";
  104. }
  105. //-----------------------------------------------------------------------------------------
  106. /**
  107. * make_message_list
  108. * and calculate messages
  109. * @return void
  110. * @author Bernd
  111. **/
  112. public function make_message_list($add_value = FALSE)
  113. {
  114. if ($this->gradido->calc_mode) {
  115. $query = $this->gradido->select_messages('max', $add_value);
  116. if ('special' != $this->gradido->page_mode)
  117. $this->gradido->display = FALSE;
  118. }
  119. elseif ($this->gradido->first_entry OR $this->gradido->display_single)
  120. $query = $this->gradido->select_messages('one', $add_value);
  121. else
  122. $query = $this->gradido->select_messages('page', $add_value);
  123. $single_messages = '';
  124. $add_markers = array();
  125. if ($query->num_rows() > 0)
  126. {
  127. $i = 0;
  128. foreach ($query->result() as $row)
  129. {
  130. $this->row_model->process_row($row, $i);
  131. $this->message_event_time($row);
  132. if ($this->gradido->display === 'list')
  133. {
  134. $single_messages .= $this->make_message_view($i, $row);
  135. if ($this->gradido->select_mode === 'message_id')
  136. {
  137. // $single_messages .= br(2).'<hr class = "list_clear">'; // does not validate
  138. }
  139. $single_messages .= $this->make_advertising_view($i, $row);
  140. }
  141. elseif ($this->gradido->display === 'map')
  142. {
  143. $marker = array(
  144. 'header' => $row->s_name,
  145. 'link' => server_base_url($row->s_server).current_lang_short(FALSE, TRUE).$this->make_subject_link($row),
  146. 'subject' => $row->subject,
  147. 'time' => 6 === element('ad_class', $this->gradido_market->ad_param) ?
  148. $this->gradido->format('datetime_no_nbs',$row->event_start).', '.$row->event_repeat : '',
  149. 'message' => $row->message,
  150. 'icon' => 'generic',
  151. 'text' => $i+1,
  152. 'address_circa' => $row->s_address_circa,
  153. 'address_street'=> $row->s_address_street,
  154. 'latitude' => $row->s_latitude,
  155. 'longitude' => $row->s_longitude,
  156. 's_show_position'=> $row->s_show_position,
  157. 'message_id' =>$row->message_id,
  158. );
  159. $add_markers[] = $marker;
  160. }
  161. $i++;
  162. // Maximal number of entries which are calculated at one time
  163. $limit = $this->config->item('max_calculate_entries');
  164. if ($i > $limit) break;
  165. }
  166. }
  167. // display or hide write form
  168. if($this->gradido->is_write_act() && $this->gradido->edit_message_id)
  169. {
  170. if ( ! $this->gradido->edit_message_id)
  171. $this->gradido->data['top_elements'] = $this->gradido->set_top_elements();
  172. if ( isset($row) && $row)
  173. {
  174. $this->gradido->mcontent = $this->write_model->write('', $row);
  175. }
  176. else
  177. {
  178. $this->session->unset_userdata('Write_Message');
  179. redirect($this->gradido->poo->username);
  180. }
  181. }
  182. ///////////////////////////////////////////////////////////////
  183. // Display
  184. // as List or as Map
  185. ///////////////////////////////////////////////////////////////
  186. if ($this->gradido->display === 'list')
  187. {
  188. if ($this->gradido->page_mode === 'content')
  189. $single_messages .= br(2).'<hr class = "list_clear">'.$this->make_advertising_view('', '', TRUE);
  190. $this->display_message_page($single_messages);
  191. }
  192. elseif ($this->gradido->display === 'map')
  193. return $add_markers;
  194. }
  195. //-----------------------------------------------------------------------------------------
  196. /**
  197. * display_message_page
  198. *
  199. *
  200. * @return
  201. * @author Bernd
  202. *
  203. **/
  204. public function display_message_page($single_messages)
  205. {
  206. if ( ! $this->gradido->calc_mode && ! $this->gradido->first_entry && ! $this->gradido->display_single)
  207. $this->gradido->mcontent .= $this->pagination->create_links();
  208. $this->gradido->mcontent .= "\n <div class = \"messages\"> \n ";
  209. $this->gradido->mcontent .= "<br /><ul> \n";
  210. $this->gradido->mcontent .= $single_messages;
  211. $this->gradido->mcontent .= "</ul> \n";
  212. $this->gradido->mcontent .= "</div> \n";
  213. if ( ! $this->gradido->calc_mode && ! $this->gradido->first_entry && ! $this->gradido->display_single)
  214. $this->gradido->mcontent .= $this->pagination->create_links();
  215. }
  216. //-----------------------------------------------------------------------------------------
  217. /**
  218. * SMake the Subject Link
  219. *
  220. * @return string
  221. * @author Bernd
  222. **/
  223. public function make_subject_link($row)
  224. {
  225. // get the right language
  226. $subject = (is_lang2() && $row->subject2) ? $row->subject2 : $row->subject;
  227. if ($this->gradido->market_mode === 'self')
  228. $single = 'self-ad';
  229. elseif ($this->gradido->market_mode === 'place')
  230. $single = 'market-ad';
  231. elseif ($this->gradido->market_mode === 'network')
  232. $single = 'ad';
  233. elseif($this->gradido->dm_mode)
  234. $single = 'direct-message';
  235. else
  236. $single = 'm';
  237. if ($subject)
  238. {
  239. return $this->gradido->po_id.'/'.$single.'/'.$row->message_id;
  240. }
  241. else
  242. return FALSE;
  243. }
  244. //-----------------------------------------------------------------------------------------
  245. /**
  246. * Short Message for list view
  247. *
  248. * @return string
  249. * @author Bernd
  250. **/
  251. public function short_message($row, $i = 1)
  252. {
  253. // get the right language
  254. $subject = (is_lang2() && $row->subject2) ? $row->subject2 : $row->subject;
  255. $subject = strip_tags($subject);
  256. $message = (is_lang2() && $row->message2) ? $row->message2 : $row->message;
  257. $video = (is_lang2() && $row->video2 && $row->video_url2) ? $row->video2 : $row->video;
  258. $video_url = (is_lang2() && $row->video_url2) ? $row->video_url2 : $row->video_url;
  259. //////////////////////////////////////////////////////////////////////////
  260. // calculate the length of leading text regarding html-code in the anchor
  261. // $add_len is added to character_limiter later on
  262. //////////////////////////////////////////////////////////////////////////
  263. if ($subject)
  264. {
  265. $leading_text = '<h4 style="display: inline;">'.anchor($this->make_subject_link($row), $subject).'</h4>';
  266. // calculate the length of html-code in the leading_text
  267. $add_len = strlen($leading_text) - strlen($subject);
  268. }
  269. else
  270. $add_len = 0;
  271. ////////////////////////////////////////////////////////////
  272. // put together subject and message
  273. // and display them inline
  274. ////////////////////////////////////////////////////////////
  275. if($row->joy) // old joytopia messages
  276. {
  277. if ($subject AND $message)
  278. $msg = '<h4 style="display: inline;">'.anchor($this->make_subject_link($row), $subject).'</h4>'.": ".$message;
  279. elseif ($subject)
  280. $msg = '<h4 style="display: inline;">'.anchor($this->make_subject_link($row), $subject).'</h4>';
  281. else
  282. $msg = $message;
  283. $msg = str_replace ('<br / ><br / >', '//', $msg);
  284. $msg = str_replace ('<br />', ' ', $msg);
  285. $msg = str_replace ('<br / >', ' ', $msg); // bug in joytopia
  286. }
  287. else // gradido messages
  288. {
  289. $msg = '';
  290. if ( $this->gradido->page_mode === 'content') // my_topics
  291. {
  292. if ( $row->abbrev)
  293. {
  294. // only subject with link
  295. $msg .= '<h4 >'.anchor($this->make_subject_link($row), $subject).'</h4>';
  296. }
  297. else
  298. {
  299. // whole article without abbreviation
  300. $msg_subj = $i == 0 ? '<h2 >'.$subject.'</h2>' : '<h3 >'.$subject.'</h3>';
  301. $msg .= $message;
  302. $msg = strpos($message, '<') === FALSE ? nl2br($msg) : $msg; // nl2br if no html-code
  303. $msg = auto_link($msg, '', TRUE);
  304. if ($video && $video_url && strpos($message, '{video}') === FALSE)
  305. {
  306. $video_html = $this->show_video($video, $video_url);
  307. $msg = $video_html.br(2).$msg;
  308. }
  309. $msg = $msg_subj.$msg;
  310. }
  311. }
  312. else // all other messages are abbreviated
  313. {
  314. $msg .= '<h4 style="display: inline;">'.anchor($this->make_subject_link($row), $subject).'</h4>';
  315. $msg .= ': ';
  316. if($this->gradido->show_name($row))
  317. $msg .= strip_tags($row->salutation).' ';
  318. $msg .= strip_tags($message).' ';
  319. if($this->gradido->show_name($row))
  320. $msg .= strip_tags($row->ending);
  321. /////////////////////////////////////////////////////////////
  322. // limit the length of the short message
  323. // regarding html-code in the anchor (see above)
  324. // generate a [more]-link if needed
  325. /////////////////////////////////////////////////////////////
  326. $msg_fulltext = $msg;
  327. $msg = character_limiter($msg_fulltext, 110 + $add_len, ' ...');
  328. $more = (trim($msg_fulltext) == trim($msg)) ? FALSE : TRUE;
  329. $msg = auto_link($msg, '', TRUE);
  330. if ($more)
  331. $msg .= ' ['.anchor($this->make_subject_link($row), lang('gradido.select_more')).']';
  332. }
  333. // Show price
  334. if ($row->type == 3)
  335. $msg .= $this->compose_price($row);
  336. }
  337. if ($row->video && $row->video_url && strpos($message, '{video}') !== FALSE)
  338. {
  339. $video_html = $this->show_video($video, $video_url);
  340. $msg = str_replace('{video}', $video_html, $msg);
  341. }
  342. if (strpos($msg, '{') !== FALSE)
  343. $msg = $this->email_model->substitute_placeholders($msg, $this->gradido->usa, is_lang2());
  344. // output the message
  345. $this->gradido->data['message'] = $msg;
  346. }
  347. //-----------------------------------------------------------------------------------------
  348. /**
  349. * Full Message
  350. *
  351. * @return string
  352. * @author Bernd
  353. **/
  354. public function full_message($row)
  355. {
  356. // get the right language
  357. $subject = (is_lang2() && $row->subject2) ? $row->subject2 : $row->subject;
  358. $subject = strip_tags($subject);
  359. $message = (is_lang2() && $row->message2) ? $row->message2 : $row->message;
  360. $video = (is_lang2() && $row->video2 && $row->video_url2) ? $row->video2 : $row->video;
  361. $video_url = (is_lang2() && $row->video_url2) ? $row->video_url2 : $row->video_url;
  362. // single message
  363. if ($this->gradido->select_mode === 'message_id')
  364. {
  365. // put the subject into the page-title
  366. if ( $this->gradido->poo->id == $this->config->item('welcome_id'))
  367. $this->gradido->data['title'] = $subject.' | '.$this->config->item('site_name');
  368. else
  369. $this->gradido->data['title'] = $subject.' | '.$this->gradido->po_id;
  370. $this->gradido->mcontent .='<h1>'.$subject.'</h1>';
  371. }
  372. else // show whole content in the list view (my_topics)
  373. {
  374. $this->gradido->mcontent .='<h3>'.$subject.'</h3>';
  375. }
  376. if($row->joy) // old joytopia messages
  377. {
  378. $msg = $message;
  379. $msg = str_replace ('<br / >', '<br />', $msg); // bug in joytopia
  380. }
  381. else
  382. {
  383. $msg = '';
  384. if($this->gradido->show_name($row))
  385. $msg .= $row->salutation ? '<p>'.$row->salutation.'</p>' : '';
  386. $msg .= $message;
  387. if($this->gradido->show_name($row))
  388. $msg .= $row->ending ? '<p>'.$row->ending.'</p>' : '';
  389. }
  390. $msg = strpos($message, '<') === FALSE ? nl2br($msg) : $msg; // nl2br if no html-code
  391. $msg = auto_link($msg, '', TRUE);
  392. if ($row->video && $row->video_url && strpos($message, '{video}') === FALSE)
  393. {
  394. $video_html = $this->show_video($video, $video_url);
  395. $msg = br().$video_html.br(2).$msg;
  396. }
  397. // edit message: show subject in message
  398. if($this->gradido->edit_message_id)
  399. $msg ='<h3>'.$subject.'</h3>'.$msg ;
  400. // Show price
  401. if ($row->type == 3)
  402. $msg .= $this->compose_price($row);
  403. $gve_msg = '';
  404. if ($this->gradido->code && $this->gradido->code == $row->code && ! $this->gradido->is_po())
  405. {
  406. //////////////////////////////////////////////////////////
  407. // Gradido-via-Email (GvE) and Gradido-via_Social (GvS)
  408. // Code identification
  409. //////////////////////////////////////////////////////////
  410. $expire_sec = $this->config->item('email_expire_days') * 24*60*60;
  411. $valid = (bool) ($row->tstamp + $expire_sec - now()) > 0 ;
  412. if (($row->status == 10 OR $row->status == 11) && $valid)
  413. {
  414. $expire = timespan(now(), $row->tstamp + $expire_sec);
  415. $gve_expire = br().span(lang('gradido.booking_expire','', $expire), 'class="small"');
  416. $this->gradido->invited_by = $this->gradido_model->self_is($row->id, true) == 's' ? $row->s_grad_id : $row->r_grad_id ;
  417. $this->session->set_flashdata('invited_by', $this->gradido->invited_by);
  418. // remove multiple "log_in" etc. in uri-string
  419. if (last_segment(3) == 'log_in' OR last_segment(3) == 'log_out' OR last_segment(3) == 'register') $uri_string = redirect_sub(3, FALSE);
  420. elseif (last_segment(2) == 'log_in' OR last_segment(2) == 'log_out' OR last_segment(2) == 'register') $uri_string = redirect_sub(2, FALSE);
  421. elseif (last_segment(1) == 'log_in' OR last_segment(1) == 'log_out' OR last_segment(1) == 'register') $uri_string = redirect_sub(1, FALSE);
  422. else $uri_string = uri_string();
  423. $msg .= br();
  424. if ($this->gradido->logged_in())
  425. {
  426. $gve_msg .= '<strong>'.lang('gradido.write_salutation_text').' '.$this->gradido->uso->username.', </strong>';
  427. $gve_msg .= anchor($uri_string.'/log_out', '( '.lang('gradido.header_signout').' )').br();
  428. $accept_or_reject[] = anchor($uri_string.'/confirm_booking/30/'.$row->id,lang('gradido.mes_confirm'));
  429. $accept_or_reject[] = anchor($uri_string.'/confirm_booking/8/'.$row->id,lang('gradido.mes_reject'));
  430. $gve_msg .= lang('gradido.booking_accept_or_reject', '', $accept_or_reject);
  431. }
  432. else
  433. {
  434. $gve_msg .= '<strong>'.lang('gradido.booking_for_you').'</strong>'.br();
  435. $sign_or_register[] = '<strong>'.secure_anchor($uri_string.'/log_in', lang('gradido.header_signin')).'</strong>';
  436. $sign_or_register[] = '<strong>'.secure_anchor($uri_string.'/register', lang('gradido.join')).'</strong>';
  437. $gve_msg .= lang('gradido.booking_to_accept', '', $sign_or_register);
  438. }
  439. }
  440. elseif ($row->status == 10 OR $row->status == 11)
  441. {
  442. $gve_msg .= "<strong>".lang('gradido.booking_expired')."</strong>";
  443. }
  444. else
  445. {
  446. $gve_msg .= "<strong>".lang('gradido.booking_confirmed')."</strong>";
  447. }
  448. if ($gve_msg)
  449. {
  450. $this->gradido->mcontent = br().'<span style="font-size: 160%;">'.$gve_msg.'</span>'.br(2).'<hr />'.$this->gradido->mcontent;
  451. if (isset($gve_expire)) $msg .= $gve_expire;
  452. }
  453. }
  454. elseif (($row->r_server === 'social' OR $row->r_server === 'email') && $this->gradido->is_po())
  455. {
  456. //////////////////////////////////////////////////////////
  457. // Gradido-via-Social network (GvS)
  458. // provide text with link to copy into a private message
  459. //////////////////////////////////////////////////////////
  460. $request = ($row->mode==20 OR $row->mode==30) ? 'r' : '';
  461. $msg .= '<p>-';
  462. $msg .= br().glang('gradido.gve_insert2'.$request, is_lang2(), $this->gradido->uso->username);
  463. $msg .= ': '.$this->gradido->format('cur_no_nbs', $row->amount);
  464. $msg .= br().glang('gradido.gve_insert3'.$request, is_lang2()).' '.lang('gradido.gve_click_here');
  465. $msg .= ' '.lang('gradido.gve_copy_link').': ';
  466. $link = base_url().$this->gradido->uso->username.'/mc/'.$row->message_id.'/'.$row->code;
  467. $msg .= br().$link;
  468. $msg .= br().'-</p>';
  469. }
  470. if ($row->video && $row->video_url && strpos($message, '{video}') !== FALSE)
  471. {
  472. $video_html = $this->show_video($video, $video_url);
  473. $msg = str_replace('{video}', $video_html, $msg);
  474. }
  475. if (strpos($msg, '{') !== FALSE)
  476. $msg = $this->email_model->substitute_placeholders($msg, $this->gradido->usa, is_lang2());
  477. $this->gradido->data['message'] = $msg;
  478. }
  479. //-----------------------------------------------------------------------------------------
  480. /**
  481. * Newsletter
  482. *
  483. * @return string
  484. * @author Bernd
  485. **/
  486. public function get_newsletter($message_id, $user=FALSE)
  487. {
  488. $this->db->where('id', $message_id);
  489. $row = $this->db->get('messages')->row();
  490. $row_email = $this->email_model->get_job_from_message_id($message_id);
  491. $output ['subject'] = $this->get_subject($row, 1, false);
  492. $output ['subject2'] = $this->get_subject($row,2, false);
  493. $output ['message'] = $msg = $this->get_message($row,1, false);
  494. $output ['message2'] = $msg2 = $this->get_message($row,2, false);
  495. $msg = $this->email_model->substitute_placeholders($msg, $user, $lang2=FALSE);
  496. $msg2 = $this->email_model->substitute_placeholders($msg2, $user, $lang2=TRUE);
  497. $output['message_url']= base_url().$row->cruser_id.'/m/'.$row->message_id;
  498. $output['message_url2']= base_url().$this->config->item('lang_2_short').'/'.$row->cruser_id.'/m/'.$row->message_id;
  499. /////////////////////////////////////////////////////////
  500. // videos cannot be displayed in manny email clients
  501. // show either preview image or video url instead
  502. /////////////////////////////////////////////////////////
  503. if ($row->video && $row->video_url)
  504. {
  505. if (element('video_preview', $row_email->scheduler))
  506. {
  507. $link = element('preview_link', $row_email->scheduler) ? $output['message_url'] : $this->get_video_url($row, 1);
  508. $preview_anchor = anchor($link, img(element('video_preview', $row_email->scheduler)));
  509. if (strpos($msg, '{video}') === FALSE)
  510. $msg = br().$preview_anchor.br(2).$msg;
  511. else
  512. $msg = str_replace('{video}', $preview_anchor, $msg);
  513. }
  514. else
  515. {
  516. $video = $this->get_video($row, 1);
  517. $video_url = $this->get_video_url($row, 1);
  518. $video_html = $this->show_video($video, $video_url);
  519. if (strpos($msg, '{video}') === FALSE)
  520. $msg = br().anchor($row->video_url).br(2).$msg;
  521. else
  522. $msg = str_replace('{video}', anchor($video_url), $msg);
  523. }
  524. $msg = auto_link($msg , $type = 'both', $popup = FALSE, $safe = FALSE);
  525. // second language
  526. if ($msg2)
  527. {
  528. if (element('video_preview', $row_email->scheduler) OR element('video_preview', $row_email->scheduler))
  529. {
  530. $link2 = element('preview_link2', $row_email->scheduler) ? $output['message_url2'] : $this->get_video_url($row, 2);
  531. if (element('video_preview2', $row_email->scheduler))
  532. {
  533. $preview_anchor2 = anchor($link2, img(element('video_preview2', $row_email->scheduler)));
  534. }
  535. else
  536. {
  537. $preview_anchor2 = anchor($link2, img(element('video_preview', $row_email->scheduler)));
  538. }
  539. if (strpos($msg2, '{video}') === FALSE)
  540. $msg2 = br().$preview_anchor2.br(2).$msg2;
  541. else
  542. $msg2 = str_replace('{video}', $preview_anchor2, $msg2);
  543. }
  544. else
  545. {
  546. $video = $this->get_video($row, 2);
  547. $video_url = $this->get_video_url($row, 2);
  548. $video_html = $this->show_video($video, $video_url);
  549. if (strpos($msg, '{video}') === FALSE)
  550. $msg2 = br().anchor($row->video_url).br(2).$msg2;
  551. else
  552. $msg2 = str_replace('{video}', anchor($video_url), $msg2);
  553. }
  554. $msg2 = auto_link($msg2 , $type = 'both', $popup = FALSE, $safe = FALSE);
  555. }
  556. }
  557. // compose and format message1 html
  558. $output ['message1_html'] = '<p>';
  559. if ($msg2)
  560. $output ['message1_html'] .= '---> <a href="#english">English version below</a> <---'.br();
  561. if (element('online_link', $row_email->scheduler))
  562. $output ['message1_html'] .= anchor($output['message_url'], glang('gradido.email_view_online', false)).' , '.glang('gradido.email_cannot_display', false).'.';
  563. $output ['message1_html'] .= '</p>';
  564. $output ['message1_html'] .= $msg;
  565. $output ['message1_html'] = $this->format_html_email($output ['message1_html']);
  566. // compose and format message1 html
  567. $output ['message2_html'] = '';
  568. if ($msg2)
  569. {
  570. $output ['message2_html'] .= '<p>';
  571. $output ['message2_html'] .= '---> English version <---'.br();
  572. if (element('online_link', $row_email->scheduler))
  573. $output ['message2_html'] .= anchor($output['message_url2'], glang('gradido.email_view_online', true), 'name="english"').' , '.glang('gradido.email_cannot_display', true).'.';
  574. $output ['message2_html'] .= '</p>';
  575. $output ['message2_html'] .= $msg2;
  576. $output ['message2_html'] = $this->format_html_email($output ['message2_html']);
  577. }
  578. $output ['message_total'] = $output ['message1_html'].br(2).$output ['message2_html'];
  579. return $output;
  580. }
  581. //-----------------------------------------------------------------------------------------
  582. /**
  583. * format_html_email
  584. * i
  585. * @param string
  586. * @return string
  587. * @author Bernd
  588. *
  589. **/
  590. public function format_html_email($msg)
  591. {
  592. // style informations
  593. $format = 'style = "font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 12px; color:#444;" ';
  594. $format_h1 = 'style = "font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 16px; color:#444 !important; font-weight:bold;" ';
  595. $format_h2 = 'style = "font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 16px; color:#444 !important; font-weight:bold;" ';
  596. $format_h3 = 'style = "font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 14px; color:#444 !important; font-weight:bold;" ';
  597. $format_h4 = 'style = "font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 12px; color:#444 !important; font-weight:bold;" ';
  598. $msg = str_replace('<td>', "<td $format >", $msg);
  599. $msg = str_replace('<p>', "<p $format >", $msg);
  600. $msg = str_replace('<ol>', "<ol $format >", $msg);
  601. $msg = str_replace('<ul>', "<ul $format >", $msg);
  602. $msg = str_replace('<h1>', "<h1 $format_h1 >", $msg);
  603. $msg = str_replace('<h2>', "<h2 $format_h2 >", $msg);
  604. $msg = str_replace('<h3>', "<h3 $format_h3 >", $msg);
  605. $msg = str_replace('<h4>', "<h4 $format_h4 >", $msg);
  606. $msg = str_replace('<h5>', "<h5 $format_h4 >", $msg);
  607. $msg = str_replace('<h6>', "<h5 $format_h4 >", $msg);
  608. return $msg;
  609. }
  610. //-----------------------------------------------------------------------------------------
  611. /**
  612. * get_subject
  613. * in the right language
  614. * @param int 0, 1, 2
  615. * @param bool
  616. * @return string
  617. * @author Bernd
  618. *
  619. **/
  620. public function get_subject($row, $lang = 0, $take_first = TRUE)
  621. {
  622. if ( ! $lang) $lang = is_lang2() ? 2 : 1;
  623. if ($take_first && $lang == 2)
  624. $output = $row->subject2 ? $row->subject2 : $row->subject;
  625. elseif ($lang == 2)
  626. $output = $row->subject2 ? $row->subject2 : '';
  627. else
  628. $output = $row->subject;
  629. $output = strip_tags($output);
  630. return $output;
  631. }
  632. /**
  633. * get_message
  634. * in the right language
  635. * @param int 0, 1, 2
  636. * @param bool
  637. * @return string
  638. * @author Bernd
  639. *
  640. **/
  641. public function get_message($row, $lang = 0, $take_first = TRUE)
  642. {
  643. if ( ! $lang) $lang = is_lang2() ? 2 : 1;
  644. if ($take_first && $lang == 2)
  645. $output = $row->message2 ? $row->message2 : $row->message;
  646. elseif ($lang == 2)
  647. $output = $row->message2 ? $row->message2 : '';
  648. else
  649. $output = $row->message;
  650. return $output;
  651. }
  652. /**
  653. * get_video
  654. * in the right language
  655. * @param int 0, 1, 2
  656. * @return string
  657. * @author Bernd
  658. *
  659. **/
  660. public function get_video($row, $lang = 0)
  661. {
  662. if ( ! $lang) $lang = is_lang2() ? 2 : 1;
  663. $output = ($lang == 2 && $row->video2) ? $row->video2 : $row->video;
  664. return $output;
  665. }
  666. /**
  667. * get_video_url
  668. * in the right language
  669. * @param int 0, 1, 2
  670. * @return string
  671. * @author Bernd
  672. *
  673. **/
  674. public function get_video_url($row, $lang = 0)
  675. {
  676. if ( ! $lang) $lang = is_lang2() ? 2 : 1;
  677. $output = ($lang == 2 && $row->video_url2) ? $row->video_url2 : $row->video_url;
  678. return $output;
  679. }
  680. //-----------------------------------------------------------------------------------------
  681. /**
  682. * make_advertising_view
  683. * from Google or others, if allowed
  684. *
  685. * @return
  686. * @author Bernd
  687. *
  688. **/
  689. public function make_advertising_view($i = 0, $row, $bottom = FALSE)
  690. {
  691. $ad_position = explode(',', $this->config->item('ad_position'));
  692. if ($this->gradido->show_ads)
  693. {
  694. if ($bottom OR ($this->gradido->page_mode !== 'content' && $this->gradido->display === 'list' && in_array($i+1, $ad_position )))
  695. {
  696. $this->gradido->data['advertising'] = $this->advertising($this->ad_count++);
  697. return $this->load->view('messages/s_message_ad', $this->gradido->data, true)."\n";
  698. }
  699. }
  700. }
  701. /**
  702. * Advertising from Google or other
  703. *
  704. * @return string
  705. * @author Bernd
  706. **/
  707. public function advertising($count = 0)
  708. {
  709. if ( ! isset($this->banners ) )
  710. {
  711. $this->banners = $this->banner_model->show_banners();
  712. if ( ! isset($this->banners) OR ! is_array($this->banners))
  713. return;
  714. shuffle($this->banners);
  715. }
  716. if ( $count >= count($this->banners))
  717. $count = count($this->banners) - 1;
  718. if ( ! isset($this->banners[$count]))
  719. {
  720. return '';
  721. }
  722. else
  723. {
  724. $single = $this->banners[$count];
  725. $this->banner_model->track_views($single);
  726. $img = anchor('link/banner/'.$single['id'], img($single['banner_url']), 'target="_blank"');
  727. return $img;
  728. }
  729. }
  730. /**
  731. * Advertising from Google or other
  732. *
  733. * @return string
  734. * @author Bernd
  735. **/
  736. public function xxxadvertising($count = 0)
  737. {
  738. $advertising ='
  739. <script type="text/javascript"><!--
  740. google_ad_client = "pub-3290708995475366";
  741. /* gradido.de 468x60, Erstellt 27.04.10 */
  742. google_ad_slot = "5485092897";
  743. google_ad_width = 468;
  744. google_ad_height = 60;
  745. //-->
  746. </script>
  747. <script type="text/javascript"
  748. src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  749. </script>
  750. ';
  751. if($count)
  752. {
  753. $advertising ='
  754. <script type="text/javascript"><!--
  755. google_ad_client = "pub-3290708995475366";
  756. /* 468x60, Erstellt 01.05.10 */
  757. google_ad_slot = "7739819088";
  758. google_ad_width = 468;
  759. google_ad_height = 60;
  760. //-->
  761. </script>
  762. <script type="text/javascript"
  763. src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  764. </script>
  765. ';
  766. }
  767. return $advertising;
  768. }
  769. //-----------------------------------------------------------------------------------------
  770. /**
  771. * Message Headline
  772. *
  773. * @return string
  774. * @author Bernd Hueckstaeedt
  775. **/
  776. public function message_head($row)
  777. {
  778. $head = '';
  779. if ($this->gradido->display_single)
  780. {
  781. //other
  782. $head .= ($this->gradido->data['other']) ? $this->gradido->data['other'].br().' ' : '';
  783. if ($row->event_start)
  784. $head .= $this->compose_event_data($row);
  785. else
  786. $head .= ($this->gradido->data['datetime']) ? $this->gradido->data['datetime'].br().' ' : '';
  787. // amount and balance (only gradido-message )
  788. $head .= ($this->gradido->show_amount() && $this->gradido->data['amount_form']) ? $this->gradido->data['amount_form'].nbs().' ' : '';
  789. $head .= ($this->gradido->show_amount() && $this->gradido->data['balance_form']) ? $this->gradido->data['balance_form'].br().' ' : '';
  790. }
  791. else
  792. {
  793. //other
  794. $head .= ($this->gradido->data['other']) ? $this->gradido->data['other'].nbs().' ' : '';
  795. if ($row->event_start)
  796. $head .= $this->compose_event_data($row);
  797. else
  798. $head .= ($this->gradido->data['datetime']) ? $this->gradido->data['datetime'].nbs().' ' : '';
  799. }
  800. $this->gradido->data['message_head'] = $head;
  801. }
  802. //-----------------------------------------------------------------------------------------
  803. /**
  804. * Compose Event Data
  805. *
  806. * @return string
  807. * @author Bernd Hueckstaedt
  808. **/
  809. public function compose_event_data($row)
  810. {
  811. $output = br();
  812. if ($row->event_repeat && $row->event_repeat != 'FALSE')
  813. {
  814. $output .= lang('gradido.url.month_start').' '.$this->gradido->format('date',$row->event_start, false).nbs().' ';
  815. $output .= lang('gradido.url.month_end').' '.$this->gradido->format('date',$row->event_end, false).nbs().' ';
  816. $repeat = lang('gradido.repeat');
  817. $output .= isset($repeat[$row->event_repeat]) ? br().$repeat[$row->event_repeat].nbs().' ' : '' ;
  818. $output .= $this->gradido->format('time',$row->event_start, false).nbs().' ';
  819. $output .= lang('gradido.url.month_end').' '.$this->gradido->format('time',$row->event_end, false).nbs().' ';
  820. }
  821. else
  822. {
  823. if ($this->gradido->format('date',$row->event_start, false) === $this->gradido->format('date',$row->event_end, false))
  824. {
  825. $output .= $this->gradido->format('date',$row->event_start, false).nbs().' ';
  826. $output .= $this->gradido->format('time',$row->event_start, false).nbs().' ';
  827. $output .= lang('gradido.url.month_end').' '.$this->gradido->format('time',$row->event_end, false).nbs().' ';
  828. }
  829. else
  830. {
  831. $output .= ($row->event_start) ? $this->gradido->format('datetime',$row->event_start, false).nbs().' ' : '';
  832. $output .= ($row->event_end) ? lang('gradido.url.month_end').' '.$this->gradido->format('datetime',$row->event_end, false).nbs().' ' : '';
  833. }
  834. }
  835. return $output;
  836. }
  837. //-----------------------------------------------------------------------------------------
  838. /**
  839. * Compose Price
  840. *
  841. * @return string
  842. * @author Bernd Hueckstaedt
  843. **/
  844. public function compose_price($row)
  845. {
  846. $output = '';
  847. if ($row->commercial)
  848. {
  849. $output .= br();
  850. $output .= $row->brutto ? lang('gradido.market_gross').': '.$this->gradido->format('decimal', $row->brutto).' '.$this->config->item('national_currency').nbs().' ' : '';
  851. // Gradido discount
  852. if ($row->percent > 1)
  853. {
  854. $output .= lang('gradido.market_gradido').': '.$row->percent.nbs().'%'.nbs().' ';
  855. $output .= $row->brutto ? lang('gradido.market_net').': '.$this->gradido->format('decimal',$row->netto).' '.$this->config->item('national_currency').nbs().' ' : '';
  856. }
  857. elseif ($row->percent == 1)
  858. {
  859. $output .= lang('gradido.market_gradido').': '.lang('gradido.market_agreement').nbs().' ';
  860. }
  861. else
  862. {
  863. $output .= lang('gradido.market_gradido').': '.lang('gradido.market_no_details').nbs().' ';
  864. }
  865. }
  866. else
  867. {
  868. $output .= $row->brutto ? br().lang('gradido.market_thank_request').': '.$row->brutto.' '.$this->config->item('currency_short').nbs().' ' : '';
  869. }
  870. return $output;
  871. }
  872. //-----------------------------------------------------------------------------------------
  873. /**
  874. * Other with link
  875. *
  876. * @return string
  877. * @author Bernd
  878. **/
  879. public function other($row)
  880. {
  881. // Creation, Decay GvE, GvS do not link
  882. if(
  883. $this->gradido->data['other_id'] == $this->config->item('creation_id')
  884. OR $this->gradido->data['other_id'] == $this->config->item('decay_id')
  885. OR $this->gradido->data['other_server'] === 'email' && $this->gradido->is_po()
  886. OR $this->gradido->data['other_server'] === 'social' && $this->gradido->is_po()
  887. )
  888. {
  889. $other = $this->gradido->data['other_prefix'].$this->gradido->data['other_name'];
  890. }
  891. // Normal: other with link
  892. elseif($this->gradido->show_name($row))
  893. {
  894. $other_text = $this->gradido->data['other_server'] === $this->config->item('site_servername') ? '' : $this->gradido->data['other_server'].'/';
  895. $other_text .= $this->gradido->data['other_name'];
  896. $other = $this->gradido->data['other_prefix'].anchor($this->gradido->data['other_server_url'].current_lang_short(FALSE, TRUE).$this->gradido->data['other_id'],$other_text);
  897. }
  898. // Protected or no more member
  899. else
  900. {
  901. $other = $this->gradido->data['other_prefix'].lang('gradido.mes_protected');
  902. }
  903. $this->gradido->data['other'] = $other;
  904. }
  905. //-----------------------------------------------------------------------------------------
  906. /**
  907. * Other image with link
  908. *
  909. * @return string
  910. * @author Bernd
  911. **/
  912. public function other_image($row)
  913. {
  914. if(trim($row->image) && ! $this->gradido->display_single)
  915. {
  916. $img_url = str_replace('/img/' , '/img/thumbs/', $row->image);
  917. $img = '<img src = "'.$img_url.'" width = "50" height = "50" alt="Test_Image" />';
  918. }
  919. elseif($this->gradido->data['other_id'] == $this->config->item('creation_id'))
  920. {
  921. // Creation image does not link
  922. $img = '<img src = "'.$this->gradido->data['other_server_url'].'/uploads/users/'.
  923. $this->gradido->data['other_id'].'_userimg_'.$this->config->item('userimg_msg').'.jpg" alt="creation" />';
  924. }
  925. elseif($this->gradido->data['other_id'] == $this->config->item('decay_id'))
  926. {
  927. // Decay image does not link
  928. $img = '<img src = "'.$this->gradido->data['other_server_url'].'/uploads/users/'.
  929. $this->gradido->data['other_id'].'_userimg_'.$this->config->item('userimg_msg').'.jpg" alt="decay" />';
  930. }
  931. elseif(!$this->gradido->show_name($row) OR $row->r_server === 'email'OR $row->s_server === 'email' OR $row->r_server === 'social')
  932. {
  933. // protected or gradido via email
  934. $img = '<img src = "'.$this->gradido->data['other_server_url'].'/uploads/users/'.
  935. 'user_protected'.'_userimg_'.$this->config->item('userimg_msg').'.jpg" alt="protected" />';
  936. }
  937. else
  938. {
  939. // Normal: other image with link
  940. $img = '<img src = "'.$this->gradido->data['other_server_url'].'/uploads/users/'.
  941. $this->gradido->data['other_id'].'_userimg_'.$this->config->item('userimg_msg').'.jpg" alt="'.$this->gradido->data['other_id'].'" />';
  942. $img = anchor($this->gradido->data['other_server_url'].current_lang_short(FALSE, TRUE).$this->gradido->data['other_id'], $img);
  943. }
  944. $this->gradido->data['other_image'] = $img;
  945. }
  946. //-----------------------------------------------------------------------------------------
  947. /**
  948. * Edit Links
  949. *
  950. * @return string
  951. * @author Bernd
  952. **/
  953. public function edit_links($row)
  954. {
  955. if ($this->gradido->self_is($row) && $this->gradido->market_mode != 'place' && $this->gradido->market_mode != 'network' )
  956. {
  957. // market adds only can be changed on the owner's site
  958. $link = '';
  959. $m = 'style = "text-decoration: underline;"';
  960. $sep = '|'.nbs(2);
  961. $i = 0;
  962. // publish links
  963. if ($this->gradido->select_mode !== 'dm' && $row->type != 4)
  964. {
  965. $link .= ($i)? $sep : '';
  966. $i++;
  967. $publish = ($this->gradido->self_is($row) == 's') ? $row->s_publish : $row->r_publish;
  968. $a30 = (30 == $publish) ? $m : '';
  969. $a20 = (20 == $publish) ? $m : '';
  970. $a10 = (10 >= $publish) ? $m : '';
  971. $a0 = (!$row->s_publish) ? $m : '';
  972. $link .= anchor($this->gradido->po_id.'/set_publish/30/'.$row->id, span(lang('gradido.publish_internet'),$a30)).nbs(2);
  973. $link .= anchor($this->gradido->po_id.'/set_publish/20/'.$row->id, span(lang('gradido.publish_gradido'),$a20)).nbs(2);
  974. $link .= anchor($this->gradido->po_id.'/set_publish/10/'.$row->id, span(lang('gradido.publish_private'),$a10)).nbs(2);
  975. }
  976. // status links confirm/reject
  977. //if (6 <= $row->status && 15 >= $row->status && $this->gradido->self_is($row) === 'r') // only for debugging
  978. if (6 <= $row->status && 15 >= $row->status && $row->status != 8 && $row->status != 9 && $this->gradido->self_is($row) === 'r')
  979. {
  980. $link .= ($i)? $sep : '';
  981. $i++;
  982. $link .= anchor($this->gradido->po_id.'/set_status/30/'.$row->id, span(lang('gradido.mes_confirm'),'')).nbs(2);
  983. $link .= anchor($this->gradido->po_id.'/set_status/8/'.$row->id, span(lang('gradido.mes_reject'),'')).nbs(2);
  984. }
  985. // status links remind/cancel
  986. //if (6 <= $row->status && 15 >= $row->status && $this->gradido->self_is($row) === 's') // only for debugging
  987. if (6 <= $row->status && 15 >= $row->status && $row->status != 8 && $row->status != 9 && $this->gradido->self_is($row) === 's')
  988. {
  989. $link .= ($i)? $sep : '';
  990. $i++;
  991. $link .= anchor($this->gradido->po_id.'/set_status/11/'.$row->id, span(lang('gradido.mes_remind'),'')).nbs(2);
  992. $link .= anchor($this->gradido->po_id.'/set_status/9/'.$row->id, span(lang('gradido.mes_cancel'),'')).nbs(2);
  993. }
  994. if ( ! TRUE) //show open, close links
  995. {
  996. $link .= ($i)? $sep : '';
  997. $i++;
  998. $closed_flag = ($this->gradido->uso->id == $row->s_id) ? $row->s_closed : $row->r_closed;
  999. $open = (0 == $closed_flag) ? $m : '';
  1000. $closed = (1 == $closed_flag) ? $m : '';
  1001. $link .= anchor($this->gradido->po_id.'/set_open/'.$row->id, span(lang('gradido.publish_open'),$open)).nbs(2);
  1002. $link .= anchor($this->gradido->po_id.'/set_closed/'.$row->id, span(lang('gradido.publish_closed'),$closed)).nbs(2);
  1003. }
  1004. if ($this->gradido->allow_edit($row)) // edit
  1005. {
  1006. //$link .= ($i)? $sep : '';
  1007. $i++;
  1008. $icon = '<img src = "'.base_url().'design/icons/pencil_16.png" alt="'.lang('gradido.write_edit_message').'" />';
  1009. //$link .= anchor($seg1.'/edit_message/'.$row->id, $icon, 'title = "'.lang('gradido.write_edit_message').'"').nbs(2);
  1010. $link .= anchor($this->gradido->po_id.'/m/'.$row->message_id.'/edit', $icon, 'title = "'.lang('gradido.write_edit_message').'"').nbs(2);
  1011. }
  1012. return div($link, 'class = "edit_links" ');
  1013. }
  1014. }
  1015. //-----------------------------------------------------------------------------------------
  1016. /**
  1017. * message_event_time
  1018. *
  1019. * @return string ???????????? nothing is returned! Work in progress???
  1020. * @author Bernd
  1021. **/
  1022. public function message_event_time($row)
  1023. {
  1024. $output = '';
  1025. if ($row->event_start)
  1026. $output .= $this->gradido->display === 'map' ? $this->gradido->format('datetime_no_nbs',$row->event_start, false) : $this->gradido->format('datetime',$row->event_start, false);
  1027. if ($row->event_end)
  1028. {
  1029. $output .= ' '.strtolower(lang('gradido.events_end')).' ';
  1030. $output .= $this->gradido->display === 'map' ? $this->gradido->format('datetime_no_nbs',$row->event_end, false) : $this->gradido->format('datetime',$row->event_end, false);
  1031. }
  1032. }
  1033. //-----------------------------------------------------------------------------------------
  1034. /**
  1035. * select_mutual_links (all, mutual, other)
  1036. *
  1037. * @return string
  1038. * @author Bernd
  1039. **/
  1040. public function select_mutual_links()
  1041. {
  1042. if($this->gradido->logged_in() && !$t

Large files files are truncated, but you can click here to view the full file