Merge pull request #788 from annando/master

Infinite scroll, "new share" is now standard
This commit is contained in:
tobiasd 2013-10-20 06:04:25 -07:00
commit c308bb9042
18 changed files with 143 additions and 46 deletions

View File

@ -92,5 +92,5 @@ $a->config['system']['lockpath'] = "";
// If enabled, the MyBB fulltext engine is used
// $a->config['system']['use_fulltext_engine'] = true;
// Use the new "share" element
// $a->config['system']['new_share'] = true;
// Use the old style "share"
// $a->config['system']['old_share'] = false;

View File

@ -984,7 +984,7 @@
);
if ($r[0]['body'] != "") {
if (intval(get_config('system','new_share'))) {
if (!intval(get_config('system','old_share'))) {
$post = "[share author='".str_replace("'", "'", $r[0]['reply_author']).
"' profile='".$r[0]['reply_url'].
"' avatar='".$r[0]['reply_photo'].

View File

@ -343,15 +343,15 @@ function bb_ShareAttributesSimple2($match) {
function GetProfileUsername($profile, $username) {
$friendica = preg_replace("=https?://(.*)/profile/(.*)=ism", "$2@$1", $profile);
if ($friendica != $profile)
return($friendica);
return($friendica." (".$username.")");
$diaspora = preg_replace("=https?://(.*)/u/(.*)=ism", "$2@$1", $profile);
if ($diaspora != $profile)
return($diaspora);
return($diaspora." (".$username.")");
$twitter = preg_replace("=https?://twitter.com/(.*)=ism", "$1@twitter.com", $profile);
if ($twitter != $profile)
return($twitter);
return($twitter." (".$username.")");
$StatusnetHost = preg_replace("=https?://(.*)/user/(.*)=ism", "$1", $profile);
if ($StatusnetHost != $profile) {
@ -360,7 +360,7 @@ function GetProfileUsername($profile, $username) {
$UserData = fetch_url("http://".$StatusnetHost."/api/users/show.json?user_id=".$StatusnetUser);
$user = json_decode($UserData);
if ($user)
return($user->screen_name."@".$StatusnetHost);
return($user->screen_name."@".$StatusnetHost." (".$username.")");
}
}

View File

@ -1040,7 +1040,7 @@ function diaspora_reshare($importer,$xml,$msg) {
$datarray['owner-name'] = $contact['name'];
$datarray['owner-link'] = $contact['url'];
$datarray['owner-avatar'] = ((x($contact,'thumb')) ? $contact['thumb'] : $contact['photo']);
if (intval(get_config('system','new_share'))) {
if (!intval(get_config('system','wall-to-wall_share'))) {
$prefix = "[share author='".str_replace("'", "'",$person['name']).
"' profile='".$person['url'].
"' avatar='".((x($person,'thumb')) ? $person['thumb'] : $person['photo']).

View File

@ -82,13 +82,19 @@ function collecturls($message) {
$urls = array();
foreach ($result as $treffer) {
$ignore = false;
// A list of some links that should be ignored
$list = array("/user/", "/tag/", "/group/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/",
"//facebook.com/profile.php?id=", "//plus.google.com/");
"//facebook.com/profile.php?id=", "//plus.google.com/", "//twitter.com/");
foreach ($list as $listitem)
if (strpos($treffer[1], $listitem) !== false)
$ignore = true;
if ((strpos($treffer[1], "//twitter.com/") !== false) and (strpos($treffer[1], "/status/") !== false))
$ignore = false;
if ((strpos($treffer[1], "//plus.google.com/") !== false) and (strpos($treffer[1], "/posts") !== false))
$ignore = false;

View File

@ -811,7 +811,7 @@ function get_atom_elements($feed,$item) {
if (($name != "") and ($uri != "") and ($avatar != "") and ($message != "")) {
logger('get_atom_elements: fixing sender of repeated message.');
if (intval(get_config('system','new_share'))) {
if (!intval(get_config('system','wall-to-wall_share'))) {
$prefix = "[share author='".str_replace("'", "'",$name).
"' profile='".$uri.
"' avatar='".$avatar.

View File

@ -108,6 +108,7 @@ if((x($_GET,'zrl')) && (!$install && !$maintenance)) {
*
* What we really need to do is output the raw headers ourselves so we can keep them separate.
*
*/
// header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";');
@ -118,7 +119,6 @@ if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module ==
if(! x($_SESSION,'authenticated'))
header('X-Account-Management-Status: none');
/* set up page['htmlhead'] and page['end'] for the modules to use */
$a->page['htmlhead'] = '';
$a->page['end'] = '';
@ -428,6 +428,83 @@ else
$a->page['htmlhead'] = str_replace('{{$stylesheet}}',$stylesheet,$a->page['htmlhead']);
//$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => $stylesheet));
if ($_GET["mode"] == "raw") {
$doc = new DOMDocument();
$target = new DOMDocument();
$target->loadXML("<root></root>");
$content = mb_convert_encoding($a->page["content"], 'HTML-ENTITIES', "UTF-8");
@$doc->loadHTML($content);
$xpath = new DomXPath($doc);
$list = $xpath->query("//*[contains(@id,'tread-wrapper-')]"); /* */
foreach ($list as $item) {
$item = $target->importNode($item, true);
// And then append it to the target
$target->documentElement->appendChild($item);
}
header("Content-type: text/html; charset=utf-8");
echo substr($target->saveHTML(), 6, -8);
session_write_close();
exit;
} elseif (get_pconfig(local_user(),'system','infinite_scroll') AND ($_GET["q"] == "network")) {
if (is_string($_GET["page"]))
$pageno = $_GET["page"];
else
$pageno = 1;
$reload_uri = "";
foreach ($_GET AS $param => $value)
if (($param != "page") AND ($param != "q"))
$reload_uri .= "&".$param."=".$value;
$a->page['htmlhead'] .= <<< EOT
<script type="text/javascript">
$(document).ready(function() {
num = $pageno;
});
function loadcontent() {
//$("div.loader").show();
num+=1;
console.log('Loading page ' + num);
$.get('/network?mode=raw$reload_uri&page=' + num, function(data) {
$(data).insertBefore('#conversation-end');
});
//$("div.loader").fadeOut('normal');
}
var num = $pageno;
$(window).scroll(function(e){
//if ($(window).scrollTop() == $(document).height() - $(window).height()){
if ($(window).scrollTop() > $("section").height() - $(window).height()){
loadcontent();
}
});
</script>
EOT;
}
$page = $a->page;
$profile = $a->profile;

View File

@ -282,7 +282,7 @@ function admin_page_site_post(&$a){
$ostatus_poll_interval = ((x($_POST,'ostatus_poll_interval')) ? intval(trim($_POST['ostatus_poll_interval'])) : 0);
$diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False);
$ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0);
$new_share = ((x($_POST,'new_share')) ? True : False);
$old_share = ((x($_POST,'old_share')) ? True : False);
$hide_help = ((x($_POST,'hide_help')) ? True : False);
$use_fulltext_engine = ((x($_POST,'use_fulltext_engine')) ? True : False);
$itemcache = ((x($_POST,'itemcache')) ? notags(trim($_POST['itemcache'])) : '');
@ -398,7 +398,7 @@ function admin_page_site_post(&$a){
set_config('system','diaspora_enabled', $diaspora_enabled);
set_config('config','private_addons', $private_addons);
set_config('system','new_share', $new_share);
set_config('system','old_share', $old_share);
set_config('system','hide_help', $hide_help);
set_config('system','use_fulltext_engine', $use_fulltext_engine);
set_config('system','itemcache', $itemcache);
@ -508,7 +508,7 @@ function admin_page_site(&$a) {
'$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices),
'$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile-theme'), t("Theme for mobile devices"), $theme_choices_mobile),
'$ssl_policy' => array('ssl_policy', t("SSL link policy"), (string) intval(get_config('system','ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices),
'$new_share' => array('new_share', t("'Share' element"), get_config('system','new_share'), t("Activates the bbcode element 'share' for repeating items.")),
'$old_share' => array('old_share', t("Old style 'Share'"), get_config('system','old_share'), t("Deactivates the bbcode element 'share' for repeating items.")),
'$hide_help' => array('hide_help', t("Hide help entry from navigation menu"), get_config('system','hide_help'), t("Hides the menu entry for the Help pages from the navigation menu. You can still access it calling /help directly.")),
'$singleuser' => array('singleuser', t("Single user instance"), get_config('system','singleuser'), t("Make this instance multi-user or single-user for the named user"), $user_names),
'$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),

View File

@ -174,8 +174,6 @@ function network_init(&$a) {
);
}
// search terms header
if(x($_GET,'search')) {
$a->page['content'] .= '<h2>' . t('Search Results For:') . ' ' . $search . '</h2>';
@ -225,9 +223,9 @@ function saved_searches($search) {
'selected' => ($search==$rr['term']),
);
}
}
}
$tpl = get_markup_template("saved_searches_aside.tpl");
$o = replace_macros($tpl, array(
'$title' => t('Saved Searches'),
@ -235,7 +233,7 @@ function saved_searches($search) {
'$searchbox' => search($search,'netsearch-box',$srchurl,true),
'$saved' => $saved,
));
return $o;
}
@ -270,15 +268,15 @@ function network_query_get_sel_tab($a) {
|| ($a->argc > 2 && $a->argv[2] === 'new')) {
$new_active = 'active';
}
if(x($_GET,'search')) {
$search_active = 'active';
}
if(x($_GET,'star')) {
$starred_active = 'active';
}
if(x($_GET,'bmark')) {
$bookmarked_active = 'active';
}
@ -291,8 +289,8 @@ function network_query_get_sel_tab($a) {
$spam_active = 'active';
}
if (($new_active == '')
&& ($starred_active == '')
&& ($bookmarked_active == '')
@ -308,7 +306,7 @@ function network_query_get_sel_tab($a) {
case 'comment' : $all_active = 'active'; $no_active=''; break;
}
}
return array($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active);
}
@ -571,7 +569,6 @@ function network_content(&$a, $update = 0) {
// that belongs to you, hence you can see all of it. We will filter by group if
// desired.
$sql_options = (($star) ? " and starred = 1 " : '');
$sql_options .= (($bmark) ? " and bookmark = 1 " : '');
@ -641,6 +638,7 @@ function network_content(&$a, $update = 0) {
$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
$sql_order = "`item`.`received`";
$sql_table = "`item`";
if(x($_GET,'search')) {
@ -675,11 +673,15 @@ function network_content(&$a, $update = 0) {
$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
$sql_order = "`term`.`tid`";
} else {
if (get_config('system','use_fulltext_engine'))
$sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
else
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
$sql_order = "`item`.`received`";
}
}
if(strlen($file)) {
@ -767,7 +769,7 @@ function network_content(&$a, $update = 0) {
$simple_update
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$sql_extra $sql_nets
ORDER BY `item`.`received` DESC $pager_sql ",
ORDER BY $sql_order DESC $pager_sql ",
intval($_SESSION['uid'])
);
@ -783,6 +785,9 @@ function network_content(&$a, $update = 0) {
else
$ordering = "`commented`";
if ($sql_order == "")
$sql_order = "`item`.$ordering";
// Fetch a page full of parent items for this page
if($update) {
@ -803,7 +808,7 @@ function network_content(&$a, $update = 0) {
AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`parent` = `item`.`id`
$sql_extra3 $sql_extra $sql_nets
ORDER BY `item`.$ordering DESC $pager_sql ",
ORDER BY $sql_order DESC $pager_sql ",
intval(local_user())
);
}
@ -874,7 +879,7 @@ function network_content(&$a, $update = 0) {
$o .= conversation($a,$items,$mode,$update);
if(! $update) {
if(!$update) {
if( get_config('alt_pager', 'global') || get_pconfig(local_user(),'system','alt_pager') ) {
$o .= alt_pager($a,count($items));
}

View File

@ -59,7 +59,7 @@ function parseurl_getsiteinfo($url) {
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch,CURLOPT_USERAGENT,'Opera/9.64(Windows NT 5.1; U; de) Presto/2.1.1');
curl_setopt($ch,CURLOPT_USERAGENT,' Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0');
$header = curl_exec($ch);
$curl_info = @curl_getinfo($ch);

View File

@ -144,6 +144,8 @@ function search_content(&$a) {
$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d group by `item`.`uri` ",
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
$sql_order = "`term`.`tid`";
//$sql_order = "`item`.`received`";
//$sql_extra = sprintf(" AND EXISTS (SELECT * FROM `term` WHERE `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d) GROUP BY `item`.`uri` ",
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
@ -155,6 +157,7 @@ function search_content(&$a) {
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
}
$sql_table = "`item`";
$sql_order = "`item`.`received`";
}
// Here is the way permissions work in the search module...
@ -195,7 +198,7 @@ function search_content(&$a) {
OR ( `item`.`uid` = %d ))
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$sql_extra
ORDER BY `received` DESC LIMIT %d , %d ",
ORDER BY $sql_order DESC LIMIT %d , %d ",
intval(local_user()),
intval($a->pager['start']),
intval($a->pager['itemspage'])
@ -209,7 +212,7 @@ function search_content(&$a) {
}
if($tag)
if($tag)
$o .= '<h2>Items tagged with: ' . $search . '</h2>';
else
$o .= '<h2>Search results for: ' . $search . '</h2>';

View File

@ -259,7 +259,8 @@ function settings_post(&$a) {
$theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : $a->user['theme']);
$mobile_theme = ((x($_POST,'mobile_theme')) ? notags(trim($_POST['mobile_theme'])) : '');
$nosmile = ((x($_POST,'nosmile')) ? intval($_POST['nosmile']) : 0);
$nosmile = ((x($_POST,'nosmile')) ? intval($_POST['nosmile']) : 0);
$infinite_scroll = ((x($_POST,'infinite_scroll')) ? intval($_POST['infinite_scroll']) : 0);
$browser_update = ((x($_POST,'browser_update')) ? intval($_POST['browser_update']) : 0);
$browser_update = $browser_update * 1000;
if($browser_update < 10000)
@ -281,6 +282,7 @@ function settings_post(&$a) {
set_pconfig(local_user(),'system','itemspage_network', $itemspage_network);
set_pconfig(local_user(),'system','itemspage_mobile_network', $itemspage_mobile_network);
set_pconfig(local_user(),'system','no_smilies',$nosmile);
set_pconfig(local_user(),'system','infinite_scroll',$infinite_scroll);
if ($theme == $a->user['theme']){
@ -816,7 +818,7 @@ function settings_content(&$a) {
}
$theme_selected = (!x($_SESSION,'theme')? $default_theme : $_SESSION['theme']);
$mobile_theme_selected = (!x($_SESSION,'mobile-theme')? $default_mobile_theme : $_SESSION['mobile-theme']);
$browser_update = intval(get_pconfig(local_user(), 'system','update_interval'));
$browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
@ -824,17 +826,19 @@ function settings_content(&$a) {
$itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : 40); // default if not set: 40 items
$itemspage_mobile_network = intval(get_pconfig(local_user(), 'system','itemspage_mobile_network'));
$itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : 20); // default if not set: 20 items
$nosmile = get_pconfig(local_user(),'system','no_smilies');
$nosmile = (($nosmile===false)? '0': $nosmile); // default if not set: 0
$infinite_scroll = get_pconfig(local_user(),'system','infinite_scroll');
$infinite_scroll = (($infinite_scroll===false)? '0': $infinite_scroll); // default if not set: 0
$theme_config = "";
if( ($themeconfigfile = get_theme_config_file($theme_selected)) != null){
require_once($themeconfigfile);
$theme_config = theme_content($a);
}
$tpl = get_markup_template("settings_display.tpl");
$o = replace_macros($tpl, array(
'$ptitle' => t('Display Settings'),
@ -842,17 +846,18 @@ function settings_content(&$a) {
'$submit' => t('Submit'),
'$baseurl' => $a->get_baseurl(true),
'$uid' => local_user(),
'$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes, true),
'$mobile_theme' => array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false),
'$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')),
'$itemspage_network' => array('itemspage_network', t("Number of items to display per page:"), $itemspage_network, t('Maximum of 100 items')),
'$itemspage_mobile_network' => array('itemspage_mobile_network', t("Number of items to display per page when viewed from mobile device:"), $itemspage_mobile_network, t('Maximum of 100 items')),
'$nosmile' => array('nosmile', t("Don't show emoticons"), $nosmile, ''),
'$infinite_scroll' => array('infinite_scroll', t("Infinite scroll"), $infinite_scroll, ''),
'$theme_config' => $theme_config,
));
$tpl = get_markup_template("settings_display_end.tpl");
$a->page['end'] .= replace_macros($tpl, array(
'$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes)
@ -860,8 +865,8 @@ function settings_content(&$a) {
return $o;
}
/*
* ACCOUNT SETTINGS
*/

View File

@ -18,7 +18,7 @@ function share_init(&$a) {
if(! count($r) || ($r[0]['private'] == 1))
killme();
if (intval(get_config('system','new_share'))) {
if (!intval(get_config('system','old_share'))) {
if (strpos($r[0]['body'], "[/share]") !== false) {
$pos = strpos($r[0]['body'], "[share");
$o = substr($r[0]['body'], $pos);

View File

@ -55,7 +55,7 @@
{{include file="field_select.tpl" field=$theme}}
{{include file="field_select.tpl" field=$theme_mobile}}
{{include file="field_select.tpl" field=$ssl_policy}}
{{include file="field_checkbox.tpl" field=$new_share}}
{{include file="field_checkbox.tpl" field=$old_share}}
{{include file="field_checkbox.tpl" field=$hide_help}}
{{include file="field_select.tpl" field=$singleuser}}

View File

@ -14,6 +14,7 @@
{{include file="field_input.tpl" field=$itemspage_mobile_network}}
{{include file="field_input.tpl" field=$ajaxint}}
{{include file="field_checkbox.tpl" field=$nosmile}}
{{include file="field_checkbox.tpl" field=$infinite_scroll}}
<div class="settings-submit-wrapper" >

View File

@ -16,7 +16,7 @@
{{include file="field_select.tpl" field=$theme}}
{{include file="field_select.tpl" field=$theme_mobile}}
{{include file="field_select.tpl" field=$ssl_policy}}
{{include file="field_checkbox.tpl" field=$new_share}}
{{include file="field_checkbox.tpl" field=$old_share}}
{{include file="field_checkbox.tpl" field=$hide_help}}
{{include file="field_select.tpl" field=$singleuser}}

View File

@ -16,7 +16,7 @@
{{include file="field_select.tpl" field=$theme}}
{{include file="field_select.tpl" field=$theme_mobile}}
{{include file="field_select.tpl" field=$ssl_policy}}
{{include file="field_checkbox.tpl" field=$new_share}}
{{include file="field_checkbox.tpl" field=$old_share}}
{{include file="field_checkbox.tpl" field=$hide_help}}
{{include file="field_select.tpl" field=$singleuser}}

View File

@ -16,7 +16,7 @@
{{include file="field_select.tpl" field=$theme}}
{{include file="field_select.tpl" field=$theme_mobile}}
{{include file="field_select.tpl" field=$ssl_policy}}
{{include file="field_checkbox.tpl" field=$new_share}}
{{include file="field_checkbox.tpl" field=$old_share}}
{{include file="field_checkbox.tpl" field=$hide_help}}
{{include file="field_select.tpl" field=$singleuser}}