Notice_source checks in better code style
This commit is contained in:
parent
5e4f93cc7d
commit
7ea067a0dc
|
@ -339,7 +339,7 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction
|
|||
$source = null;
|
||||
|
||||
$ns = $notice->getSource();
|
||||
if ($ns) {
|
||||
if ($ns instanceof Notice_source) {
|
||||
if (!empty($ns->name) && !empty($ns->url)) {
|
||||
$source = '<a href="'
|
||||
. htmlspecialchars($ns->url)
|
||||
|
|
|
@ -139,8 +139,11 @@ class Message extends Managed_DataObject
|
|||
|
||||
function getSource()
|
||||
{
|
||||
if (empty($this->source)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ns = new Notice_source();
|
||||
if (!empty($this->source)) {
|
||||
switch ($this->source) {
|
||||
case 'web':
|
||||
case 'xmpp':
|
||||
|
@ -152,7 +155,7 @@ class Message extends Managed_DataObject
|
|||
break;
|
||||
default:
|
||||
$ns = Notice_source::getKV($this->source);
|
||||
if (!$ns) {
|
||||
if (!$ns instanceof Notice_source) {
|
||||
$ns = new Notice_source();
|
||||
$ns->code = $this->source;
|
||||
$app = Oauth_application::getKV('name', $this->source);
|
||||
|
@ -163,7 +166,6 @@ class Message extends Managed_DataObject
|
|||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $ns;
|
||||
}
|
||||
|
||||
|
@ -204,7 +206,7 @@ class Message extends Managed_DataObject
|
|||
|
||||
$source = $this->getSource();
|
||||
|
||||
if ($source) {
|
||||
if ($source instanceof Notice_source) {
|
||||
$act->generator = ActivityObject::fromNoticeSource($source);
|
||||
}
|
||||
|
||||
|
|
|
@ -2407,8 +2407,11 @@ class Notice extends Managed_DataObject
|
|||
*/
|
||||
function getSource()
|
||||
{
|
||||
if (empty($this->source)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ns = new Notice_source();
|
||||
if (!empty($this->source)) {
|
||||
switch ($this->source) {
|
||||
case 'web':
|
||||
case 'xmpp':
|
||||
|
@ -2431,7 +2434,7 @@ class Notice extends Managed_DataObject
|
|||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $ns;
|
||||
}
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ class ApiAction extends Action
|
|||
$source = null;
|
||||
|
||||
$ns = $notice->getSource();
|
||||
if ($ns) {
|
||||
if ($ns instanceof Notice_source) {
|
||||
if (!empty($ns->name) && !empty($ns->url)) {
|
||||
$source = '<a href="'
|
||||
. htmlspecialchars($ns->url)
|
||||
|
|
|
@ -264,7 +264,7 @@ class ResultItem
|
|||
break;
|
||||
default:
|
||||
$ns = Notice_source::getKV($source);
|
||||
if ($ns) {
|
||||
if ($ns instanceof Notice_source) {
|
||||
$source_name = '<a href="' . $ns->url . '">' . $ns->name . '</a>';
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -417,7 +417,10 @@ class NoticeListItem extends Widget
|
|||
{
|
||||
$ns = $this->notice->getSource();
|
||||
|
||||
if ($ns) {
|
||||
if (!$ns instanceof Notice_source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TRANS: A possible notice source (web interface).
|
||||
$source_name = (empty($ns->name)) ? ($ns->code ? _($ns->code) : _m('SOURCE','web')) : _($ns->name);
|
||||
$this->out->text(' ');
|
||||
|
@ -459,7 +462,6 @@ class NoticeListItem extends Widget
|
|||
|
||||
$this->out->elementEnd('span');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* show link to single-notice view for this notice item
|
||||
|
|
Loading…
Reference in New Issue
Block a user