Browse Source

* Add MIME types for file attachments

* Restore translatability to mood phrases
* Prevent casting of "false" in html2plain
* Allow attachments with a comma in the filename
* Fix/optimize ACL img data-src jQuery search
* Fix bug when uploading files with a comma in the name using Chrome/Chromium
* Babel nicer output formatting
* Remove obsolete "plaintext" check in mod/parse_url
* Restore TinyMCE live insertion of images
* Smarty conversion script: add --no-header option to suppress warning headers in Smarty template files
pull/582/head
Zach Prezkuta 8 years ago
parent
commit
74caf1a4a7
29 changed files with 75 additions and 62 deletions
  1. +4
    -0
      include/attach.php
  2. +8
    -13
      include/conversation.php
  3. +1
    -1
      include/html2plain.php
  4. +2
    -2
      include/items.php
  5. +4
    -0
      include/notifier.php
  6. +2
    -2
      include/text.php
  7. +1
    -1
      js/acl.js
  8. +1
    -1
      js/acl.min.js
  9. +4
    -2
      mod/attach.php
  10. +14
    -10
      mod/babel.php
  11. +0
    -2
      mod/parse_url.php
  12. +6
    -1
      mod/wall_upload.php
  13. +8
    -3
      mods/friendica-to-smarty-tpl.py
  14. +1
    -2
      view/smarty3/voting_fakelink.tpl
  15. +2
    -2
      view/theme/frost-mobile/js/acl.js
  16. +1
    -1
      view/theme/frost-mobile/js/acl.min.js
  17. +2
    -2
      view/theme/frost-mobile/js/main.js
  18. +1
    -1
      view/theme/frost-mobile/js/main.min.js
  19. +1
    -2
      view/theme/frost-mobile/smarty3/voting_fakelink.tpl
  20. +1
    -2
      view/theme/frost-mobile/voting_fakelink.tpl
  21. +1
    -0
      view/theme/frost/acl_selector.tpl
  22. +2
    -2
      view/theme/frost/js/acl.js
  23. +1
    -1
      view/theme/frost/js/acl.min.js
  24. +2
    -2
      view/theme/frost/js/main.js
  25. +1
    -1
      view/theme/frost/js/main.min.js
  26. +1
    -0
      view/theme/frost/smarty3/acl_selector.tpl
  27. +1
    -2
      view/theme/frost/smarty3/voting_fakelink.tpl
  28. +1
    -2
      view/theme/frost/voting_fakelink.tpl
  29. +1
    -2
      view/voting_fakelink.tpl

+ 4
- 0
include/attach.php View File

