more work on bug #59 - hope this doesn't hork everything. Also some tweaking of the theme for the new radius control, which produced some surprising results when expert mode was toggled.

This commit is contained in:
friendica 2013-07-08 22:01:57 -07:00
parent cd40802229
commit 6e012839c9
6 changed files with 74 additions and 87 deletions

View File

@ -11,12 +11,14 @@ require_once('include/text.php');
/** /**
* A list of threads * A list of threads
* *
* We should think about making this a SPL Iterator
*/ */
class Conversation extends BaseObject { class Conversation extends BaseObject {
private $threads = array(); private $threads = array();
private $mode = null; private $mode = null;
private $observer = null;
private $writable = false; private $writable = false;
private $commentable = false;
private $profile_owner = 0; private $profile_owner = 0;
private $preview = false; private $preview = false;
@ -34,8 +36,8 @@ class Conversation extends BaseObject {
$a = $this->get_app(); $a = $this->get_app();
$observer = $a->get_observer(); $this->observer = $a->get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : ''); $ob_hash = (($this->observer) ? $this->observer['xchan_hash'] : '');
switch($mode) { switch($mode) {
case 'network': case 'network':
@ -63,7 +65,6 @@ class Conversation extends BaseObject {
break; break;
} }
$this->mode = $mode; $this->mode = $mode;
} }
/** /**
@ -80,6 +81,10 @@ class Conversation extends BaseObject {
return $this->writable; return $this->writable;
} }
public function is_commentable() {
return $this->commentable;
}
/** /**
* Check if page is a preview * Check if page is a preview
*/ */
@ -101,6 +106,10 @@ class Conversation extends BaseObject {
$this->set_mode($mode); $this->set_mode($mode);
} }
public function get_observer() {
return $this->observer;
}
/** /**
* Add a thread to the conversation * Add a thread to the conversation
@ -121,12 +130,21 @@ class Conversation extends BaseObject {
} }
/* /*
* Only add will be displayed * Only add things that will be displayed
*/ */
if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
if(($item->get_data_value('id') != $item->get_data_value('parent')) && (activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE))) {
return false; return false;
} }
if(local_user() && $item->get_data_value('uid') == local_user())
$this->commentable = true;
if(($this->observer) && (! $this->writable)) {
$this->commentable = can_comment_on_post($this->observer['xchan_hash'],$item['data']);
}
$item->set_conversation($this); $item->set_conversation($this);
$this->threads[] = $item; $this->threads[] = $item;
return end($this->threads); return end($this->threads);

View File

