public function setUrl($url) { if (!preg_match('/^(\\.\\/|index.php)/i', $url) && preg_match('/\\w+\\.\\w{2,3}($|\\/)/', $url)) { $url = PHPWS_Text::checkLink($url); } PHPWS_Text::makeRelative($url); $url = str_replace('&', '&', trim($url)); $this->url = preg_replace('/&?authkey=\\w{32}/i', '', $url); }
public function getLocation() { if (!empty($this->loc_link)) { return sprintf('<a href="%s" title="%s">%s</a>', PHPWS_Text::checkLink($this->loc_link), dgettext('calendar', 'Visit this location\'s web site.'), $this->location); } else { return $this->location; } }
public function getTpl() { $tpl['SUMMARY'] = $this->summary; $tpl['DESCRIPTION'] = $this->getDescription(); if (CALENDAR_MONTH_FIRST) { $month_day_mode = '%B %e'; } else { $month_day_mode = '%e %B'; } if ($this->all_day) { $tpl['TO'] = '–'; if (date('Ymd', $this->start_time) != date('Ymd', $this->end_time)) { if (CALENDAR_MONTH_FIRST) { if (date('Y', $this->start_time) != date('Y', $this->end_time)) { $tpl['START_TIME'] = sprintf(dgettext('calendar', 'All day event, %s'), strftime('%B %e, %Y', $this->start_time)); } else { $tpl['START_TIME'] = sprintf(dgettext('calendar', 'All day event, %s'), strftime('%B %e', $this->start_time)); } } else { if (date('Y', $this->start_time) != date('Y', $this->end_time)) { $tpl['START_TIME'] = sprintf(dgettext('calendar', 'All day event, %s'), strftime('%e, %Y', $this->start_time)); } else { $tpl['START_TIME'] = sprintf(dgettext('calendar', 'All day event, %s'), strftime('%e', $this->start_time)); } } if (date('Ym', $this->start_time) != date('Ym', $this->end_time)) { if (CALENDAR_MONTH_FIRST) { $tpl['END_TIME'] = strftime('%B %e, %Y', $this->end_time); } else { $tpl['END_TIME'] = strftime('%e, %Y', $this->end_time); } } else { if (CALENDAR_MONTH_FIRST) { $tpl['END_TIME'] = strftime('%e, %Y', $this->end_time); } else { $tpl['END_TIME'] = strftime('%e %B, %Y', $this->end_time); } } } else { $tpl['START_TIME'] = dgettext('calendar', 'All day event'); $tpl['END_TIME'] = $this->getStartTime($month_day_mode); } } else { if (date('Ymd', $this->start_time) != date('Ymd', $this->end_time)) { // If this event happens over 2 or more day if (date('Y', $this->start_time) != date('Y', $this->end_time)) { $tpl['START_TIME'] = $this->getStartTime(CALENDAR_TIME_FORMAT . ', ' . $month_day_mode . ', %Y'); } else { $tpl['START_TIME'] = $this->getStartTime(CALENDAR_TIME_FORMAT . ', ' . $month_day_mode); } $tpl['END_TIME'] = $this->getEndTime(CALENDAR_TIME_FORMAT . ', ' . $month_day_mode . ', %Y'); } else { $tpl['START_TIME'] = $this->getStartTime(CALENDAR_TIME_FORMAT); $tpl['END_TIME'] = $this->getEndTime(CALENDAR_TIME_FORMAT . ', ' . $month_day_mode . ', %Y'); } $tpl['TO'] = dgettext('calendar', 'to'); } if (!empty($this->location)) { if (!empty($this->loc_link)) { $tpl['LOCATION'] = sprintf('<a href="%s" title="%s">%s</a>', PHPWS_Text::checkLink($this->loc_link), dgettext('calendar', 'Visit this location\'s web site.'), $this->location); } else { $tpl['LOCATION'] = $this->location; } } $vars['suggestion_id'] = $this->id; $vars['aop'] = 'approve_suggestion'; $links[] = PHPWS_Text::secureLink(dgettext('calendar', 'Approve'), 'calendar', $vars); $vars['aop'] = 'disapprove_suggestion'; $links[] = PHPWS_Text::secureLink(dgettext('calendar', 'Disapprove'), 'calendar', $vars); $tpl['ACTION'] = implode(' | ', $links); return $tpl; }
public function post_entry() { if (!Current_User::authorized('blog', 'edit_blog')) { Current_User::disallow(); } if (empty($_POST['title'])) { $this->_error[] = dgettext('blog', 'Missing title.'); } else { $this->title = strip_tags($_POST['title']); } $summary_and_entry = $_POST['summary']; if (!$this->id && strlen($summary_and_entry) > 1000) { if (!preg_match('/<hr[^>]?/', $summary_and_entry)) { $paragraphs = explode('<p>', $summary_and_entry); if (count($paragraphs) > 3) { $paragraphs[2] .= '<hr />'; $summary_and_entry = implode('<p>', $paragraphs); } } } if (empty($summary_and_entry)) { $this->_error[] = dgettext('blog', 'Your submission must have some content.'); } else { // We don't catch the regular expression result because we only care about matches preg_replace_callback('@(.*?)<hr[^>]*/>(.*)@s', function ($matches) { $GLOBALS['split_summary'] = $matches; }, $summary_and_entry); if (isset($GLOBALS['split_summary'])) { $this->setSummary($GLOBALS['split_summary'][1]); $this->setEntry($GLOBALS['split_summary'][2]); } else { $this->setSummary($summary_and_entry); $this->entry = null; } } if (isset($_POST['image_id'])) { $this->image_id = (int) $_POST['image_id']; } if (isset($_POST['thumbnail'])) { $this->thumbnail = 1; } else { $this->thumbnail = 0; } if (empty($this->author)) { $this->author = Current_User::getDisplayName(); } if (empty($_POST['publish_date'])) { $this->publish_date = time(); } else { $this->publish_date = strtotime($_POST['publish_date']); } if (empty($_POST['expire_date'])) { $this->expire_date = 0; } else { $this->expire_date = strtotime($_POST['expire_date']); } $this->approved = 1; $link_choices[] = 'none'; $link_choices[] = 'default'; $link_choices[] = 'readmore'; $link_choices[] = 'parent'; $link_choices[] = 'url'; $image_link =& $_POST['image_link']; if (!in_array($image_link, $link_choices)) { $this->image_link = 'default'; } elseif ($_POST['image_link'] != 'url') { $this->image_link = $image_link; } else { $url = $_POST['image_url']; if (!empty($url) || $url == 'http://') { $this->image_link = PHPWS_Text::checkLink($url); } else { $this->image_link = 'default'; } } return true; }