Merge branch 'master' of git://github.com/friendika/friendika

This commit is contained in:
Tobias Diekershoff 2011-06-10 07:02:53 +02:00
commit 8390e8b19b
6 changed files with 220 additions and 16 deletions

View file

@ -4,7 +4,7 @@ set_time_limit(0);
ini_set('pcre.backtrack_limit', 250000);
define ( 'FRIENDIKA_VERSION', '2.2.1005' );
define ( 'FRIENDIKA_VERSION', '2.2.1006' );
define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
define ( 'DB_UPDATE_VERSION', 1063 );
@ -150,6 +150,7 @@ define ( 'ACTIVITY_OBJ_PERSON', NAMESPACE_ACTIVITY_SCHEMA . 'person' );
define ( 'ACTIVITY_OBJ_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'photo' );
define ( 'ACTIVITY_OBJ_P_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'profile-photo' );
define ( 'ACTIVITY_OBJ_ALBUM', NAMESPACE_ACTIVITY_SCHEMA . 'photo-album' );
define ( 'ACTIVITY_OBJ_EVENT', NAMESPACE_ACTIVITY_SCHEMA . 'event' );
/**
* item weight for query ordering

View file

@ -1,5 +1,8 @@
<?php
require_once("include/oembed.php");
require_once('include/event.php');
// BBcode 2 HTML was written by WAY2WEB.net
// extended to work with Mistpark/Friendika - Mike Macgirvin
@ -17,6 +20,12 @@ function bbcode($Text,$preserve_nl = false) {
if($preserve_nl)
$Text = str_replace(array("\n","\r"), array('',''),$Text);
// If we find any event code, turn it into an event.
// After we're finished processing the bbcode we'll
// replace all of the event code with a reformatted version.
$ev = bbtoevent($Text);
// Set up the parameters for a URL search string
$URLSearchString = "^\[\]";
// Set up the parameters for a MAIL search string
@ -37,7 +46,7 @@ function bbcode($Text,$preserve_nl = false) {
$Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.*?)\[\/mail\]/", '<a href="mailto:$1">$2</a>', $Text);
// Check for bold text
$Text = preg_replace("(\[b\](.*?)\[\/b])is",'<strong>$1</strong>',$Text);
$Text = preg_replace("(\[b\](.*?)\[\/b\])is",'<strong>$1</strong>',$Text);
// Check for Italics text
$Text = preg_replace("(\[i\](.*?)\[\/i\])is",'<em>$1</em>',$Text);
@ -104,8 +113,24 @@ function bbcode($Text,$preserve_nl = false) {
}
// $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '<object width="425" height="350" type="application/x-shockwave-flash" data="http://www.youtube.com/v/$1" ><param name="movie" value="http://www.youtube.com/v/$1"></param><!--[if IE]><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350" /><![endif]--></object>', $Text);
// oembed tag
$Text = oembed_bbcode2html($Text);
// If we found an event earlier, strip out all the event code and replace with a reformatted version.
if(x($ev,'desc') && x($ev,'start')) {
$sub = format_event_html($ev);
$Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/is",$sub,$Text);
$Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/is",'',$Text);
$Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/is",'',$Text);
$Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/is",'',$Text);
$Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",'',$Text);
}
call_hooks('bbcode',$Text);

View file

@ -1,7 +1,7 @@
<?php
function format_event_html($ev,$pre = '') {
function format_event_html($ev) {
require_once('include/bbcode.php');
@ -105,16 +105,63 @@ function parse_event($h) {
}
function format_event_bbcode($ev) {
$o = '';
if($ev['desc'])
$o .= '[event-description]' . $ev['desc'] . '[/event-description]';
if($ev['start'])
$o .= '[event-start]' . $ev['start'] . '[/event-start]';
if(($ev['finish']) && (! $ev['nofinish']))
$o .= '[event-finish]' . $ev['finish'] . '[/event-finish]';
if($ev['location'])
$o .= '[event-location]' . $ev['location'] . '[/event-location]';
if($ev['adjust'])
$o .= '[event-adjust]' . $ev['adjust'] . '[/event-adjust]';
return $o;
}
function bbtovcal($s) {
$o = '';
$ev = bbtoevent($s);
if($ev['desc'])
$o = format_event_html($ev);
return $o;
}
function bbtoevent($s) {
$ev = array();
$match = '';
if(preg_match("/\[event\-description\](.*?)\[\/event\-description\]/is",$s,$match))
$ev['desc'] = $match[1];
$match = '';
if(preg_match("/\[event\-start\](.*?)\[\/event\-start\]/is",$s,$match))
$ev['start'] = $match[1];
$match = '';
if(preg_match("/\[event\-finish\](.*?)\[\/event\-finish\]/is",$s,$match))
$ev['finish'] = $match[1];
$match = '';
if(preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is",$s,$match))
$ev['location'] = $match[1];
$match = '';
if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match))
$ev['adjust'] = $match[1];
$match = '';
$ev['nofinish'] = (($ev['start'] && (! $ev['finish'])) ? 1 : 0);
return $ev;
}
function sort_by_date($a) {

View file

@ -2,6 +2,7 @@
require_once('include/datetime.php');
require_once('include/event.php');
require_once('include/items.php');
function events_post(&$a) {
@ -44,18 +45,27 @@ function events_post(&$a) {
}
$desc = escape_tags($_POST['desc']);
$location = escape_tags($_POST['location']);
$desc = escape_tags(trim($_POST['desc']));
$location = escape_tags(trim($_POST['location']));
$type = 'event';
$str_group_allow = perms2str($_POST['group_allow']);
$str_contact_allow = perms2str($_POST['contact_allow']);
$str_group_deny = perms2str($_POST['group_deny']);
$str_contact_deny = perms2str($_POST['contact_deny']);
if((! $desc) || (! $start)) {
notice('Event description and start time are required.');
goaway($a->get_baseurl() . '/events/new');
}
$share = ((intval($_POST['share'])) ? intval($_POST['share']) : 0);
// until publishing is ready
$str_contact_allow = '<' . local_user() . '>';
if($share) {
$str_group_allow = perms2str($_POST['group_allow']);
$str_contact_allow = perms2str($_POST['contact_allow']);
$str_group_deny = perms2str($_POST['group_deny']);
$str_contact_deny = perms2str($_POST['contact_deny']);
}
else {
$str_contact_allow = '<' . local_user() . '>';
$str_group_allow = $str_contact_deny = $str_group_deny = '';
}
if($event_id) {
$r = q("UPDATE `event` SET
@ -114,8 +124,56 @@ function events_post(&$a) {
dbesc($str_group_deny)
);
}
$r = q("SELECT * FROM `event` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($uri),
intval(local_user())
);
if(count($r))
$event = $r[0];
$arr = array();
$arr['uid'] = local_user();
$arr['uri'] = $uri;
$arr['parent-uri'] = $uri;
$arr['type'] = 'activity';
$arr['wall'] = 1;
$arr['contact-id'] = $a->contact['id'];
$arr['owner-name'] = $a->contact['name'];
$arr['owner-link'] = $a->contact['url'];
$arr['owner-avatar'] = $a->contact['thumb'];
$arr['author-name'] = $a->contact['name'];
$arr['author-link'] = $a->contact['url'];
$arr['author-avatar'] = $a->contact['thumb'];
$arr['title'] = '';
$arr['allow_cid'] = $str_contact_allow;
$arr['allow_gid'] = $str_group_allow;
$arr['deny_cid'] = $str_contact_deny;
$arr['deny_gid'] = $str_group_deny;
$arr['last-child'] = 1;
$arr['visible'] = 1;
$arr['verb'] = ACTIVITY_POST;
$arr['object-type'] = ACTIVITY_OBJ_EVENT;
$arr['body'] = format_event_bbcode($event);
$arr['object'] = '<object><type>' . ACTIVITY_OBJ_EVENT . '</type><title></title><id>' . $uri . '</id>';
$arr['object'] .= '<content>' . format_event_bbcode($event) . '</content>';
$arr['object'] .= '</object>' . "\n";
$item_id = item_store($arr);
if($item_id) {
q("UPDATE `item` SET `plink` = '%s', `event-id` = %d WHERE `uid` = %d AND `id` = %d LIMIT 1",
dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id),
intval($event['id']),
intval(local_user()),
intval($item_id)
);
proc_run('php',"include/notifier.php","tag","$item_id");
}
}
}
@ -204,6 +262,7 @@ function events_content(&$a) {
if(count($r)) {
$r = sort_by_date($r);
foreach($r as $rr) {
$d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], $fmt) : datetime_convert('UTC','UTC',$rr['start'],$fmt));
$d = day_translate($d);
if($d !== $last_date)
@ -216,7 +275,7 @@ function events_content(&$a) {
}
if($mode === 'edit' || $mode === 'new') {
$htpl = get_markup_template('profed_head.tpl');
$htpl = get_markup_template('event_head.tpl');
$a->page['htmlhead'] .= replace_macros($htpl,array('$baseurl' => $a->get_baseurl()));
$tpl = get_markup_template('event_form.tpl');
@ -225,6 +284,8 @@ function events_content(&$a) {
$month = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
$day = datetime_convert('UTC', date_default_timezone_get(), 'now', 'd');
require_once('include/acl_selectors.php');
$o .= replace_macros($tpl,array(
'$post' => $a->get_baseurl() . '/events',
'$e_text' => t('Event details'),
@ -243,6 +304,9 @@ function events_content(&$a) {
'$d_orig' => '',
'$l_text' => t('Location:'),
'$l_orig' => '',
'$sh_text' => t('Share this event'),
'$sh_checked' => '',
'$acl' => populate_acl($a->user,false),
'$submit' => t('Submit')
));

View file

@ -29,6 +29,11 @@ $f_dsel $f_tsel
<div id="event-location-text">$l_text</div>
<textarea id="event-location-textarea" name="location">$l_orig</textarea>
<input type="checkbox" name="share" value="1" id="event-share-checkbox" $sh_checked /> <div id="event-share-text">$sh_text</div>
<div id="event-share-break"></div>
$acl
<input id="event-submit" type="submit" name="submit" value="$submit" />
</form>

62
view/event_head.tpl Normal file
View file

@ -0,0 +1,62 @@
<script language="javascript" type="text/javascript"
src="$baseurl/tinymce/jscripts/tiny_mce/tiny_mce_src.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
theme : "advanced",
mode : "textareas",
plugins : "bbcode,paste",
theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "center",
theme_advanced_blockformats : "blockquote,code",
paste_text_sticky : true,
entity_encoding : "raw",
add_unload_trigger : false,
remove_linebreaks : false,
force_p_newlines : false,
force_br_newlines : true,
forced_root_block : '',
content_css: "$baseurl/view/custom_tinymce.css",
theme_advanced_path : false,
setup : function(ed) {
ed.onInit.add(function(ed) {
ed.pasteAsPlainText = true;
});
}
});
$(document).ready(function() {
$('#event-share-checkbox').change(function() {
if ($('#event-share-checkbox').is(':checked')) {
$('#acl-wrapper').show();
}
else {
$('#acl-wrapper').hide();
}
}).trigger('change');
$('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
var selstr;
$('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
selstr = $(this).text();
$('#jot-public').hide();
});
if(selstr == null) {
$('#jot-public').show();
}
}).trigger('change');
});
</script>