/application/models/display_model.php
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
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- /**
- * Name: Display Model
- *
- * Author: Bernd Hueckstaedt
- * akademie@joytopia.net
- * @BerndHueckstaedt
- *
- *
- *
- * Created: 10.08.2010
- *
- * Description: Display Gradido Messages
- *
- *
- * Requirements: PHP5 or above
- *
- */
- // CI 2.0 Compatibility
- if(!class_exists('CI_Model')) { class CI_Model extends Model {} }
- class Display_model extends CI_Model
- {
- public $display_single;
- public $offset;
- public $ad_count = 0;
- public function __construct()
- {
- parent::__construct();
- $this->load->library('gradido');
- $this->load->library('gradido_market');
- $this->load->library('oembed');
-
- $this->load->model('gradido_model');
- $this->load->config('ion_auth');
- $this->load->model('user_model');
- $this->load->model('banner_model');
-
- $this->init_vars();
- }
-
- private function init_vars()
- {
- }
- //-----------------------------------------------------------------------------------------
- /**
- * make_message_view
- *
- * @input int $i
- * @input int $row
- *
- * @return string the output of the single message view
- *
- * @author Bernd
- *
- **/
- public function make_message_view($i, $row)
- {
-
- if($this->gradido->display)
- {
- //////////////////////////////////////////
- // other's userimage, link it etc.
- //////////////////////////////////////////
-
- $this->other($row);
- $this->other_image($row);
- $this->message_head($row);
-
- //////////////////////////////////////////
- // Message
- //////////////////////////////////////////
-
- if ($this->gradido->display_single)
- {
- $this->full_message($row);
-
- if ($row->type == 2 && $row->mode <= 2)
- $view = 's_my_topics_full';
- else
- $view = $this->config->item('currency2') ? 's_message_full_c2' : 's_message_full';
- }
- //elseif (0 == $i && 0 == $this->gradido->offset) // first message on first page
- elseif (0 == $i) // first message on each page
- {
- // first message
- $this->short_message($row, $i);
-
- if ($row->type == 2 && $row->mode <= 2 && $row->abbrev == 1)
- $view ='s_my_topics_first';
- elseif ($row->type == 2 && $row->mode <= 2)
- $view ='s_my_topics_full';
- else
- $view = $this->config->item('currency2') ? 's_message_first_c2' : 's_message_first';
- }
- else
- {
- $this->short_message($row, $i);
-
- if ($row->type == 2 && $row->mode <= 2 && $row->abbrev == 1)
- $view ='s_my_topics_single';
- elseif ($row->type == 2 && $row->mode <= 2)
- $view ='s_my_topics_full';
- else
- $view = $this->config->item('currency2') ? 's_message_single_c2' : 's_message_single';
- }
- }
-
- $this->gradido->data['message'] .= $this->edit_links($row);
-
- // show the back link (backlink, back_link)
- if ($this->gradido->display_single && $this->session->userdata('list_uri') && ! $this->gradido->code)
- {
- $this->gradido->data['message'] .= br(2).anchor($this->session->userdata('list_uri'), '>>> '.lang('gradido.nav_back').' >>>').br(2);
- }
-
- return $this->load->view('messages/'.$view, $this->gradido->data, true)."\n";
- }
- //-----------------------------------------------------------------------------------------
- /**
- * make_message_list
- * and calculate messages
- * @return void
- * @author Bernd
- **/
- public function make_message_list($add_value = FALSE)
- {
-
- if ($this->gradido->calc_mode) {
- $query = $this->gradido->select_messages('max', $add_value);
- if ('special' != $this->gradido->page_mode)
- $this->gradido->display = FALSE;
- }
- elseif ($this->gradido->first_entry OR $this->gradido->display_single)
- $query = $this->gradido->select_messages('one', $add_value);
- else
- $query = $this->gradido->select_messages('page', $add_value);
-
- $single_messages = '';
- $add_markers = array();
-
- if ($query->num_rows() > 0)
- {
-
- $i = 0;
- foreach ($query->result() as $row)
- {
- $this->row_model->process_row($row, $i);
- $this->message_event_time($row);
-
- if ($this->gradido->display === 'list')
- {
- $single_messages .= $this->make_message_view($i, $row);
- if ($this->gradido->select_mode === 'message_id')
- {
- // $single_messages .= br(2).'<hr class = "list_clear">'; // does not validate
- }
-
- $single_messages .= $this->make_advertising_view($i, $row);
- }
- elseif ($this->gradido->display === 'map')
- {
- $marker = array(
- 'header' => $row->s_name,
- 'link' => server_base_url($row->s_server).current_lang_short(FALSE, TRUE).$this->make_subject_link($row),
-
- 'subject' => $row->subject,
- 'time' => 6 === element('ad_class', $this->gradido_market->ad_param) ?
- $this->gradido->format('datetime_no_nbs',$row->event_start).', '.$row->event_repeat : '',
-
- 'message' => $row->message,
-
- 'icon' => 'generic',
- 'text' => $i+1,
-
- 'address_circa' => $row->s_address_circa,
- 'address_street'=> $row->s_address_street,
- 'latitude' => $row->s_latitude,
- 'longitude' => $row->s_longitude,
- 's_show_position'=> $row->s_show_position,
- 'message_id' =>$row->message_id,
- );
-
- $add_markers[] = $marker;
- }
-
- $i++;
-
- // Maximal number of entries which are calculated at one time
- $limit = $this->config->item('max_calculate_entries');
- if ($i > $limit) break;
- }
- }
-
- // display or hide write form
- if($this->gradido->is_write_act() && $this->gradido->edit_message_id)
- {
- if ( ! $this->gradido->edit_message_id)
- $this->gradido->data['top_elements'] = $this->gradido->set_top_elements();
-
- if ( isset($row) && $row)
- {
- $this->gradido->mcontent = $this->write_model->write('', $row);
- }
- else
- {
- $this->session->unset_userdata('Write_Message');
- redirect($this->gradido->poo->username);
- }
-
- }
-
-
- ///////////////////////////////////////////////////////////////
- // Display
- // as List or as Map
- ///////////////////////////////////////////////////////////////
-
- if ($this->gradido->display === 'list')
- {
- if ($this->gradido->page_mode === 'content')
- $single_messages .= br(2).'<hr class = "list_clear">'.$this->make_advertising_view('', '', TRUE);
- $this->display_message_page($single_messages);
- }
- elseif ($this->gradido->display === 'map')
- return $add_markers;
-
- }
-
- //-----------------------------------------------------------------------------------------
- /**
- * display_message_page
- *
- *
- * @return
- * @author Bernd
- *
- **/
- public function display_message_page($single_messages)
- {
- if ( ! $this->gradido->calc_mode && ! $this->gradido->first_entry && ! $this->gradido->display_single)
- $this->gradido->mcontent .= $this->pagination->create_links();
-
- $this->gradido->mcontent .= "\n <div class = \"messages\"> \n ";
- $this->gradido->mcontent .= "<br /><ul> \n";
-
- $this->gradido->mcontent .= $single_messages;
-
- $this->gradido->mcontent .= "</ul> \n";
- $this->gradido->mcontent .= "</div> \n";
-
- if ( ! $this->gradido->calc_mode && ! $this->gradido->first_entry && ! $this->gradido->display_single)
- $this->gradido->mcontent .= $this->pagination->create_links();
- }
-
- //-----------------------------------------------------------------------------------------
- /**
- * SMake the Subject Link
- *
- * @return string
- * @author Bernd
- **/
- public function make_subject_link($row)
- {
- // get the right language
- $subject = (is_lang2() && $row->subject2) ? $row->subject2 : $row->subject;
-
- if ($this->gradido->market_mode === 'self')
- $single = 'self-ad';
- elseif ($this->gradido->market_mode === 'place')
- $single = 'market-ad';
- elseif ($this->gradido->market_mode === 'network')
- $single = 'ad';
- elseif($this->gradido->dm_mode)
- $single = 'direct-message';
- else
- $single = 'm';
-
- if ($subject)
- {
- return $this->gradido->po_id.'/'.$single.'/'.$row->message_id;
- }
- else
- return FALSE;
-
- }
-
- //-----------------------------------------------------------------------------------------
- /**
- * Short Message for list view
- *
- * @return string
- * @author Bernd
- **/
- public function short_message($row, $i = 1)
- {
- // get the right language
- $subject = (is_lang2() && $row->subject2) ? $row->subject2 : $row->subject;
- $subject = strip_tags($subject);
- $message = (is_lang2() && $row->message2) ? $row->message2 : $row->message;
- $video = (is_lang2() && $row->video2 && $row->video_url2) ? $row->video2 : $row->video;
- $video_url = (is_lang2() && $row->video_url2) ? $row->video_url2 : $row->video_url;
-
- //////////////////////////////////////////////////////////////////////////
- // calculate the length of leading text regarding html-code in the anchor
- // $add_len is added to character_limiter later on
- //////////////////////////////////////////////////////////////////////////
-
-
- if ($subject)
- {
- $leading_text = '<h4 style="display: inline;">'.anchor($this->make_subject_link($row), $subject).'</h4>';
- // calculate the length of html-code in the leading_text
- $add_len = strlen($leading_text) - strlen($subject);
- }
- else
- $add_len = 0;
-
- ////////////////////////////////////////////////////////////
- // put together subject and message
- // and display them inline
- ////////////////////////////////////////////////////////////
-
- if($row->joy) // old joytopia messages
- {
- if ($subject AND $message)
- $msg = '<h4 style="display: inline;">'.anchor($this->make_subject_link($row), $subject).'</h4>'.": ".$message;
- elseif ($subject)
- $msg = '<h4 style="display: inline;">'.anchor($this->make_subject_link($row), $subject).'</h4>';
- else
- $msg = $message;
-
- $msg = str_replace ('<br / ><br / >', '//', $msg);
- $msg = str_replace ('<br />', ' ', $msg);
- $msg = str_replace ('<br / >', ' ', $msg); // bug in joytopia
- }
- else // gradido messages
- {
- $msg = '';
-
- if ( $this->gradido->page_mode === 'content') // my_topics
- {
- if ( $row->abbrev)
- {
- // only subject with link
- $msg .= '<h4 >'.anchor($this->make_subject_link($row), $subject).'</h4>';
- }
- else
- {
- // whole article without abbreviation
- $msg_subj = $i == 0 ? '<h2 >'.$subject.'</h2>' : '<h3 >'.$subject.'</h3>';
- $msg .= $message;
- $msg = strpos($message, '<') === FALSE ? nl2br($msg) : $msg; // nl2br if no html-code
- $msg = auto_link($msg, '', TRUE);
-
- if ($video && $video_url && strpos($message, '{video}') === FALSE)
- {
- $video_html = $this->show_video($video, $video_url);
- $msg = $video_html.br(2).$msg;
- }
-
- $msg = $msg_subj.$msg;
- }
-
- }
- else // all other messages are abbreviated
- {
- $msg .= '<h4 style="display: inline;">'.anchor($this->make_subject_link($row), $subject).'</h4>';
- $msg .= ': ';
- if($this->gradido->show_name($row))
- $msg .= strip_tags($row->salutation).' ';
- $msg .= strip_tags($message).' ';
- if($this->gradido->show_name($row))
- $msg .= strip_tags($row->ending);
-
- /////////////////////////////////////////////////////////////
- // limit the length of the short message
- // regarding html-code in the anchor (see above)
- // generate a [more]-link if needed
- /////////////////////////////////////////////////////////////
- $msg_fulltext = $msg;
- $msg = character_limiter($msg_fulltext, 110 + $add_len, ' ...');
- $more = (trim($msg_fulltext) == trim($msg)) ? FALSE : TRUE;
-
- $msg = auto_link($msg, '', TRUE);
-
- if ($more)
- $msg .= ' ['.anchor($this->make_subject_link($row), lang('gradido.select_more')).']';
- }
-
- // Show price
- if ($row->type == 3)
- $msg .= $this->compose_price($row);
-
- }
-
- if ($row->video && $row->video_url && strpos($message, '{video}') !== FALSE)
- {
- $video_html = $this->show_video($video, $video_url);
- $msg = str_replace('{video}', $video_html, $msg);
- }
-
- if (strpos($msg, '{') !== FALSE)
- $msg = $this->email_model->substitute_placeholders($msg, $this->gradido->usa, is_lang2());
-
- // output the message
- $this->gradido->data['message'] = $msg;
- }
- //-----------------------------------------------------------------------------------------
- /**
- * Full Message
- *
- * @return string
- * @author Bernd
- **/
- public function full_message($row)
-
- {
- // get the right language
- $subject = (is_lang2() && $row->subject2) ? $row->subject2 : $row->subject;
- $subject = strip_tags($subject);
- $message = (is_lang2() && $row->message2) ? $row->message2 : $row->message;
- $video = (is_lang2() && $row->video2 && $row->video_url2) ? $row->video2 : $row->video;
- $video_url = (is_lang2() && $row->video_url2) ? $row->video_url2 : $row->video_url;
-
- // single message
- if ($this->gradido->select_mode === 'message_id')
- {
- // put the subject into the page-title
- if ( $this->gradido->poo->id == $this->config->item('welcome_id'))
- $this->gradido->data['title'] = $subject.' | '.$this->config->item('site_name');
- else
- $this->gradido->data['title'] = $subject.' | '.$this->gradido->po_id;
-
- $this->gradido->mcontent .='<h1>'.$subject.'</h1>';
- }
- else // show whole content in the list view (my_topics)
- {
- $this->gradido->mcontent .='<h3>'.$subject.'</h3>';
- }
-
- if($row->joy) // old joytopia messages
- {
- $msg = $message;
- $msg = str_replace ('<br / >', '<br />', $msg); // bug in joytopia
- }
- else
- {
- $msg = '';
-
- if($this->gradido->show_name($row))
- $msg .= $row->salutation ? '<p>'.$row->salutation.'</p>' : '';
- $msg .= $message;
- if($this->gradido->show_name($row))
- $msg .= $row->ending ? '<p>'.$row->ending.'</p>' : '';
- }
-
- $msg = strpos($message, '<') === FALSE ? nl2br($msg) : $msg; // nl2br if no html-code
- $msg = auto_link($msg, '', TRUE);
-
- if ($row->video && $row->video_url && strpos($message, '{video}') === FALSE)
- {
- $video_html = $this->show_video($video, $video_url);
- $msg = br().$video_html.br(2).$msg;
- }
-
- // edit message: show subject in message
- if($this->gradido->edit_message_id)
- $msg ='<h3>'.$subject.'</h3>'.$msg ;
-
- // Show price
- if ($row->type == 3)
- $msg .= $this->compose_price($row);
-
- $gve_msg = '';
-
- if ($this->gradido->code && $this->gradido->code == $row->code && ! $this->gradido->is_po())
- {
- //////////////////////////////////////////////////////////
- // Gradido-via-Email (GvE) and Gradido-via_Social (GvS)
- // Code identification
- //////////////////////////////////////////////////////////
-
- $expire_sec = $this->config->item('email_expire_days') * 24*60*60;
- $valid = (bool) ($row->tstamp + $expire_sec - now()) > 0 ;
-
-
- if (($row->status == 10 OR $row->status == 11) && $valid)
- {
-
- $expire = timespan(now(), $row->tstamp + $expire_sec);
- $gve_expire = br().span(lang('gradido.booking_expire','', $expire), 'class="small"');
- $this->gradido->invited_by = $this->gradido_model->self_is($row->id, true) == 's' ? $row->s_grad_id : $row->r_grad_id ;
- $this->session->set_flashdata('invited_by', $this->gradido->invited_by);
-
- // remove multiple "log_in" etc. in uri-string
- if (last_segment(3) == 'log_in' OR last_segment(3) == 'log_out' OR last_segment(3) == 'register') $uri_string = redirect_sub(3, FALSE);
- elseif (last_segment(2) == 'log_in' OR last_segment(2) == 'log_out' OR last_segment(2) == 'register') $uri_string = redirect_sub(2, FALSE);
- elseif (last_segment(1) == 'log_in' OR last_segment(1) == 'log_out' OR last_segment(1) == 'register') $uri_string = redirect_sub(1, FALSE);
- else $uri_string = uri_string();
-
- $msg .= br();
- if ($this->gradido->logged_in())
- {
- $gve_msg .= '<strong>'.lang('gradido.write_salutation_text').' '.$this->gradido->uso->username.', </strong>';
- $gve_msg .= anchor($uri_string.'/log_out', '( '.lang('gradido.header_signout').' )').br();
- $accept_or_reject[] = anchor($uri_string.'/confirm_booking/30/'.$row->id,lang('gradido.mes_confirm'));
- $accept_or_reject[] = anchor($uri_string.'/confirm_booking/8/'.$row->id,lang('gradido.mes_reject'));
- $gve_msg .= lang('gradido.booking_accept_or_reject', '', $accept_or_reject);
- }
- else
- {
- $gve_msg .= '<strong>'.lang('gradido.booking_for_you').'</strong>'.br();
- $sign_or_register[] = '<strong>'.secure_anchor($uri_string.'/log_in', lang('gradido.header_signin')).'</strong>';
- $sign_or_register[] = '<strong>'.secure_anchor($uri_string.'/register', lang('gradido.join')).'</strong>';
- $gve_msg .= lang('gradido.booking_to_accept', '', $sign_or_register);
-
- }
- }
- elseif ($row->status == 10 OR $row->status == 11)
- {
- $gve_msg .= "<strong>".lang('gradido.booking_expired')."</strong>";
- }
- else
- {
- $gve_msg .= "<strong>".lang('gradido.booking_confirmed')."</strong>";
- }
-
- if ($gve_msg)
- {
-
- $this->gradido->mcontent = br().'<span style="font-size: 160%;">'.$gve_msg.'</span>'.br(2).'<hr />'.$this->gradido->mcontent;
- if (isset($gve_expire)) $msg .= $gve_expire;
- }
-
- }
- elseif (($row->r_server === 'social' OR $row->r_server === 'email') && $this->gradido->is_po())
- {
- //////////////////////////////////////////////////////////
- // Gradido-via-Social network (GvS)
- // provide text with link to copy into a private message
- //////////////////////////////////////////////////////////
-
- $request = ($row->mode==20 OR $row->mode==30) ? 'r' : '';
- $msg .= '<p>-';
- $msg .= br().glang('gradido.gve_insert2'.$request, is_lang2(), $this->gradido->uso->username);
- $msg .= ': '.$this->gradido->format('cur_no_nbs', $row->amount);
- $msg .= br().glang('gradido.gve_insert3'.$request, is_lang2()).' '.lang('gradido.gve_click_here');
- $msg .= ' '.lang('gradido.gve_copy_link').': ';
-
- $link = base_url().$this->gradido->uso->username.'/mc/'.$row->message_id.'/'.$row->code;
- $msg .= br().$link;
- $msg .= br().'-</p>';
-
- }
- if ($row->video && $row->video_url && strpos($message, '{video}') !== FALSE)
- {
- $video_html = $this->show_video($video, $video_url);
- $msg = str_replace('{video}', $video_html, $msg);
- }
-
- if (strpos($msg, '{') !== FALSE)
- $msg = $this->email_model->substitute_placeholders($msg, $this->gradido->usa, is_lang2());
-
- $this->gradido->data['message'] = $msg;
-
-
- }
- //-----------------------------------------------------------------------------------------
- /**
- * Newsletter
- *
- * @return string
- * @author Bernd
- **/
- public function get_newsletter($message_id, $user=FALSE)
- {
- $this->db->where('id', $message_id);
- $row = $this->db->get('messages')->row();
-
- $row_email = $this->email_model->get_job_from_message_id($message_id);
-
- $output ['subject'] = $this->get_subject($row, 1, false);
- $output ['subject2'] = $this->get_subject($row,2, false);
-
- $output ['message'] = $msg = $this->get_message($row,1, false);
- $output ['message2'] = $msg2 = $this->get_message($row,2, false);
-
- $msg = $this->email_model->substitute_placeholders($msg, $user, $lang2=FALSE);
- $msg2 = $this->email_model->substitute_placeholders($msg2, $user, $lang2=TRUE);
-
- $output['message_url']= base_url().$row->cruser_id.'/m/'.$row->message_id;
- $output['message_url2']= base_url().$this->config->item('lang_2_short').'/'.$row->cruser_id.'/m/'.$row->message_id;
-
-
- /////////////////////////////////////////////////////////
- // videos cannot be displayed in manny email clients
- // show either preview image or video url instead
- /////////////////////////////////////////////////////////
-
- if ($row->video && $row->video_url)
- {
-
- if (element('video_preview', $row_email->scheduler))
- {
- $link = element('preview_link', $row_email->scheduler) ? $output['message_url'] : $this->get_video_url($row, 1);
- $preview_anchor = anchor($link, img(element('video_preview', $row_email->scheduler)));
-
- if (strpos($msg, '{video}') === FALSE)
- $msg = br().$preview_anchor.br(2).$msg;
- else
- $msg = str_replace('{video}', $preview_anchor, $msg);
- }
- else
- {
-
- $video = $this->get_video($row, 1);
- $video_url = $this->get_video_url($row, 1);
-
- $video_html = $this->show_video($video, $video_url);
- if (strpos($msg, '{video}') === FALSE)
- $msg = br().anchor($row->video_url).br(2).$msg;
- else
- $msg = str_replace('{video}', anchor($video_url), $msg);
- }
-
- $msg = auto_link($msg , $type = 'both', $popup = FALSE, $safe = FALSE);
-
-
- // second language
-
- if ($msg2)
- {
-
-
-
- if (element('video_preview', $row_email->scheduler) OR element('video_preview', $row_email->scheduler))
- {
- $link2 = element('preview_link2', $row_email->scheduler) ? $output['message_url2'] : $this->get_video_url($row, 2);
- if (element('video_preview2', $row_email->scheduler))
- {
- $preview_anchor2 = anchor($link2, img(element('video_preview2', $row_email->scheduler)));
- }
- else
- {
- $preview_anchor2 = anchor($link2, img(element('video_preview', $row_email->scheduler)));
- }
-
- if (strpos($msg2, '{video}') === FALSE)
- $msg2 = br().$preview_anchor2.br(2).$msg2;
- else
- $msg2 = str_replace('{video}', $preview_anchor2, $msg2);
- }
- else
- {
-
- $video = $this->get_video($row, 2);
- $video_url = $this->get_video_url($row, 2);
-
- $video_html = $this->show_video($video, $video_url);
- if (strpos($msg, '{video}') === FALSE)
- $msg2 = br().anchor($row->video_url).br(2).$msg2;
- else
- $msg2 = str_replace('{video}', anchor($video_url), $msg2);
- }
- $msg2 = auto_link($msg2 , $type = 'both', $popup = FALSE, $safe = FALSE);
-
- }
-
-
- }
-
- // compose and format message1 html
- $output ['message1_html'] = '<p>';
- if ($msg2)
- $output ['message1_html'] .= '---> <a href="#english">English version below</a> <---'.br();
-
- if (element('online_link', $row_email->scheduler))
- $output ['message1_html'] .= anchor($output['message_url'], glang('gradido.email_view_online', false)).' , '.glang('gradido.email_cannot_display', false).'.';
-
- $output ['message1_html'] .= '</p>';
- $output ['message1_html'] .= $msg;
- $output ['message1_html'] = $this->format_html_email($output ['message1_html']);
-
- // compose and format message1 html
- $output ['message2_html'] = '';
- if ($msg2)
- {
- $output ['message2_html'] .= '<p>';
- $output ['message2_html'] .= '---> English version <---'.br();
-
- if (element('online_link', $row_email->scheduler))
- $output ['message2_html'] .= anchor($output['message_url2'], glang('gradido.email_view_online', true), 'name="english"').' , '.glang('gradido.email_cannot_display', true).'.';
-
- $output ['message2_html'] .= '</p>';
- $output ['message2_html'] .= $msg2;
- $output ['message2_html'] = $this->format_html_email($output ['message2_html']);
- }
- $output ['message_total'] = $output ['message1_html'].br(2).$output ['message2_html'];
- return $output;
-
- }
-
- //-----------------------------------------------------------------------------------------
- /**
- * format_html_email
- * i
- * @param string
- * @return string
- * @author Bernd
- *
- **/
- public function format_html_email($msg)
- {
- // style informations
- $format = 'style = "font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 12px; color:#444;" ';
- $format_h1 = 'style = "font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 16px; color:#444 !important; font-weight:bold;" ';
- $format_h2 = 'style = "font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 16px; color:#444 !important; font-weight:bold;" ';
- $format_h3 = 'style = "font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 14px; color:#444 !important; font-weight:bold;" ';
- $format_h4 = 'style = "font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 12px; color:#444 !important; font-weight:bold;" ';
-
- $msg = str_replace('<td>', "<td $format >", $msg);
- $msg = str_replace('<p>', "<p $format >", $msg);
- $msg = str_replace('<ol>', "<ol $format >", $msg);
- $msg = str_replace('<ul>', "<ul $format >", $msg);
-
- $msg = str_replace('<h1>', "<h1 $format_h1 >", $msg);
- $msg = str_replace('<h2>', "<h2 $format_h2 >", $msg);
- $msg = str_replace('<h3>', "<h3 $format_h3 >", $msg);
- $msg = str_replace('<h4>', "<h4 $format_h4 >", $msg);
- $msg = str_replace('<h5>', "<h5 $format_h4 >", $msg);
- $msg = str_replace('<h6>', "<h5 $format_h4 >", $msg);
-
- return $msg;
-
- }
- //-----------------------------------------------------------------------------------------
- /**
- * get_subject
- * in the right language
- * @param int 0, 1, 2
- * @param bool
- * @return string
- * @author Bernd
- *
- **/
- public function get_subject($row, $lang = 0, $take_first = TRUE)
- {
- if ( ! $lang) $lang = is_lang2() ? 2 : 1;
-
- if ($take_first && $lang == 2)
- $output = $row->subject2 ? $row->subject2 : $row->subject;
- elseif ($lang == 2)
- $output = $row->subject2 ? $row->subject2 : '';
- else
- $output = $row->subject;
- $output = strip_tags($output);
- return $output;
- }
-
- /**
- * get_message
- * in the right language
- * @param int 0, 1, 2
- * @param bool
- * @return string
- * @author Bernd
- *
- **/
- public function get_message($row, $lang = 0, $take_first = TRUE)
- {
- if ( ! $lang) $lang = is_lang2() ? 2 : 1;
-
- if ($take_first && $lang == 2)
- $output = $row->message2 ? $row->message2 : $row->message;
- elseif ($lang == 2)
- $output = $row->message2 ? $row->message2 : '';
- else
- $output = $row->message;
- return $output;
- }
-
- /**
- * get_video
- * in the right language
- * @param int 0, 1, 2
- * @return string
- * @author Bernd
- *
- **/
- public function get_video($row, $lang = 0)
- {
- if ( ! $lang) $lang = is_lang2() ? 2 : 1;
- $output = ($lang == 2 && $row->video2) ? $row->video2 : $row->video;
- return $output;
- }
-
- /**
- * get_video_url
- * in the right language
- * @param int 0, 1, 2
- * @return string
- * @author Bernd
- *
- **/
- public function get_video_url($row, $lang = 0)
- {
- if ( ! $lang) $lang = is_lang2() ? 2 : 1;
- $output = ($lang == 2 && $row->video_url2) ? $row->video_url2 : $row->video_url;
- return $output;
- }
-
-
- //-----------------------------------------------------------------------------------------
- /**
- * make_advertising_view
- * from Google or others, if allowed
- *
- * @return
- * @author Bernd
- *
- **/
- public function make_advertising_view($i = 0, $row, $bottom = FALSE)
- {
- $ad_position = explode(',', $this->config->item('ad_position'));
-
- if ($this->gradido->show_ads)
- {
- if ($bottom OR ($this->gradido->page_mode !== 'content' && $this->gradido->display === 'list' && in_array($i+1, $ad_position )))
- {
- $this->gradido->data['advertising'] = $this->advertising($this->ad_count++);
- return $this->load->view('messages/s_message_ad', $this->gradido->data, true)."\n";
- }
- }
-
- }
-
- /**
- * Advertising from Google or other
- *
- * @return string
- * @author Bernd
- **/
- public function advertising($count = 0)
- {
- if ( ! isset($this->banners ) )
- {
- $this->banners = $this->banner_model->show_banners();
- if ( ! isset($this->banners) OR ! is_array($this->banners))
- return;
- shuffle($this->banners);
- }
-
- if ( $count >= count($this->banners))
- $count = count($this->banners) - 1;
-
- if ( ! isset($this->banners[$count]))
- {
- return '';
- }
- else
- {
- $single = $this->banners[$count];
- $this->banner_model->track_views($single);
- $img = anchor('link/banner/'.$single['id'], img($single['banner_url']), 'target="_blank"');
- return $img;
- }
- }
-
- /**
- * Advertising from Google or other
- *
- * @return string
- * @author Bernd
- **/
- public function xxxadvertising($count = 0)
-
- {
-
-
- $advertising ='
- <script type="text/javascript"><!--
- google_ad_client = "pub-3290708995475366";
- /* gradido.de 468x60, Erstellt 27.04.10 */
- google_ad_slot = "5485092897";
- google_ad_width = 468;
- google_ad_height = 60;
- //-->
- </script>
- <script type="text/javascript"
- src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
- </script>
- ';
- if($count)
- {
- $advertising ='
- <script type="text/javascript"><!--
- google_ad_client = "pub-3290708995475366";
- /* 468x60, Erstellt 01.05.10 */
- google_ad_slot = "7739819088";
- google_ad_width = 468;
- google_ad_height = 60;
- //-->
- </script>
- <script type="text/javascript"
- src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
- </script>
- ';
- }
-
- return $advertising;
-
- }
- //-----------------------------------------------------------------------------------------
- /**
- * Message Headline
- *
- * @return string
- * @author Bernd Hueckstaeedt
- **/
- public function message_head($row)
- {
- $head = '';
-
-
- if ($this->gradido->display_single)
- {
- //other
- $head .= ($this->gradido->data['other']) ? $this->gradido->data['other'].br().' ' : '';
-
-
- if ($row->event_start)
- $head .= $this->compose_event_data($row);
- else
- $head .= ($this->gradido->data['datetime']) ? $this->gradido->data['datetime'].br().' ' : '';
- // amount and balance (only gradido-message )
- $head .= ($this->gradido->show_amount() && $this->gradido->data['amount_form']) ? $this->gradido->data['amount_form'].nbs().' ' : '';
- $head .= ($this->gradido->show_amount() && $this->gradido->data['balance_form']) ? $this->gradido->data['balance_form'].br().' ' : '';
-
-
- }
- else
- {
- //other
- $head .= ($this->gradido->data['other']) ? $this->gradido->data['other'].nbs().' ' : '';
-
- if ($row->event_start)
- $head .= $this->compose_event_data($row);
- else
- $head .= ($this->gradido->data['datetime']) ? $this->gradido->data['datetime'].nbs().' ' : '';
-
- }
-
- $this->gradido->data['message_head'] = $head;
-
- }
-
-
- //-----------------------------------------------------------------------------------------
- /**
- * Compose Event Data
- *
- * @return string
- * @author Bernd Hueckstaedt
- **/
- public function compose_event_data($row)
- {
- $output = br();
- if ($row->event_repeat && $row->event_repeat != 'FALSE')
- {
- $output .= lang('gradido.url.month_start').' '.$this->gradido->format('date',$row->event_start, false).nbs().' ';
- $output .= lang('gradido.url.month_end').' '.$this->gradido->format('date',$row->event_end, false).nbs().' ';
-
- $repeat = lang('gradido.repeat');
- $output .= isset($repeat[$row->event_repeat]) ? br().$repeat[$row->event_repeat].nbs().' ' : '' ;
- $output .= $this->gradido->format('time',$row->event_start, false).nbs().' ';
- $output .= lang('gradido.url.month_end').' '.$this->gradido->format('time',$row->event_end, false).nbs().' ';
- }
- else
- {
- if ($this->gradido->format('date',$row->event_start, false) === $this->gradido->format('date',$row->event_end, false))
- {
- $output .= $this->gradido->format('date',$row->event_start, false).nbs().' ';
- $output .= $this->gradido->format('time',$row->event_start, false).nbs().' ';
- $output .= lang('gradido.url.month_end').' '.$this->gradido->format('time',$row->event_end, false).nbs().' ';
- }
- else
- {
- $output .= ($row->event_start) ? $this->gradido->format('datetime',$row->event_start, false).nbs().' ' : '';
- $output .= ($row->event_end) ? lang('gradido.url.month_end').' '.$this->gradido->format('datetime',$row->event_end, false).nbs().' ' : '';
- }
- }
-
- return $output;
- }
- //-----------------------------------------------------------------------------------------
- /**
- * Compose Price
- *
- * @return string
- * @author Bernd Hueckstaedt
- **/
- public function compose_price($row)
- {
- $output = '';
-
- if ($row->commercial)
- {
- $output .= br();
- $output .= $row->brutto ? lang('gradido.market_gross').': '.$this->gradido->format('decimal', $row->brutto).' '.$this->config->item('national_currency').nbs().' ' : '';
-
- // Gradido discount
- if ($row->percent > 1)
- {
- $output .= lang('gradido.market_gradido').': '.$row->percent.nbs().'%'.nbs().' ';
- $output .= $row->brutto ? lang('gradido.market_net').': '.$this->gradido->format('decimal',$row->netto).' '.$this->config->item('national_currency').nbs().' ' : '';
- }
- elseif ($row->percent == 1)
- {
- $output .= lang('gradido.market_gradido').': '.lang('gradido.market_agreement').nbs().' ';
- }
- else
- {
- $output .= lang('gradido.market_gradido').': '.lang('gradido.market_no_details').nbs().' ';
- }
-
-
-
- }
- else
- {
- $output .= $row->brutto ? br().lang('gradido.market_thank_request').': '.$row->brutto.' '.$this->config->item('currency_short').nbs().' ' : '';
- }
-
-
-
- return $output;
-
- }
-
- //-----------------------------------------------------------------------------------------
- /**
- * Other with link
- *
- * @return string
- * @author Bernd
- **/
- public function other($row)
- {
- // Creation, Decay GvE, GvS do not link
- if(
- $this->gradido->data['other_id'] == $this->config->item('creation_id')
- OR $this->gradido->data['other_id'] == $this->config->item('decay_id')
- OR $this->gradido->data['other_server'] === 'email' && $this->gradido->is_po()
- OR $this->gradido->data['other_server'] === 'social' && $this->gradido->is_po()
- )
- {
- $other = $this->gradido->data['other_prefix'].$this->gradido->data['other_name'];
- }
- // Normal: other with link
- elseif($this->gradido->show_name($row))
- {
- $other_text = $this->gradido->data['other_server'] === $this->config->item('site_servername') ? '' : $this->gradido->data['other_server'].'/';
- $other_text .= $this->gradido->data['other_name'];
- $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);
- }
- // Protected or no more member
- else
- {
- $other = $this->gradido->data['other_prefix'].lang('gradido.mes_protected');
- }
- $this->gradido->data['other'] = $other;
- }
- //-----------------------------------------------------------------------------------------
- /**
- * Other image with link
- *
- * @return string
- * @author Bernd
- **/
- public function other_image($row)
- {
- if(trim($row->image) && ! $this->gradido->display_single)
- {
- $img_url = str_replace('/img/' , '/img/thumbs/', $row->image);
- $img = '<img src = "'.$img_url.'" width = "50" height = "50" alt="Test_Image" />';
-
- }
- elseif($this->gradido->data['other_id'] == $this->config->item('creation_id'))
- {
- // Creation image does not link
- $img = '<img src = "'.$this->gradido->data['other_server_url'].'/uploads/users/'.
- $this->gradido->data['other_id'].'_userimg_'.$this->config->item('userimg_msg').'.jpg" alt="creation" />';
- }
- elseif($this->gradido->data['other_id'] == $this->config->item('decay_id'))
- {
- // Decay image does not link
- $img = '<img src = "'.$this->gradido->data['other_server_url'].'/uploads/users/'.
- $this->gradido->data['other_id'].'_userimg_'.$this->config->item('userimg_msg').'.jpg" alt="decay" />';
- }
- elseif(!$this->gradido->show_name($row) OR $row->r_server === 'email'OR $row->s_server === 'email' OR $row->r_server === 'social')
- {
- // protected or gradido via email
- $img = '<img src = "'.$this->gradido->data['other_server_url'].'/uploads/users/'.
- 'user_protected'.'_userimg_'.$this->config->item('userimg_msg').'.jpg" alt="protected" />';
- }
- else
- {
- // Normal: other image with link
- $img = '<img src = "'.$this->gradido->data['other_server_url'].'/uploads/users/'.
- $this->gradido->data['other_id'].'_userimg_'.$this->config->item('userimg_msg').'.jpg" alt="'.$this->gradido->data['other_id'].'" />';
-
- $img = anchor($this->gradido->data['other_server_url'].current_lang_short(FALSE, TRUE).$this->gradido->data['other_id'], $img);
- }
- $this->gradido->data['other_image'] = $img;
- }
-
- //-----------------------------------------------------------------------------------------
- /**
- * Edit Links
- *
- * @return string
- * @author Bernd
- **/
- public function edit_links($row)
- {
- if ($this->gradido->self_is($row) && $this->gradido->market_mode != 'place' && $this->gradido->market_mode != 'network' )
- {
- // market adds only can be changed on the owner's site
-
- $link = '';
- $m = 'style = "text-decoration: underline;"';
- $sep = '|'.nbs(2);
- $i = 0;
-
- // publish links
- if ($this->gradido->select_mode !== 'dm' && $row->type != 4)
- {
- $link .= ($i)? $sep : '';
- $i++;
-
-
- $publish = ($this->gradido->self_is($row) == 's') ? $row->s_publish : $row->r_publish;
- $a30 = (30 == $publish) ? $m : '';
- $a20 = (20 == $publish) ? $m : '';
- $a10 = (10 >= $publish) ? $m : '';
- $a0 = (!$row->s_publish) ? $m : '';
- $link .= anchor($this->gradido->po_id.'/set_publish/30/'.$row->id, span(lang('gradido.publish_internet'),$a30)).nbs(2);
- $link .= anchor($this->gradido->po_id.'/set_publish/20/'.$row->id, span(lang('gradido.publish_gradido'),$a20)).nbs(2);
- $link .= anchor($this->gradido->po_id.'/set_publish/10/'.$row->id, span(lang('gradido.publish_private'),$a10)).nbs(2);
- }
-
- // status links confirm/reject
- //if (6 <= $row->status && 15 >= $row->status && $this->gradido->self_is($row) === 'r') // only for debugging
- if (6 <= $row->status && 15 >= $row->status && $row->status != 8 && $row->status != 9 && $this->gradido->self_is($row) === 'r')
- {
- $link .= ($i)? $sep : '';
- $i++;
-
- $link .= anchor($this->gradido->po_id.'/set_status/30/'.$row->id, span(lang('gradido.mes_confirm'),'')).nbs(2);
- $link .= anchor($this->gradido->po_id.'/set_status/8/'.$row->id, span(lang('gradido.mes_reject'),'')).nbs(2);
- }
-
- // status links remind/cancel
- //if (6 <= $row->status && 15 >= $row->status && $this->gradido->self_is($row) === 's') // only for debugging
- if (6 <= $row->status && 15 >= $row->status && $row->status != 8 && $row->status != 9 && $this->gradido->self_is($row) === 's')
- {
- $link .= ($i)? $sep : '';
- $i++;
-
- $link .= anchor($this->gradido->po_id.'/set_status/11/'.$row->id, span(lang('gradido.mes_remind'),'')).nbs(2);
- $link .= anchor($this->gradido->po_id.'/set_status/9/'.$row->id, span(lang('gradido.mes_cancel'),'')).nbs(2);
- }
-
- if ( ! TRUE) //show open, close links
- {
- $link .= ($i)? $sep : '';
- $i++;
-
- $closed_flag = ($this->gradido->uso->id == $row->s_id) ? $row->s_closed : $row->r_closed;
- $open = (0 == $closed_flag) ? $m : '';
- $closed = (1 == $closed_flag) ? $m : '';
- $link .= anchor($this->gradido->po_id.'/set_open/'.$row->id, span(lang('gradido.publish_open'),$open)).nbs(2);
- $link .= anchor($this->gradido->po_id.'/set_closed/'.$row->id, span(lang('gradido.publish_closed'),$closed)).nbs(2);
- }
-
-
- if ($this->gradido->allow_edit($row)) // edit
- {
- //$link .= ($i)? $sep : '';
- $i++;
- $icon = '<img src = "'.base_url().'design/icons/pencil_16.png" alt="'.lang('gradido.write_edit_message').'" />';
- //$link .= anchor($seg1.'/edit_message/'.$row->id, $icon, 'title = "'.lang('gradido.write_edit_message').'"').nbs(2);
- $link .= anchor($this->gradido->po_id.'/m/'.$row->message_id.'/edit', $icon, 'title = "'.lang('gradido.write_edit_message').'"').nbs(2);
- }
-
- return div($link, 'class = "edit_links" ');
- }
-
- }
-
- //-----------------------------------------------------------------------------------------
- /**
- * message_event_time
- *
- * @return string ???????????? nothing is returned! Work in progress???
- * @author Bernd
- **/
- public function message_event_time($row)
- {
- $output = '';
- if ($row->event_start)
- $output .= $this->gradido->display === 'map' ? $this->gradido->format('datetime_no_nbs',$row->event_start, false) : $this->gradido->format('datetime',$row->event_start, false);
- if ($row->event_end)
- {
- $output .= ' '.strtolower(lang('gradido.events_end')).' ';
- $output .= $this->gradido->display === 'map' ? $this->gradido->format('datetime_no_nbs',$row->event_end, false) : $this->gradido->format('datetime',$row->event_end, false);
- }
- }
- //-----------------------------------------------------------------------------------------
- /**
- * select_mutual_links (all, mutual, other)
- *
- * @return string
- * @author Bernd
- **/
-
-
- public function select_mutual_links()
- {
- if($this->gradido->logged_in() && !$t…
Large files files are truncated, but you can click here to view the full file