@ -11,12 +11,10 @@ require_once('boot.php');
* An item * An item
*/ */
class Item extends BaseObject { class Item extends BaseObject {
private $data = array(); public $data = array();
private $template = 'conv_item.tpl'; private $template = 'conv_item.tpl';
private $comment_box_template = 'comment_item.tpl'; private $comment_box_template = 'comment_item.tpl';
private $toplevel = false; private $toplevel = false;
private $writable = false;
private $commentable = false;
private $children = array(); private $children = array();
private $parent = null; private $parent = null;
private $conversation = null; private $conversation = null;
@ -34,19 +32,9 @@ class Item extends BaseObject {
$a = $this->get_app(); $a = $this->get_app();
$this->data = $data; $this->data = $data;
$this->channel = $a->get_channel();
$this->observer = $a->get_observer();
$this->toplevel = ($this->get_id() == $this->get_data_value('parent')); $this->toplevel = ($this->get_id() == $this->get_data_value('parent'));
$this->writable = (((local_user()) && ($this->channel['channel_hash'] === $this->data['owner_xchan'])) ? true : false);
$this->commentable = $this->writable;
if(($this->observer) && (! $this->writable)) {
$this->commentable = can_comment_on_post($this->observer['xchan_hash'],$data);
}
// Prepare the children // Prepare the children
if(count($data['children'])) { if(count($data['children'])) {
foreach($data['children'] as $item) { foreach($data['children'] as $item) {
@ -106,10 +94,9 @@ class Item extends BaseObject {
else else
$edpost = false; $edpost = false;
// FIXME - this is wrong. if($this->observer['xchan_hash'] == $this->get_data_value('author_xchan')
// if(($this->get_data_value('uid') == local_user()) || $this->is_visiting()) || $this->observer['xchan_hash'] == $this->get_data_value('owner_xchan')
|| $this->get_data_value('uid') == local_user())
if($this->get_data_value('uid') == local_user())
$dropping = true; $dropping = true;
if($dropping) { if($dropping) {
@ -175,7 +162,7 @@ class Item extends BaseObject {
); );
} }
if($this->is_commentable()) { if($conv->is_commentable()) {
$like = array( t("I like this \x28toggle\x29"), t("like")); $like = array( t("I like this \x28toggle\x29"), t("like"));
$dislike = array( t("I don't like this \x28toggle\x29"), t("dislike")); $dislike = array( t("I don't like this \x28toggle\x29"), t("dislike"));
if ($shareable) if ($shareable)
@ -455,28 +442,6 @@ class Item extends BaseObject {
return $this->toplevel; return $this->toplevel;
} }
/**
* Check if this is writable
*/
private function is_writable() {
return $this->writable;
// $conv = $this->get_conversation();
// return true;
// if($conv) {
// This will allow us to comment on wall-to-wall items owned by our friends
// and community forums even if somebody else wrote the post.
// return ($this->writable || ($this->is_visiting() && $conv->get_mode() == 'channel'));
// }
}
private function is_commentable() {
return $this->commentable;
}
/** /**
* Count the total of our descendants * Count the total of our descendants
*/ */
@ -514,44 +479,43 @@ class Item extends BaseObject {
$comment_box = ''; $comment_box = '';
$conv = $this->get_conversation(); $conv = $this->get_conversation();
if(! $this->is_commentable()) if(! $conv->is_commentable())
return; return;
if($conv->is_writable() || $this->is_writable()) { $template = get_markup_template($this->get_comment_box_template());
$template = get_markup_template($this->get_comment_box_template());
$a = $this->get_app(); $a = $this->get_app();
$observer = $conv->get_observer();
$qc = ((local_user()) ? get_pconfig(local_user(),'system','qcomment') : null); $qc = ((local_user()) ? get_pconfig(local_user(),'system','qcomment') : null);
$qcomment = (($qc) ? explode("\n",$qc) : null); $qcomment = (($qc) ? explode("\n",$qc) : null);
$comment_box = replace_macros($template,array( $comment_box = replace_macros($template,array(
'$return_path' => '', '$return_path' => '',
'$threaded' => $this->is_threaded(), '$threaded' => $this->is_threaded(),
'$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''), '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''),
'$type' => (($conv->get_mode() === 'channel') ? 'wall-comment' : 'net-comment'), '$type' => (($conv->get_mode() === 'channel') ? 'wall-comment' : 'net-comment'),
'$id' => $this->get_id(), '$id' => $this->get_id(),
'$parent' => $this->get_id(), '$parent' => $this->get_id(),
'$qcomment' => $qcomment, '$qcomment' => $qcomment,
'$profile_uid' => $conv->get_profile_owner(), '$profile_uid' => $conv->get_profile_owner(),
'$mylink' => $this->observer['xchan_url'], '$mylink' => $observer['xchan_url'],
'$mytitle' => t('This is you'), '$mytitle' => t('This is you'),
'$myphoto' => $this->observer['xchan_photo_s'], '$myphoto' => $observer['xchan_photo_s'],
'$comment' => t('Comment'), '$comment' => t('Comment'),
'$submit' => t('Submit'), '$submit' => t('Submit'),
'$edbold' => t('Bold'), '$edbold' => t('Bold'),
'$editalic' => t('Italic'), '$editalic' => t('Italic'),
'$eduline' => t('Underline'), '$eduline' => t('Underline'),
'$edquote' => t('Quote'), '$edquote' => t('Quote'),
'$edcode' => t('Code'), '$edcode' => t('Code'),
'$edimg' => t('Image'), '$edimg' => t('Image'),
'$edurl' => t('Link'), '$edurl' => t('Link'),
'$edvideo' => t('Video'), '$edvideo' => t('Video'),
'$preview' => ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''), '$preview' => ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''),
'$indent' => $indent, '$indent' => $indent,
'$sourceapp' => get_app()->sourcename '$sourceapp' => get_app()->sourcename
)); ));
}
return $comment_box; return $comment_box;
} }

View File

@ -1354,7 +1354,7 @@ function import_directory_profile($hash,$profile) {
} }
else { else {
$update = true; $update = true;
$x = q("insert into xprof (xprof_hash, xprof_desc, xprof_dob, xprof_age, xprof_gender, xprof_marital, xprof_sexual, xprof_locale, xprof_region, xprof_postcode, xprof_country, xprof_keywords) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", $x = q("insert into xprof (xprof_hash, xprof_desc, xprof_dob, xprof_age, xprof_gender, xprof_marital, xprof_sexual, xprof_locale, xprof_region, xprof_postcode, xprof_country, xprof_keywords) values ('%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
dbesc($arr['xprof_hash']), dbesc($arr['xprof_hash']),
dbesc($arr['xprof_desc']), dbesc($arr['xprof_desc']),
dbesc($arr['xprof_dob']), dbesc($arr['xprof_dob']),

View File

@ -1,7 +1,7 @@
/* There's probably some stuff in here we don't need, and maybe some missing stuff we do need. We can clean it up incrementaly, just get the heavy lifting done for now */ /* There's probably some stuff in here we don't need, and maybe some missing stuff we do need. We can clean it up incrementaly, just get the heavy lifting done for now */
aside { aside {
border-radius: 0px 0px 20px 0px;} border-radius: $radiuspx;}
.tab { .tab {
@ -9,9 +9,9 @@ border-radius: 0px 0px 20px 0px;}
background-color: #f00; background-color: #f00;
color: #fff !important; color: #fff !important;
font-weight: bold; font-weight: bold;
-webkit-border-radius: 5px; -webkit-border-radius: $radiuspx;
-moz-border-radius: 5px; -moz-border-radius: $radiuspx;
border-radius: 20px; border-radius: $radiuspx;
margin: 0; margin: 0;
width: auto; width: auto;
margin-left: 8px; margin-left: 8px;
@ -38,7 +38,7 @@ border-radius: 0px 0px 20px 0px;}
.wall-item-content-wrapper { .wall-item-content-wrapper {
position: relative; position: relative;
border-radius: 10px; border-radius: $radiuspx;
box-shadow: 8px 8px 8px #000; box-shadow: 8px 8px 8px #000;
border: 1px solid #eec; border: 1px solid #eec;
} }
@ -68,7 +68,7 @@ opacity: 1;
ul.menu-popup { ul.menu-popup {
background: #dd0000; background: #dd0000;
color: #eec; color: #eec;
border-radius: 0px 0px 20px 20px; border-radius: $radiuspx;
z-index: 100000; z-index: 100000;
-webkit-box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7); -webkit-box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7);
-moz-box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7); -moz-box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7);

View File

@ -926,6 +926,9 @@ footer {
.wall-item-content-wrapper { .wall-item-content-wrapper {
margin-top: 10px; margin-top: 10px;
position: relative; position: relative;
border-radius: $radiuspx;
border: 1px solid #eec;
/* background: #fff; */ /* background: #fff; */
/* border-radius: 5px; */ /* border-radius: 5px; */
/* box-shadow: 12px 12px 12px #111; */ /* box-shadow: 12px 12px 12px #111; */

View File

@ -54,6 +54,7 @@
// Dark themes are very different - we need to do some of these from scratch, so don't bother setting vars for anything else // Dark themes are very different - we need to do some of these from scratch, so don't bother setting vars for anything else
if ($colour_scheme === 'dark') {$colour = 'dark'; $navcolour = 'black';} if ($colour_scheme === 'dark') {$colour = 'dark'; $navcolour = 'black';}
if ($colour_scheme === 'redbasic'){$navcolour = 'red';} if ($colour_scheme === 'redbasic'){$navcolour = 'red';}
$shadows = false;
} }
// This is probably the easiest place to apply global settings. Don't bother with site line height and such. Instead, check pconfig for global user settings. // This is probably the easiest place to apply global settings. Don't bother with site line height and such. Instead, check pconfig for global user settings.
@ -133,7 +134,8 @@
if ($displaystyle === "fancy") if ($displaystyle === "fancy")
{if (file_exists('view/theme/' . current_theme() . '/css/fancy.css')) { {if (file_exists('view/theme/' . current_theme() . '/css/fancy.css')) {
$fancy = (file_get_contents('view/theme/' . current_theme() . '/css/fancy.css')); $fancy = (file_get_contents('view/theme/' . current_theme() . '/css/fancy.css'));
echo "$fancy";} echo str_replace(array('$radius'),array($radius),$fancy);
}
} }
// Put the # here to force hex colours - if we don't, somebody is going to do something odd, using RGB and we're all going to be confused on the support forums // Put the # here to force hex colours - if we don't, somebody is going to do something odd, using RGB and we're all going to be confused on the support forums