* @return int|bool user id or false
*/
function local_user() {
- if((x($_SESSION,'authenticated')) && (x($_SESSION,'uid')))
+ if (x($_SESSION, 'authenticated') && x($_SESSION, 'uid')) {
return intval($_SESSION['uid']);
+ }
return false;
}
+/**
+ * @brief Returns the public contact id of logged in user or false.
+ *
+ * @return int|bool public contact id or false
+ */
+function public_contact() {
+ static $public_contact_id = false;
+
+ if (!$public_contact_id && x($_SESSION, 'authenticated')) {
+ if (x($_SESSION, 'my_address')) {
+ // Local user
+ $public_contact_id = intval(get_contact($_SESSION['my_address'], 0));
+ } else if (x($_SESSION, 'visitor_home')) {
+ // Remote user
+ $public_contact_id = intval(get_contact($_SESSION['visitor_home'], 0));
+ }
+ } else if (!x($_SESSION, 'authenticated')) {
+ $public_contact_id = false;
+ }
+
+ return $public_contact_id;
+}
+
/**
* @brief Returns contact id of authenticated site visitor or false
*
);
if ($r[0]['body'] != "") {
- if (!intval(get_config('system','old_share'))) {
- if (strpos($r[0]['body'], "[/share]") !== false) {
- $pos = strpos($r[0]['body'], "[share");
- $post = substr($r[0]['body'], $pos);
- } else {
- $post = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
-
- $post .= $r[0]['body'];
- $post .= "[/share]";
- }
- $_REQUEST['body'] = $post;
- } else
- $_REQUEST['body'] = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')."[url=".$r[0]['reply_url']."]".$r[0]['reply_author']."[/url] \n".$r[0]['body'];
+ if (strpos($r[0]['body'], "[/share]") !== false) {
+ $pos = strpos($r[0]['body'], "[share");
+ $post = substr($r[0]['body'], $pos);
+ } else {
+ $post = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
+ $post .= $r[0]['body'];
+ $post .= "[/share]";
+ }
+ $_REQUEST['body'] = $post;
$_REQUEST['profile_uid'] = api_user();
$_REQUEST['type'] = 'wall';
$_REQUEST['api_source'] = true;
`item`.`shadow`,
*/
- return "`item`.`author-link`, `item`.`author-name`, `item`.`author-avatar`,
- `item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`,
+ return "`item`.`author-id`, `item`.`author-link`, `item`.`author-name`, `item`.`author-avatar`,
+ `item`.`owner-id`, `item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`,
`item`.`contact-id`, `item`.`uid`, `item`.`id`, `item`.`parent`,
`item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`,
`item`.`commented`, `item`.`created`, `item`.`edited`,
else
$conv_responses[$mode][$item['thr-parent']] ++;
- if((local_user()) && (local_user() == $item['uid']) && ($item['self']))
+ if (public_contact() == $item['author-id']) {
$conv_responses[$mode][$item['thr-parent'] . '-self'] = 1;
+ }
$conv_responses[$mode][$item['thr-parent'] . '-l'][] = $url;
function do_like($item_id, $verb) {
$a = get_app();
- if(! local_user() && ! remote_user()) {
+ if (! local_user() && ! remote_user()) {
return false;
}
- switch($verb) {
+ switch ($verb) {
case 'like':
+ $bodyverb = t('%1$s likes %2$s\'s %3$s');
+ $activity = ACTIVITY_LIKE;
+ break;
case 'unlike':
+ $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
$activity = ACTIVITY_LIKE;
break;
case 'dislike':
case 'undislike':
+ $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
$activity = ACTIVITY_DISLIKE;
break;
case 'attendyes':
case 'unattendyes':
+ $bodyverb = t('%1$s is attending %2$s\'s %3$s');
$activity = ACTIVITY_ATTEND;
break;
case 'attendno':
case 'unattendno':
+ $bodyverb = t('%1$s is not attending %2$s\'s %3$s');
$activity = ACTIVITY_ATTENDNO;
break;
case 'attendmaybe':
case 'unattendmaybe':
+ $bodyverb = t('%1$s may attend %2$s\'s %3$s');
$activity = ACTIVITY_ATTENDMAYBE;
break;
default:
+ logger('like: unknown verb ' . $verb . ' for item ' . $item_id);
return false;
- break;
}
+ // Enable activity toggling instead of on/off
+ $event_verb_flag = $activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE;
+
logger('like: verb ' . $verb . ' item ' . $item_id);
- $r = q("SELECT * FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
+ // Retrieve item
+ $items = q("SELECT * FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
dbesc($item_id),
dbesc($item_id)
);
- if(! $item_id || (! dbm::is_result($r))) {
- logger('like: no item ' . $item_id);
+ if (! $item_id || ! dbm::is_result($items)) {
+ logger('like: unknown item ' . $item_id);
return false;
}
- $item = $r[0];
-
- $owner_uid = $item['uid'];
+ $item = $items[0];
- if (! can_write_wall($a,$owner_uid)) {
+ if (! can_write_wall($a, $item['uid'])) {
+ logger('like: unable to write on wall ' . $item['uid']);
return false;
}
- $remote_owner = null;
-
- if(! $item['wall']) {
- // The top level post may have been written by somebody on another system
- $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($item['contact-id']),
- intval($item['uid'])
- );
- if (! dbm::is_result($r)) {
- return false;
- }
- if (! $r[0]['self']) {
- $remote_owner = $r[0];
- }
+ // Retrieves the local post owner
+ $owners = q("SELECT `contact`.* FROM `contact`
+ WHERE `contact`.`self` = 1
+ AND `contact`.`uid` = %d",
+ intval($item['uid'])
+ );
+ if (dbm::is_result($owners)) {
+ $owner_self_contact = $owners[0];
+ } else {
+ logger('like: unknown owner ' . $item['uid']);
+ return false;
}
- // this represents the post owner on this system.
+ // Retrieve the current logged in user's public contact
+ $author_id = public_contact();
- $r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
- WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
- intval($owner_uid)
+ $contacts = q("SELECT * FROM `contact` WHERE `id` = %d",
+ intval($author_id)
);
- if (dbm::is_result($r)) {
- $owner = $r[0];
- }
-
- if (! $owner) {
- logger('like: no owner');
+ if (dbm::is_result($contacts)) {
+ $author_contact = $contacts[0];
+ } else {
+ logger('like: unknown author ' . $author_id);
return false;
}
- if (! $remote_owner) {
- $remote_owner = $owner;
- }
-
- // This represents the person posting
-
- if ((local_user()) && (local_user() == $owner_uid)) {
- $contact = $owner;
+ // Contact-id is the uid-dependant author contact
+ if (local_user() == $item['uid']) {
+ $item_contact_id = $owner_self_contact['id'];
+ $item_contact = $owner_self_contact;
} else {
- $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($_SESSION['visitor_id']),
- intval($owner_uid)
+ $item_contact_id = get_contact($author_contact['url'], $item['uid']);
+
+ $contacts = q("SELECT * FROM `contact` WHERE `id` = %d",
+ intval($item_contact_id)
);
- if (dbm::is_result($r)) {
- $contact = $r[0];
+ if (dbm::is_result($contacts)) {
+ $item_contact = $contacts[0];
+ } else {
+ logger('like: unknown item contact ' . $item_contact_id);
+ return false;
}
}
- if (! $contact) {
- return false;
- }
-
-
- $verbs = " '".dbesc($activity)."' ";
+ // Look for an existing verb row
// event participation are essentially radio toggles. If you make a subsequent choice,
// we need to eradicate your first choice.
- if ($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
- $verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' ";
- }
-
- $r = q("SELECT `id`, `guid` FROM `item` WHERE `verb` IN ( $verbs ) AND `deleted` = 0
- AND `contact-id` = %d AND `uid` = %d
- AND (`parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s') LIMIT 1",
- intval($contact['id']), intval($owner_uid),
+ if ($event_verb_flag) {
+ $verbs = "'" . dbesc(ACTIVITY_ATTEND) . "', '" . dbesc(ACTIVITY_ATTENDNO) . "', '" . dbesc(ACTIVITY_ATTENDMAYBE) . "'";
+ } else {
+ $verbs = "'".dbesc($activity)."'";
+ }
+
+ $existing_like = q("SELECT `id`, `guid`, `verb` FROM `item`
+ WHERE `verb` IN ($verbs)
+ AND `deleted` = 0
+ AND `author-id` = %d
+ AND `uid` = %d
+ AND (`parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s')
+ LIMIT 1",
+ intval($author_contact['id']),
+ intval($item['uid']),
dbesc($item_id), dbesc($item_id), dbesc($item['uri'])
);
- if (dbm::is_result($r)) {
- $like_item = $r[0];
+ // If it exists, mark it as deleted
+ if (dbm::is_result($existing_like)) {
+ $like_item = $existing_like[0];
// Already voted, undo it
- $r = q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `id` = %d",
+ q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()),
intval($like_item['id'])
);
-
// Clean up the Diaspora signatures for this like
// Go ahead and do it even if Diaspora support is disabled. We still want to clean up
// if it had been enabled in the past
- $r = q("DELETE FROM `sign` WHERE `iid` = %d",
+ q("DELETE FROM `sign` WHERE `iid` = %d",
intval($like_item['id'])
);
$like_item_id = $like_item['id'];
proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $like_item_id);
- return true;
+ if (!$event_verb_flag || $like_item['verb'] == $activity) {
+ return true;
+ }
}
- $uri = item_new_uri($a->get_hostname(),$owner_uid);
+ // Verb is "un-something", just trying to delete existing entries
+ if (strpos($verb, 'un') === 0) {
+ return true;
+ }
+ // Else or if event verb different from existing row, create a new item row
$post_type = (($item['resource-id']) ? t('photo') : t('status'));
if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$post_type = t('event');
}
- $objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
- $link = xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
+ $objtype = $item['resource-id'] ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE ;
+ $link = xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/display/' . $owner_self_contact['nick'] . '/' . $item['id'] . '" />' . "\n") ;
$body = $item['body'];
$obj = <<< EOT
<content>$body</content>
</object>
EOT;
- if ($verb === 'like') {
- $bodyverb = t('%1$s likes %2$s\'s %3$s');
- }
- if ($verb === 'dislike') {
- $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
- }
- if ($verb === 'attendyes') {
- $bodyverb = t('%1$s is attending %2$s\'s %3$s');
- }
- if ($verb === 'attendno') {
- $bodyverb = t('%1$s is not attending %2$s\'s %3$s');
- }
- if ($verb === 'attendmaybe') {
- $bodyverb = t('%1$s may attend %2$s\'s %3$s');
- }
- if (! isset($bodyverb)) {
- return false;
- }
-
- $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
+ $ulink = '[url=' . $author_contact['url'] . ']' . $author_contact['name'] . '[/url]';
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
- $plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
-
- /// @TODO Or rewrite this to multi-line initialization of the array?
- $arr = array();
-
- $arr['guid'] = get_guid(32);
- $arr['uri'] = $uri;
- $arr['uid'] = $owner_uid;
- $arr['contact-id'] = $contact['id'];
- $arr['type'] = 'activity';
- $arr['wall'] = $item['wall'];
- $arr['origin'] = 1;
- $arr['gravity'] = GRAVITY_LIKE;
- $arr['parent'] = $item['id'];
- $arr['parent-uri'] = $item['uri'];
- $arr['thr-parent'] = $item['uri'];
- $arr['owner-name'] = $remote_owner['name'];
- $arr['owner-link'] = $remote_owner['url'];
- $arr['owner-avatar'] = $remote_owner['thumb'];
- $arr['author-name'] = $contact['name'];
- $arr['author-link'] = $contact['url'];
- $arr['author-avatar'] = $contact['thumb'];
- $arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
- $arr['verb'] = $activity;
- $arr['object-type'] = $objtype;
- $arr['object'] = $obj;
- $arr['allow_cid'] = $item['allow_cid'];
- $arr['allow_gid'] = $item['allow_gid'];
- $arr['deny_cid'] = $item['deny_cid'];
- $arr['deny_gid'] = $item['deny_gid'];
- $arr['visible'] = 1;
- $arr['unseen'] = 1;
- $arr['last-child'] = 0;
-
- $post_id = item_store($arr);
+ $plink = '[url=' . App::get_baseurl() . '/display/' . $owner_self_contact['nick'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
+
+ $new_item = array(
+ 'guid' => get_guid(32),
+ 'uri' => item_new_uri($a->get_hostname(), $item['uid']),
+ 'uid' => $item['uid'],
+ 'contact-id' => $item_contact_id,
+ 'type' => 'activity',
+ 'wall' => $item['wall'],
+ 'origin' => 1,
+ 'gravity' => GRAVITY_LIKE,
+ 'parent' => $item['id'],
+ 'parent-uri' => $item['uri'],
+ 'thr-parent' => $item['uri'],
+ 'owner-id' => $item['owner-id'],
+ 'owner-name' => $item['owner-name'],
+ 'owner-link' => $item['owner-link'],
+ 'owner-avatar' => $item['owner-avatar'],
+ 'author-id' => $author_contact['id'],
+ 'author-name' => $author_contact['name'],
+ 'author-link' => $author_contact['url'],
+ 'author-avatar' => $author_contact['thumb'],
+ 'body' => sprintf($bodyverb, $ulink, $alink, $plink),
+ 'verb' => $activity,
+ 'object-type' => $objtype,
+ 'object' => $obj,
+ 'allow_cid' => $item['allow_cid'],
+ 'allow_gid' => $item['allow_gid'],
+ 'deny_cid' => $item['deny_cid'],
+ 'deny_gid' => $item['deny_gid'],
+ 'visible' => 1,
+ 'unseen' => 1,
+ 'last-child' => 0
+ );
+
+ $new_item_id = item_store($new_item);
+ // @todo: Explain this block
if (! $item['visible']) {
- $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
+ q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
intval($item['id']),
- intval($owner_uid)
+ intval($item['uid'])
);
}
-
// Save the author information for the like in case we need to relay to Diaspora
- Diaspora::store_like_signature($contact, $post_id);
+ Diaspora::store_like_signature($item_contact, $new_item_id);
- $arr['id'] = $post_id;
+ $new_item['id'] = $new_item_id;
- call_hooks('post_local_end', $arr);
+ call_hooks('post_local_end', $new_item);
- proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $post_id);
+ proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $new_item_id);
return true;
}
}}
-if(! function_exists('paginate_data')) {
/**
- * Automatica pagination data.
+ * @brief Paginator function. Pushes relevant links in a pager array structure.
+ *
+ * Links are generated depending on the current page and the total number of items.
+ * Inactive links (like "first" and "prev" on page 1) are given the "disabled" class.
+ * Current page link is given the "active" CSS class
*
* @param App $a App instance
- * @param int $count [optional] item count (used with alt pager)
+ * @param int $count [optional] item count (used with minimal pager)
* @return Array data for pagination template
*/
-function paginate_data(App $a, $count=null) {
- $stripped = preg_replace('/([&?]page=[0-9]*)/','',$a->query_string);
+function paginate_data(App $a, $count = null) {
+ $stripped = preg_replace('/([&?]page=[0-9]*)/', '', $a->query_string);
- $stripped = str_replace('q=','',$stripped);
- $stripped = trim($stripped,'/');
+ $stripped = str_replace('q=', '', $stripped);
+ $stripped = trim($stripped, '/');
$pagenum = $a->pager['page'];
- if (($a->page_offset != "") AND !preg_match('/[?&].offset=/', $stripped))
- $stripped .= "&offset=".urlencode($a->page_offset);
+ if (($a->page_offset != '') AND !preg_match('/[?&].offset=/', $stripped)) {
+ $stripped .= '&offset=' . urlencode($a->page_offset);
+ }
$url = $stripped;
$data = array();
- function _l(&$d, $name, $url, $text, $class="") {
- if (!strpos($url, "?")) {
- if ($pos = strpos($url, "&"))
- $url = substr($url, 0, $pos)."?".substr($url, $pos + 1);
+ function _l(&$d, $name, $url, $text, $class = '') {
+ if (strpos($url, '?') === false && ($pos = strpos($url, '&')) !== false) {
+ $url = substr($url, 0, $pos) . '?' . substr($url, $pos + 1);
}
- $d[$name] = array('url'=>$url, 'text'=>$text, 'class'=>$class);
+ $d[$name] = array('url' => $url, 'text' => $text, 'class' => $class);
}
- if (!is_null($count)){
- // alt pager
- if($a->pager['page']>1)
- _l($data, "prev", $url.'&page='.($a->pager['page'] - 1), t('newer'));
- if($count>0)
- _l($data, "next", $url.'&page='.($a->pager['page'] + 1), t('older'));
+ if (!is_null($count)) {
+ // minimal pager (newer / older)
+ $data['class'] = 'pager';
+ _l($data, 'prev', $url . '&page=' . ($a->pager['page'] - 1), t('newer'), 'previous' . ($a->pager['page'] == 1 ? ' disabled' : ''));
+ _l($data, 'next', $url . '&page=' . ($a->pager['page'] + 1), t('older'), 'next' . ($count <= 0 ? ' disabled' : ''));
} else {
- // full pager
- if($a->pager['total'] > $a->pager['itemspage']) {
- if($a->pager['page'] != 1)
- _l($data, "prev", $url.'&page='.($a->pager['page'] - 1), t('prev'));
-
- _l($data, "first", $url."&page=1", t('first'));
-
+ // full pager (first / prev / 1 / 2 / ... / 14 / 15 / next / last)
+ $data['class'] = 'pagination';
+ if ($a->pager['total'] > $a->pager['itemspage']) {
+ _l($data, 'first', $url . '&page=1', t('first'), $a->pager['page'] == 1 ? 'disabled' : '');
+ _l($data, 'prev', $url . '&page=' . ($a->pager['page'] - 1), t('prev'), $a->pager['page'] == 1 ? 'disabled' : '');
$numpages = $a->pager['total'] / $a->pager['itemspage'];
$numstart = 1;
$numstop = $numpages;
- if($numpages > 14) {
+ if ($numpages > 14) {
$numstart = (($pagenum > 7) ? ($pagenum - 7) : 1);
$numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 14));
}
$pages = array();
- for($i = $numstart; $i <= $numstop; $i++){
- if($i == $a->pager['page'])
- _l($pages, $i, "#", $i, "current");
- else
- _l($pages, $i, $url."&page=$i", $i, "n");
+ for ($i = $numstart; $i <= $numstop; $i++) {
+ if ($i == $a->pager['page']) {
+ _l($pages, $i, '#', $i, 'current active');
+ } else {
+ _l($pages, $i, $url . '&page='. $i, $i, 'n');
+ }
}
- if(($a->pager['total'] % $a->pager['itemspage']) != 0) {
- if($i == $a->pager['page'])
- _l($pages, $i, "#", $i, "current");
- else
- _l($pages, $i, $url."&page=$i", $i, "n");
+ if (($a->pager['total'] % $a->pager['itemspage']) != 0) {
+ if ($i == $a->pager['page']) {
+ _l($pages, $i, '#', $i, 'current active');
+ } else {
+ _l($pages, $i, $url . '&page=' . $i, $i, 'n');
+ }
}
$data['pages'] = $pages;
$lastpage = (($numpages > intval($numpages)) ? intval($numpages)+1 : $numpages);
- _l($data, "last", $url."&page=$lastpage", t('last'));
-
- if(($a->pager['total'] - ($a->pager['itemspage'] * $a->pager['page'])) > 0)
- _l($data, "next", $url."&page=".($a->pager['page'] + 1), t('next'));
-
+ _l($data, 'next', $url . '&page=' . ($a->pager['page'] + 1), t('next'), $a->pager['page'] == $lastpage ? 'disabled' : '');
+ _l($data, 'last', $url . '&page=' . $lastpage, t('last'), $a->pager['page'] == $lastpage ? 'disabled' : '');
}
}
- return $data;
-}}
+ return $data;
+}
if(! function_exists('paginate')) {
/**
$diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False);
$ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0);
$force_ssl = ((x($_POST,'force_ssl')) ? True : False);
- $old_share = ((x($_POST,'old_share')) ? True : False);
$hide_help = ((x($_POST,'hide_help')) ? True : False);
- $suppress_language = ((x($_POST,'suppress_language')) ? True : False);
$suppress_tags = ((x($_POST,'suppress_tags')) ? True : False);
$use_fulltext_engine = ((x($_POST,'use_fulltext_engine')) ? True : False);
$itemcache = ((x($_POST,'itemcache')) ? notags(trim($_POST['itemcache'])) : '');
set_config('config','sitename',$sitename);
set_config('config','hostname',$hostname);
set_config('config','sender_email', $sender_email);
- set_config('system','suppress_language',$suppress_language);
set_config('system','suppress_tags',$suppress_tags);
set_config('system','shortcut_icon',$shortcut_icon);
set_config('system','touch_icon',$touch_icon);
set_config('config','private_addons', $private_addons);
set_config('system','force_ssl', $force_ssl);
- 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);
'$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),
'$force_ssl' => array('force_ssl', t("Force SSL"), get_config('system','force_ssl'), t("Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.")),
- '$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.")),
'$nodeinfo' => array('nodeinfo', t("Publish server information"), get_config('system','nodeinfo'), t("If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See <a href='http://the-federation.info/'>the-federation.info</a> for details.")),
'$use_fulltext_engine' => array('use_fulltext_engine', t("Use MySQL full text engine"), get_config('system','use_fulltext_engine'), t("Activates the full text engine. Speeds up search - but can only search for four and more characters.")),
- '$suppress_language' => array('suppress_language', t("Suppress Language"), get_config('system','suppress_language'), t("Suppress language information in meta information about a posting.")),
'$suppress_tags' => array('suppress_tags', t("Suppress Tags"), get_config('system','suppress_tags'), t("Suppress showing a list of hashtags at the end of the posting.")),
'$itemcache' => array('itemcache', t("Path to item cache"), get_config('system','itemcache'), t("The item caches buffers generated bbcode and external images.")),
'$itemcache_duration' => array('itemcache_duration', t("Cache duration in seconds"), get_config('system','itemcache_duration'), t("How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.")),
if(! dbm::is_result($r) || ($r[0]['private'] == 1))
killme();
- 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);
- } else {
- $o = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
-
- if($r[0]['title'])
- $o .= '[b]'.$r[0]['title'].'[/b]'."\n";
- $o .= $r[0]['body'];
- $o.= "[/share]";
- }
+ if (strpos($r[0]['body'], "[/share]") !== false) {
+ $pos = strpos($r[0]['body'], "[share");
+ $o = substr($r[0]['body'], $pos);
} else {
- $o = '';
+ $o = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
- $o .= "\xE2\x99\xb2" . ' [url=' . $r[0]['author-link'] . ']' . $r[0]['author-name'] . '[/url]' . "\n";
if($r[0]['title'])
- $o .= '[b]' . $r[0]['title'] . '[/b]' . "\n";
- $o .= $r[0]['body'] . "\n" ;
-
- $o .= (($r[0]['plink']) ? '[url=' . $r[0]['plink'] . ']' . t('link') . '[/url]' . "\n" : '');
+ $o .= '[b]'.$r[0]['title'].'[/b]'."\n";
+ $o .= $r[0]['body'];
+ $o.= "[/share]";
}
+
echo $o;
killme();
}
localize_item($item);
- if ($item["postopts"] and !get_config("system", "suppress_language")) {
- //$langdata = explode(";", $item["postopts"]);
- //$langstr = substr($langdata[0], 5)." (".round($langdata[1]*100, 1)."%)";
- $langstr = "";
- if (substr($item["postopts"], 0, 5) == "lang=") {
- $postopts = substr($item["postopts"], 5);
-
- $languages = explode(":", $postopts);
-
- if (sizeof($languages) == 1) {
- $languages = array();
- $languages[] = $postopts;
- }
-
- foreach ($languages as $language) {
- $langdata = explode(";", $language);
- if ($langstr != "") {
- $langstr .= ", ";
- }
-
- //$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)";
- $langstr .= round($langdata[1]*100, 1)."% ".$langdata[0];
- }
- }
- }
-
$body = prepare_body($item,true);
list($categories, $folders) = get_cats_and_terms($item);
'previewing' => ($conv->is_preview() ? ' preview ' : ''),
'wait' => t('Please wait'),
'thread_level' => $thread_level,
- 'postopts' => $langstr,
'edited' => $edited,
'network' => $item["item_network"],
'network_name' => network_to_name($item['item_network'], $profile_link),
{{include file="field_select.tpl" field=$theme_mobile}}
{{include file="field_select.tpl" field=$ssl_policy}}
{{if $ssl_policy.2 == 1}}{{include file="field_checkbox.tpl" field=$force_ssl}}{{/if}}
- {{include file="field_checkbox.tpl" field=$old_share}}
{{include file="field_checkbox.tpl" field=$hide_help}}
{{include file="field_select.tpl" field=$singleuser}}
<div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
{{include file="field_input.tpl" field=$lockpath}}
{{include file="field_input.tpl" field=$temppath}}
{{include file="field_input.tpl" field=$basepath}}
- {{include file="field_checkbox.tpl" field=$suppress_language}}
{{include file="field_checkbox.tpl" field=$suppress_tags}}
{{include file="field_checkbox.tpl" field=$nodeinfo}}
{{include file="field_input.tpl" field=$embedly}}
{{if $pager}}\r
{{if $pager.prev}}<span class="pager_prev {{$pager.prev.class}}"><a href="{{$pager.prev.url}}">{{$pager.prev.text}}</a></span>{{/if}}\r
\r
- {{if $pager.first}}<span class="pager_first $pager.first.class"><a href="{{$pager.first.url}}">{{$pager.first.text}}</a></span>{{/if}}\r
+ {{if $pager.first}}<span class="pager_first {{$pager.first.class}}"><a href="{{$pager.first.url}}">{{$pager.first.text}}</a></span>{{/if}}\r
\r
{{foreach $pager.pages as $p}}<span class="pager_{{$p.class}}"><a href="{{$p.url}}">{{$p.text}}</a></span>{{/foreach}}\r
\r
clear:left;
}
+.pager .disabled {
+ display: none;
+}
.pager_first,
.pager_last,
color: $link_color !important;
}
+/* Pagination improvements */
+.pagination > li > a,
+.pagination > li > span {
+ color: $link_color;
+}
+.pagination>.active>a,
+.pagination>.active>a:focus,
+.pagination>.active>a:hover,
+.pagination>.active>span,
+.pagination>.active>span:focus,
+.pagination>.active>span:hover {
+ background-color: $link_color;
+ border-color: $link_color;
+}
+.disabled > a {
+ pointer-events: none;
+}
+
/*
* some temporary workarounds until this will solved
* elsewhere (e.g. new templates)
+++ /dev/null
-<?php
-
-class colors {
-
-/* Convert hexdec color string to rgb(a) string */
-
- function hex2rgba($color, $opacity = false) {
-
- $default = 'rgb(0,0,0)';
-
- //Return default if no color provided
- if(empty($color))
- return $default;
-
- //Sanitize $color if "#" is provided
- if ($color[0] == '#' ) {
- $color = substr( $color, 1 );
- }
-
- //Check if color has 6 or 3 characters and get values
- if (strlen($color) == 6) {
- $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
- } elseif ( strlen( $color ) == 3 ) {
- $hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
- } else {
- return $default;
- }
-
- //Convert hexadec to rgb
- $rgb = array_map('hexdec', $hex);
-
- //Check if opacity is set(rgba or rgb)
- if($opacity){
- if(abs($opacity) > 1)
- $opacity = 1.0;
- $output = 'rgba('.implode(",",$rgb).','.$opacity.')';
- } else {
- $output = 'rgb('.implode(",",$rgb).')';
- }
-
- //Return rgb(a) color string
- return $output;
- }
-
- function hex2rgb( $colour ) {
- if ( $colour[0] == '#' ) {
- $colour = substr( $colour, 1 );
- }
- if ( strlen( $colour ) == 6 ) {
- list( $r, $g, $b ) = array( $colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5] );
- } elseif ( strlen( $colour ) == 3 ) {
- list( $r, $g, $b ) = array( $colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2] );
- } else {
- return false;
- }
- $r = hexdec( $r );
- $g = hexdec( $g );
- $b = hexdec( $b );
- return array( 'red' => $r, 'green' => $g, 'blue' => $b );
- }
-
-
- function rgbToHsl( $r, $g, $b ) {
- $oldR = $r;
- $oldG = $g;
- $oldB = $b;
- $r /= 255;
- $g /= 255;
- $b /= 255;
- $max = max( $r, $g, $b );
- $min = min( $r, $g, $b );
- $h;
- $s;
- $l = ( $max + $min ) / 2;
- $d = $max - $min;
-
- if( $d == 0 ){
- $h = $s = 0; // achromatic
- } else {
- $s = $d / ( 1 - abs( 2 * $l - 1 ) );
- switch( $max ){
- case $r:
- $h = 60 * fmod( ( ( $g - $b ) / $d ), 6 );
- if ($b > $g) {
- $h += 360;
- }
- break;
- case $g:
- $h = 60 * ( ( $b - $r ) / $d + 2 );
- break;
- case $b:
- $h = 60 * ( ( $r - $g ) / $d + 4 );
- break;
- }
- }
-
- return array( round( $h, 2 ), round( $s, 2 ), round( $l, 2 ) );
- }
- function hslToRgb( $h, $s, $l ){
- $r = "";
- $g = "";
- $b = "";
-
- $c = ( 1 - abs( 2 * $l - 1 ) ) * $s;
- $x = $c * ( 1 - abs( fmod( ( $h / 60 ), 2 ) - 1 ) );
- $m = $l - ( $c / 2 );
- if ( $h < 60 ) {
- $r = $c;
- $g = $x;
- $b = 0;
- } else if ( $h < 120 ) {
- $r = $x;
- $g = $c;
- $b = 0;
- } else if ( $h < 180 ) {
- $r = 0;
- $g = $c;
- $b = $x;
- } else if ( $h < 240 ) {
- $r = 0;
- $g = $x;
- $b = $c;
- } else if ( $h < 300 ) {
- $r = $x;
- $g = 0;
- $b = $c;
- } else {
- $r = $c;
- $g = 0;
- $b = $x;
- }
-
- $r = ( $r + $m ) * 255;
- $g = ( $g + $m ) * 255;
- $b = ( $b + $m ) * 255;
-
- return array( floor( $r ), floor( $g ), floor( $b ) );
- }
-
- /*
- * Som more example code - this needs to be deletet if we don't need it in
- * the future
- */
-
- function HTMLToRGB($htmlCode)
- {
- if($htmlCode[0] == '#')
- $htmlCode = substr($htmlCode, 1);
-
- if (strlen($htmlCode) == 3)
- {
- $htmlCode = $htmlCode[0] . $htmlCode[0] . $htmlCode[1] . $htmlCode[1] . $htmlCode[2] . $htmlCode[2];
- }
-
- $r = hexdec($htmlCode[0] . $htmlCode[1]);
- $g = hexdec($htmlCode[2] . $htmlCode[3]);
- $b = hexdec($htmlCode[4] . $htmlCode[5]);
-
- return $b + ($g << 0x8) + ($r << 0x10);
- }
-
- function RGBToHTML($RGB)
- {
- $r = 0xFF & ($RGB >> 0x10);
- $g = 0xFF & ($RGB >> 0x8);
- $b = 0xFF & $RGB;
-
- $r = dechex($r);
- $g = dechex($g);
- $b = dechex($b);
-
- return "#" . str_pad($r, 2, "0", STR_PAD_LEFT) . str_pad($g, 2, "0", STR_PAD_LEFT) . str_pad($b, 2, "0", STR_PAD_LEFT);
- }
-
- function ChangeLuminosity($RGB, $LuminosityPercent)
- {
- $HSL = RGBToHSL($RGB);
- $NewHSL = (int)(((float)$LuminosityPercent / 100) * 255) + (0xFFFF00 & $HSL);
- return HSLToRGB($NewHSL);
- }
-
- function RGBToHSL($RGB)
- {
- $r = 0xFF & ($RGB >> 0x10);
- $g = 0xFF & ($RGB >> 0x8);
- $b = 0xFF & $RGB;
-
- $r = ((float)$r) / 255.0;
- $g = ((float)$g) / 255.0;
- $b = ((float)$b) / 255.0;
-
- $maxC = max($r, $g, $b);
- $minC = min($r, $g, $b);
-
- $l = ($maxC + $minC) / 2.0;
-
- if($maxC == $minC)
- {
- $s = 0;
- $h = 0;
- }
- else
- {
- if($l < .5)
- {
- $s = ($maxC - $minC) / ($maxC + $minC);
- }
- else
- {
- $s = ($maxC - $minC) / (2.0 - $maxC - $minC);
- }
- if($r == $maxC)
- $h = ($g - $b) / ($maxC - $minC);
- if($g == $maxC)
- $h = 2.0 + ($b - $r) / ($maxC - $minC);
- if($b == $maxC)
- $h = 4.0 + ($r - $g) / ($maxC - $minC);
-
- $h = $h / 6.0;
- }
-
- $h = (int)round(255.0 * $h);
- $s = (int)round(255.0 * $s);
- $l = (int)round(255.0 * $l);
-
- $HSL = $l + ($s << 0x8) + ($h << 0x10);
- return $HSL;
- }
-
- function HSLToRGB($HSL)
- {
- $h = 0xFF & ($HSL >> 0x10);
- $s = 0xFF & ($HSL >> 0x8);
- $l = 0xFF & $HSL;
-
- $h = ((float)$h) / 255.0;
- $s = ((float)$s) / 255.0;
- $l = ((float)$l) / 255.0;
-
- if($s == 0)
- {
- $r = $l;
- $g = $l;
- $b = $l;
- }
- else
- {
- if($l < .5)
- {
- $t2 = $l * (1.0 + $s);
- }
- else
- {
- $t2 = ($l + $s) - ($l * $s);
- }
- $t1 = 2.0 * $l - $t2;
-
- $rt3 = $h + 1.0/3.0;
- $gt3 = $h;
- $bt3 = $h - 1.0/3.0;
-
- if($rt3 < 0) $rt3 += 1.0;
- if($rt3 > 1) $rt3 -= 1.0;
- if($gt3 < 0) $gt3 += 1.0;
- if($gt3 > 1) $gt3 -= 1.0;
- if($bt3 < 0) $bt3 += 1.0;
- if($bt3 > 1) $bt3 -= 1.0;
-
- if(6.0 * $rt3 < 1) $r = $t1 + ($t2 - $t1) * 6.0 * $rt3;
- elseif(2.0 * $rt3 < 1) $r = $t2;
- elseif(3.0 * $rt3 < 2) $r = $t1 + ($t2 - $t1) * ((2.0/3.0) - $rt3) * 6.0;
- else $r = $t1;
-
- if(6.0 * $gt3 < 1) $g = $t1 + ($t2 - $t1) * 6.0 * $gt3;
- elseif(2.0 * $gt3 < 1) $g = $t2;
- elseif(3.0 * $gt3 < 2) $g = $t1 + ($t2 - $t1) * ((2.0/3.0) - $gt3) * 6.0;
- else $g = $t1;
-
- if(6.0 * $bt3 < 1) $b = $t1 + ($t2 - $t1) * 6.0 * $bt3;
- elseif(2.0 * $bt3 < 1) $b = $t2;
- elseif(3.0 * $bt3 < 2) $b = $t1 + ($t2 - $t1) * ((2.0/3.0) - $bt3) * 6.0;
- else $b = $t1;
- }
-
- $r = (int)round(255.0 * $r);
- $g = (int)round(255.0 * $g);
- $b = (int)round(255.0 * $b);
-
- $RGB = $b + ($g << 0x8) + ($r << 0x10);
- return $RGB;
- }
-}
\ No newline at end of file
--- /dev/null
+{{* Pager template, uses output of paginate_data() in include/text.php *}}\r
+{{if $pager}}\r
+<div class="{{$pager.class}}">\r
+ {{if $pager.first}}<li class="pager_first {{$pager.first.class}}"><a href="{{$pager.first.url}}">{{$pager.first.text}}</a></li>{{/if}}\r
+\r
+ {{if $pager.prev}}<li class="pager_prev {{$pager.prev.class}}"><a href="{{$pager.prev.url}}">{{$pager.prev.text}}</a></li>{{/if}}\r
+\r
+ {{foreach $pager.pages as $p}}<li class="pager_{{$p.class}}"><a href="{{$p.url}}">{{$p.text}}</a></li>{{/foreach}}\r
+\r
+ {{if $pager.next}}<li class="pager_next {{$pager.next.class}}"><a href="{{$pager.next.url}}">{{$pager.next.text}}</a></li>{{/if}}\r
+\r
+ {{if $pager.last}} <li class="pager_last {{$pager.last.class}}"><a href="{{$pager.last.url}}">{{$pager.last.text}}</a></li>{{/if}}\r
+</div>\r
+{{/if}}\r
-webkit-border-radius: 10px;\r
}\r
\r
+.pager .disabled {\r
+ display: none;\r
+}\r
\r
.pager_first,\r
.pager_last,\r
-webkit-border-radius: 10px;
}
+.pager .disabled {
+ display: none;
+}
.pager_first,
.pager_last,
margin-top: 25px;
clear: both;
}
+.pager .disabled {
+ display: none;
+}
/**
* ADMIN
*/
margin-top: 25px;
clear: both;
}
+.pager .disabled {
+ display: none;
+}
/**
* ADMIN
*/
margin-top: 25px;
clear: both;
}
+.pager .disabled {
+ display: none;
+}
/**
* ADMIN
margin: 4px;
}
+.pager .disabled {
+ display: none;
+}
+
.pager_current {
background-color: #1873a2;
color: #ffffff;
float: left;
}
+.pager .disabled {
+ display: none;
+}
+
.hide-comments-outer {
margin-left: 80px;
margin-bottom: 5px;