@ -42,6 +42,10 @@ function z_mime_content_type($filename) {
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'ogg' => 'application/ogg',
'mp4' => 'video/mp4',
'avi' => 'video/x-msvideo',
'wmv' => 'video/x-ms-wmv',
'wma' => 'audio/x-ms-wma',
// adobe
'pdf' => 'application/pdf',


+ 8
- 13
include/conversation.php View File

@ -877,26 +877,21 @@ function format_like($cnt,$arr,$type,$id) {
if($cnt == 1)
$o .= (($type === 'like') ? sprintf( t('%s likes this.'), $arr[0]) : sprintf( t('%s doesn\'t like this.'), $arr[0])) . EOL ;
else {
//$spanatts = 'class="fakelink" onclick="openClose(\'' . $type . 'list-' . $id . '\');"';
$spanatts = "class=\"fakelink\" onclick=\"openClose('{$type}list-$id');\"";
switch($type) {
case 'like':
// $phrase = sprintf( t('<span %1$s>%2$d people</span> like this.'), $spanatts, $cnt);
$mood = t('like this');
$phrase = sprintf( t('<span %1$s>%2$d people</span> like this'), $spanatts, $cnt);
break;
case 'dislike':
// $phrase = sprintf( t('<span %1$s>%2$d people</span> don\'t like this.'), $spanatts, $cnt);
$mood = t('don\'t like this');
$phrase = sprintf( t('<span %1$s>%2$d people</span> don\'t like this'), $spanatts, $cnt);
break;
}
$tpl = get_markup_template("voting_fakelink.tpl");
$phrase = replace_macros($tpl, array(
'$vote_id' => $type . 'list-' . $id,
'$count' => $cnt,
'$people' => t('people'),
'$vote_mood' => $mood
$phrase .= EOL ;
$o .= replace_macros(get_markup_template('voting_fakelink.tpl'), array(
'$phrase' => $phrase,
'$type' => $type,
'$id' => $id
));
$o .= $phrase;
// $o .= EOL ;
$total = count($arr);
if($total >= MAX_LIKERS)


+ 1
- 1
include/html2plain.php View File

@ -209,7 +209,7 @@ function html2plain($html, $wraplength = 75, $compact = false)
if (!$compact) {
$counter = 1;
foreach ($urls as $id=>$url)
if (strpos($message, $url) == false)
if (strpos($message, $url) === false)
$message .= "\n".$url." ";
//$message .= "\n[".($counter++)."] ".$url;
}


+ 2
- 2
include/items.php View File

@ -3732,11 +3732,11 @@ function item_getfeedtags($item) {
function item_getfeedattach($item) {
$ret = '';
$arr = explode(',',$item['attach']);
$arr = explode('[/attach],',$item['attach']);
if(count($arr)) {
foreach($arr as $r) {
$matches = false;
$cnt = preg_match('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches);
$cnt = preg_match('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"|',$r,$matches);
if($cnt) {
$ret .= '<link rel="enclosure" href="' . xmlify($matches[1]) . '" type="' . xmlify($matches[3]) . '" ';
if(intval($matches[2]))


+ 4
- 0
include/notifier.php View File

@ -37,6 +37,7 @@ require_once('include/html2plain.php');
* tag (in photos.php, poke.php, tagger.php)
* tgroup (in items.php)
* wall-new (in photos.php, item.php)
* removeme (in Contact.php)
*
* and ITEM_ID is the id of the item in the database that needs to be sent to others.
*/
@ -138,14 +139,17 @@ function notifier_run(&$argv, &$argc){
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($item_id));
if (! $r)
return;
$user = $r[0];
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", intval($item_id));
if (! $r)
return;
$self = $r[0];
$r = q("SELECT * FROM `contact` WHERE `self` = 0 AND `uid` = %d", intval($item_id));
if(! $r)
return;
require_once('include/Contact.php');
foreach($r as $contact) {
terminate_friendship($user, $self, $contact);


+ 2
- 2
include/text.php View File

@ -1041,13 +1041,13 @@ function prepare_body($item,$attach = false) {
return $s;
}
$arr = explode(',',$item['attach']);
$arr = explode('[/attach],',$item['attach']);
if(count($arr)) {
$s .= '<div class="body-attach">';
foreach($arr as $r) {
$matches = false;
$icon = '';
$cnt = preg_match_all('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches, PREG_SET_ORDER);
$cnt = preg_match_all('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"|',$r,$matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
$icontype = strtolower(substr($mtch[3],0,strpos($mtch[3],'/')));


+ 1
- 1
js/acl.js View File

@ -253,7 +253,7 @@ ACL.prototype.populate = function(data){
//console.log(html);
that.list_content.append(html);
});
$(".acl-list-item[rel!=acl-template] img[data-src]").each(function(i, el){
$(".acl-list-item img[data-src]", that.list_content).each(function(i, el){
// Add src attribute for images with a data-src attribute
$(el).attr('src', $(el).data("src"));
});


+ 1
- 1
js/acl.min.js
File diff suppressed because it is too large
View File


+ 4
- 2
mod/attach.php View File

@ -34,9 +34,11 @@ function attach_init(&$a) {
return;
}
// Use quotes around the filename to prevent a "multiple Content-Disposition"
// error in Chrome for filenames with commas in them
header('Content-type: ' . $r[0]['filetype']);
header('Content-disposition: attachment; filename=' . $r[0]['filename']);
header('Content-disposition: attachment; filename="' . $r[0]['filename'] . '"');
echo $r[0]['data'];
killme();
// NOTREACHED
}
}

+ 14
- 10
mod/babel.php View File

@ -11,7 +11,7 @@ function visible_lf($s) {
function babel_content(&$a) {
$o .= '<h3>Babel Diagnostic</h3>';
$o .= '<h1>Babel Diagnostic</h1>';
$o .= '<form action="babel" method="post">';
$o .= t('Source (bbcode) text:') . EOL . '<textarea name="text" >' . htmlspecialchars($_REQUEST['text']) .'</textarea>' . EOL;
@ -28,31 +28,35 @@ function babel_content(&$a) {
if(x($_REQUEST,'text')) {
$text = trim($_REQUEST['text']);
$o .= t("Source input: ") . EOL. EOL;
$o .= "<h2>" . t("Source input: ") . "</h2>" . EOL. EOL;
$o .= visible_lf($text) . EOL. EOL;
$html = bbcode($text);
$o .= t("bb2html: ") . EOL. EOL;
$o .= "<h2>" . t("bb2html (raw HTML): ") . "</h2>" . EOL. EOL;
$o .= htmlspecialchars($html). EOL. EOL;
//$html = bbcode($text);
$o .= "<h2>" . t("bb2html: ") . "</h2>" . EOL. EOL;
$o .= $html. EOL. EOL;
$bbcode = html2bbcode($html);
$o .= t("bb2html2bb: ") . EOL. EOL;
$o .= "<h2>" . t("bb2html2bb: ") . "</h2>" . EOL. EOL;
$o .= visible_lf($bbcode) . EOL. EOL;
$diaspora = bb2diaspora($text);
$o .= t("bb2md: ") . EOL. EOL;
$o .= "<h2>" . t("bb2md: ") . "</h2>" . EOL. EOL;
$o .= visible_lf($diaspora) . EOL. EOL;
$html = Markdown($diaspora);
$o .= t("bb2md2html: ") . EOL. EOL;
$o .= "<h2>" . t("bb2md2html: ") . "</h2>" . EOL. EOL;
$o .= $html. EOL. EOL;
$bbcode = diaspora2bb($diaspora);
$o .= t("bb2dia2bb: ") . EOL. EOL;
$o .= "<h2>" . t("bb2dia2bb: ") . "</h2>" . EOL. EOL;
$o .= visible_lf($bbcode) . EOL. EOL;
$bbcode = html2bbcode($html);
$o .= t("bb2md2html2bb: ") . EOL. EOL;
$o .= "<h2>" . t("bb2md2html2bb: ") . "</h2>" . EOL. EOL;
$o .= visible_lf($bbcode) . EOL. EOL;
@ -62,12 +66,12 @@ function babel_content(&$a) {
if(x($_REQUEST,'d2bbtext')) {
$d2bbtext = trim($_REQUEST['d2bbtext']);
$o .= t("Source input (Diaspora format): ") . EOL. EOL;
$o .= "<h2>" . t("Source input (Diaspora format): ") . "</h2>" . EOL. EOL;
$o .= visible_lf($d2bbtext) . EOL. EOL;
$bb = diaspora2bb($d2bbtext);
$o .= t("diaspora2bb: ") . EOL. EOL;
$o .= "<h2>" . t("diaspora2bb: ") . "</h2>" . EOL. EOL;
$o .= visible_lf($bb) . EOL. EOL;
}


+ 0
- 2
mod/parse_url.php View File

@ -236,8 +236,6 @@ function parse_url_content(&$a) {
$str_tags = '';
$textmode = false;
if(local_user() && intval(get_pconfig(local_user(),'system','plaintext')))
$textmode = true;
if(local_user() && (! feature_enabled(local_user(),'richtext')))
$textmode = true;


+ 6
- 1
mod/wall_upload.php View File

@ -160,7 +160,12 @@ function wall_upload_post(&$a) {
//if we get the signal then return the image url info in BBCODE, otherwise this outputs the info and bails (for the ajax image uploader on wall post)
if ($_REQUEST['hush']!='yeah') {
echo "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]\n\n";
if(local_user() && (! feature_enabled(local_user(),'richtext') || x($_REQUEST['nomce'])) ) {
echo "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]\n\n";
}
else {
echo '<br /><br /><a href="' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '" ><img src="' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."\" alt=\"$basename\" /></a><br /><br />";
}
}
else {
$m = '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]";


+ 8
- 3
mods/friendica-to-smarty-tpl.py View File

@ -10,6 +10,8 @@ import sys, getopt
ldelim = '{{'
rdelim = '}}'
addheader = True
def fToSmarty(matches):
match = matches.group(0)
if match == '$j':
@ -94,8 +96,9 @@ def fix_element(element):
def convert(filename, tofilename, php_tpl):
header = ldelim + "*\n *\tAUTOMATICALLY GENERATED TEMPLATE\n *\tDO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN\n *\n *" + rdelim + "\n"
tofilename.write(header)
if addheader:
header = ldelim + "*\n *\tAUTOMATICALLY GENERATED TEMPLATE\n *\tDO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN\n *\n *" + rdelim + "\n"
tofilename.write(header)
for line in filename:
newline = ''
@ -190,13 +193,15 @@ def help(pname):
path = ''
try:
opts, args = getopt.getopt(sys.argv[1:], "hp:")
opts, args = getopt.getopt(sys.argv[1:], "hp:", ['no-header'])
for opt, arg in opts:
if opt == '-h':
help(sys.argv[0])
sys.exit()
elif opt == '-p':
path = arg
elif opt == '--no-header':
addheader = False
except getopt.GetoptError:
help(sys.argv[0])
sys.exit(2)


+ 1
- 2
view/smarty3/voting_fakelink.tpl View File

@ -3,5 +3,4 @@
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
*
*}}
<span class="fakelink" onclick="openClose('{{$vote_id}}');">{{$count}} {{$people}}</span> {{$vote_mood}}<br />
{{$phrase}}

+ 2
- 2
view/theme/frost-mobile/js/acl.js View File

@ -253,9 +253,9 @@ ACL.prototype.populate = function(data){
//console.log(html);
that.list_content.append(html);
});
$(".acl-list-item[rel!=acl-template] img[data-src]").each(function(i, el){
$j(".acl-list-item img[data-src]", that.list_content).each(function(i, el){
// Add src attribute for images with a data-src attribute
$(el).attr('src', $(el).data("src"));
$j(el).attr('src', $j(el).data("src"));
});
that.update_view();
}


+ 1
- 1
view/theme/frost-mobile/js/acl.min.js
File diff suppressed because it is too large
View File


+ 2
- 2
view/theme/frost-mobile/js/main.js View File

@ -188,9 +188,9 @@
nnm.append(html);
});
$("img[data-src]", nnm).each(function(i, el){
$j("img[data-src]", nnm).each(function(i, el){
// Add src attribute for images with a data-src attribute
$(el).attr('src', $(el).data("src"));
$j(el).attr('src', $j(el).data("src"));
});
}
notif = eNotif.attr('count');


+ 1
- 1
view/theme/frost-mobile/js/main.min.js
File diff suppressed because it is too large
View File


+ 1
- 2
view/theme/frost-mobile/smarty3/voting_fakelink.tpl View File

@ -3,5 +3,4 @@
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
*
*}}
<span class="fakelink-wrapper" id={{$vote_id}}-wrapper><span class="fakelink" onclick="openClose('{{$vote_id}}');">{{$count}} {{$people}}</span> {{$vote_mood}}</span>
<span class="fakelink-wrapper" id="{{$type}}list-{{$id}}-wrapper">{{$phrase}}</span>

+ 1
- 2
view/theme/frost-mobile/voting_fakelink.tpl View File

@ -1,2 +1 @@
<span class="fakelink-wrapper" id=$vote_id-wrapper><span class="fakelink" onclick="openClose('$vote_id');">$count $people</span> $vote_mood</span>
<span class="fakelink-wrapper" id="$[type]list-$id-wrapper">$phrase</span>

+ 1
- 0
view/theme/frost/acl_selector.tpl View File

@ -9,6 +9,7 @@
</div>
<div class="acl-list-item" rel="acl-template" style="display:none">
<img data-src="{0}"><p>{1}</p>
<a href="#" class='acl-button-show'>$show</a>
<a href="#" class='acl-button-hide'>$hide</a>
</div>


+ 2
- 2
view/theme/frost/js/acl.js View File

@ -253,9 +253,9 @@ ACL.prototype.populate = function(data){
//console.log(html);
that.list_content.append(html);
});
$(".acl-list-item[rel!=acl-template] img[data-src]").each(function(i, el){
$j(".acl-list-item img[data-src]", that.list_content).each(function(i, el){
// Add src attribute for images with a data-src attribute
$(el).attr('src', $(el).data("src"));
$j(el).attr('src', $j(el).data("src"));
});
that.update_view();
}


+ 1
- 1
view/theme/frost/js/acl.min.js
File diff suppressed because it is too large
View File


+ 2
- 2
view/theme/frost/js/main.js View File

@ -180,9 +180,9 @@
nnm.append(html);
});
$("img[data-src]", nnm).each(function(i, el){
$j("img[data-src]", nnm).each(function(i, el){
// Add src attribute for images with a data-src attribute
$(el).attr('src', $(el).data("src"));
$j(el).attr('src', $j(el).data("src"));
});
}
notif = eNotif.attr('count');


+ 1
- 1
view/theme/frost/js/main.min.js
File diff suppressed because it is too large
View File


+ 1
- 0
view/theme/frost/smarty3/acl_selector.tpl View File

@ -14,6 +14,7 @@
</div>
<div class="acl-list-item" rel="acl-template" style="display:none">
<img data-src="{0}"><p>{1}</p>
<a href="#" class='acl-button-show'>{{$show}}</a>
<a href="#" class='acl-button-hide'>{{$hide}}</a>
</div>


+ 1
- 2
view/theme/frost/smarty3/voting_fakelink.tpl View File

@ -3,5 +3,4 @@
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
*
*}}
<span class="fakelink-wrapper" id={{$vote_id}}-wrapper><span class="fakelink" onclick="openClose('{{$vote_id}}');">{{$count}} {{$people}}</span> {{$vote_mood}}</span>
<span class="fakelink-wrapper" id="{{$type}}list-{{$id}}-wrapper">{{$phrase}}</span>

+ 1
- 2
view/theme/frost/voting_fakelink.tpl View File

@ -1,2 +1 @@
<span class="fakelink-wrapper" id=$vote_id-wrapper><span class="fakelink" onclick="openClose('$vote_id');">$count $people</span> $vote_mood</span>
<span class="fakelink-wrapper" id="$[type]list-$id-wrapper">$phrase</span>

+ 1
- 2
view/voting_fakelink.tpl View File

@ -1,2 +1 @@
<span class="fakelink" onclick="openClose('$vote_id');">$count $people</span> $vote_mood<br />
$phrase

Loading…
Cancel
Save