mirror of
https://github.com/friendica/friendica
synced 2025-04-28 13:44:25 +02:00
Coding Standards
A few updates for coding standards
This commit is contained in:
parent
5888cce08e
commit
d9e9cbe753
12 changed files with 357 additions and 249 deletions
|
@ -19,8 +19,10 @@ class BaseObject
|
|||
* Get the app
|
||||
*
|
||||
* Same as get_app from boot.php
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function get_app()
|
||||
public function getApp()
|
||||
{
|
||||
if (self::$app) {
|
||||
return self::$app;
|
||||
|
@ -35,8 +37,10 @@ class BaseObject
|
|||
* Set the app
|
||||
*
|
||||
* @param object $app App
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function set_app($app)
|
||||
public static function setApp($app)
|
||||
{
|
||||
self::$app = $app;
|
||||
}
|
||||
|
|
|
@ -134,6 +134,8 @@ class Cache
|
|||
* @param string $key The key to the cached data
|
||||
* @param mixed $value The value that is about to be stored
|
||||
* @param integer $duration The cache lifespan
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function set($key, $value, $duration = CACHE_MONTH)
|
||||
{
|
||||
|
@ -159,6 +161,8 @@ class Cache
|
|||
* @brief Remove outdated data from the cache
|
||||
*
|
||||
* @param integer $max_level The maximum cache level that is to be cleared
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function clear($max_level = CACHE_MONTH)
|
||||
{
|
||||
|
|
|
@ -21,8 +21,8 @@ use dba;
|
|||
* There are a few places in the code (such as the admin panel) where boolean
|
||||
* configurations need to be fixed as of 10/08/2011.
|
||||
*/
|
||||
class Config {
|
||||
|
||||
class Config
|
||||
{
|
||||
private static $cache;
|
||||
private static $in_db;
|
||||
|
||||
|
@ -32,12 +32,12 @@ class Config {
|
|||
* All configuration values of the system are stored in global cache
|
||||
* which is available under the global variable $a->config
|
||||
*
|
||||
* @param string $family
|
||||
* The category of the configuration value
|
||||
* @param string $family The category of the configuration value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function load($family = "config") {
|
||||
|
||||
public static function load($family = "config")
|
||||
{
|
||||
// We don't preload "system" anymore.
|
||||
// This reduces the number of database reads a lot.
|
||||
if ($family === 'system') {
|
||||
|
@ -72,18 +72,15 @@ class Config {
|
|||
* local config cache, pull it into the cache so we don't have
|
||||
* to hit the DB again for this item.
|
||||
*
|
||||
* @param string $family
|
||||
* The category of the configuration value
|
||||
* @param string $key
|
||||
* The configuration key to query
|
||||
* @param mixed $default_value optional
|
||||
* The value to return if key is not set (default: null)
|
||||
* @param boolean $refresh optional
|
||||
* If true the config is loaded from the db and not from the cache (default: false)
|
||||
* @param string $family The category of the configuration value
|
||||
* @param string $key The configuration key to query
|
||||
* @param mixed $default_value optional, The value to return if key is not set (default: null)
|
||||
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
|
||||
*
|
||||
* @return mixed Stored value or null if it does not exist
|
||||
*/
|
||||
public static function get($family, $key, $default_value = null, $refresh = false) {
|
||||
|
||||
public static function get($family, $key, $default_value = null, $refresh = false)
|
||||
{
|
||||
$a = get_app();
|
||||
|
||||
if (!$refresh) {
|
||||
|
@ -128,15 +125,14 @@ class Config {
|
|||
*
|
||||
* Note: Please do not store booleans - convert to 0/1 integer values!
|
||||
*
|
||||
* @param string $family
|
||||
* The category of the configuration value
|
||||
* @param string $key
|
||||
* The configuration key to set
|
||||
* @param string $value
|
||||
* The value to store
|
||||
* @param string $family The category of the configuration value
|
||||
* @param string $key The configuration key to set
|
||||
* @param string $value The value to store
|
||||
*
|
||||
* @return mixed Stored $value or false if the database update failed
|
||||
*/
|
||||
public static function set($family, $key, $value) {
|
||||
public static function set($family, $key, $value)
|
||||
{
|
||||
$a = get_app();
|
||||
|
||||
// We store our setting values in a string variable.
|
||||
|
@ -177,14 +173,13 @@ class Config {
|
|||
* Removes the configured value from the stored cache in $a->config
|
||||
* and removes it from the database.
|
||||
*
|
||||
* @param string $family
|
||||
* The category of the configuration value
|
||||
* @param string $key
|
||||
* The configuration key to delete
|
||||
* @param string $family The category of the configuration value
|
||||
* @param string $key The configuration key to delete
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function delete($family, $key) {
|
||||
|
||||
public static function delete($family, $key)
|
||||
{
|
||||
if (isset(self::$cache[$family][$key])) {
|
||||
unset(self::$cache[$family][$key]);
|
||||
unset(self::$in_db[$family][$key]);
|
||||
|
|
|
@ -23,22 +23,32 @@ class Conversation extends BaseObject
|
|||
private $profile_owner = 0;
|
||||
private $preview = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $mode The mode
|
||||
* @param boolean $preview boolean value
|
||||
*/
|
||||
public function __construct($mode, $preview)
|
||||
{
|
||||
$this->set_mode($mode);
|
||||
$this->setMode($mode);
|
||||
$this->preview = $preview;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mode we'll be displayed on
|
||||
*
|
||||
* @param string $mode The mode to set
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function set_mode($mode)
|
||||
private function setMode($mode)
|
||||
{
|
||||
if ($this->get_mode() == $mode) {
|
||||
if ($this->getMode() == $mode) {
|
||||
return;
|
||||
}
|
||||
|
||||
$a = $this->get_app();
|
||||
$a = $this->getApp();
|
||||
|
||||
switch ($mode) {
|
||||
case 'network':
|
||||
|
@ -55,7 +65,7 @@ class Conversation extends BaseObject
|
|||
$this->writable = can_write_wall($a, $this->profile_owner);
|
||||
break;
|
||||
default:
|
||||
logger('[ERROR] Conversation::set_mode : Unhandled mode ('. $mode .').', LOGGER_DEBUG);
|
||||
logger('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').', LOGGER_DEBUG);
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
@ -64,32 +74,40 @@ class Conversation extends BaseObject
|
|||
|
||||
/**
|
||||
* Get mode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_mode()
|
||||
public function getMode()
|
||||
{
|
||||
return $this->mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if page is writable
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_writable()
|
||||
public function isWritable()
|
||||
{
|
||||
return $this->writable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if page is a preview
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_preview()
|
||||
public function isPreview()
|
||||
{
|
||||
return $this->preview;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile owner
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function get_profile_owner()
|
||||
public function getProfileOwner()
|
||||
{
|
||||
return $this->profile_owner;
|
||||
}
|
||||
|
@ -97,21 +115,22 @@ class Conversation extends BaseObject
|
|||
/**
|
||||
* Add a thread to the conversation
|
||||
*
|
||||
* Returns:
|
||||
* _ The inserted item on success
|
||||
* _ false on failure
|
||||
* @param object $item The item to insert
|
||||
*
|
||||
* @return mixed The inserted item on success
|
||||
* false on failure
|
||||
*/
|
||||
public function add_thread($item)
|
||||
public function addThread($item)
|
||||
{
|
||||
$item_id = $item->getId();
|
||||
|
||||
if (!$item_id) {
|
||||
logger('[ERROR] Conversation::add_thread : Item has no ID!!', LOGGER_DEBUG);
|
||||
logger('[ERROR] Conversation::addThread : Item has no ID!!', LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->get_thread($item->getId())) {
|
||||
logger('[WARN] Conversation::add_thread : Thread already exists ('. $item->getId() .').', LOGGER_DEBUG);
|
||||
if ($this->getThread($item->getId())) {
|
||||
logger('[WARN] Conversation::addThread : Thread already exists ('. $item->getId() .').', LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -119,12 +138,12 @@ class Conversation extends BaseObject
|
|||
* Only add will be displayed
|
||||
*/
|
||||
if ($item->getDataValue('network') === NETWORK_MAIL && local_user() != $item->getDataValue('uid')) {
|
||||
logger('[WARN] Conversation::add_thread : Thread is a mail ('. $item->getId() .').', LOGGER_DEBUG);
|
||||
logger('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').', LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($item->getDataValue('verb') === ACTIVITY_LIKE || $item->getDataValue('verb') === ACTIVITY_DISLIKE) {
|
||||
logger('[WARN] Conversation::add_thread : Thread is a (dis)like ('. $item->getId() .').', LOGGER_DEBUG);
|
||||
logger('[WARN] Conversation::addThread : Thread is a (dis)like ('. $item->getId() .').', LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -139,13 +158,14 @@ class Conversation extends BaseObject
|
|||
*
|
||||
* We should find a way to avoid using those arguments (at least most of them)
|
||||
*
|
||||
* Returns:
|
||||
* _ The data requested on success
|
||||
* _ false on failure
|
||||
* @param object $conv_responses data
|
||||
*
|
||||
* @return mixed The data requested on success
|
||||
* false on failure
|
||||
*/
|
||||
public function get_template_data($conv_responses)
|
||||
public function getTemplateData($conv_responses)
|
||||
{
|
||||
$a = get_app();
|
||||
$a = getApp();
|
||||
$result = array();
|
||||
$i = 0;
|
||||
|
||||
|
@ -157,7 +177,7 @@ class Conversation extends BaseObject
|
|||
$item_data = $item->getTemplateData($conv_responses);
|
||||
|
||||
if (!$item_data) {
|
||||
logger('[ERROR] Conversation::get_template_data : Failed to get item template data ('. $item->getId() .').', LOGGER_DEBUG);
|
||||
logger('[ERROR] Conversation::getTemplateData : Failed to get item template data ('. $item->getId() .').', LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
$result[] = $item_data;
|
||||
|
@ -169,11 +189,12 @@ class Conversation extends BaseObject
|
|||
/**
|
||||
* Get a thread based on its item id
|
||||
*
|
||||
* Returns:
|
||||
* _ The found item on success
|
||||
* _ false on failure
|
||||
* @param integer $id Item id
|
||||
*
|
||||
* @return mixed The found item on success
|
||||
* false on failure
|
||||
*/
|
||||
private function get_thread($id)
|
||||
private function getThread($id)
|
||||
{
|
||||
foreach ($this->threads as $item) {
|
||||
if ($item->getId() == $id) {
|
||||
|
|
|
@ -39,9 +39,14 @@ class Item extends BaseObject
|
|||
private $threaded = false;
|
||||
private $visiting = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $data data array
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$a = $this->get_app();
|
||||
$a = $this->getApp();
|
||||
|
||||
$this->data = $data;
|
||||
$this->setTemplate('wall');
|
||||
|
@ -92,9 +97,11 @@ class Item extends BaseObject
|
|||
/**
|
||||
* Get data in a form usable by a conversation template
|
||||
*
|
||||
* Returns:
|
||||
* _ The data requested on success
|
||||
* _ false on failure
|
||||
* @param object $conv_responses conversation responses
|
||||
* @param integer $thread_level default = 1
|
||||
*
|
||||
* @return mixed The data requested on success
|
||||
* false on failure
|
||||
*/
|
||||
public function getTemplateData($conv_responses, $thread_level = 1)
|
||||
{
|
||||
|
@ -102,7 +109,7 @@ class Item extends BaseObject
|
|||
|
||||
$result = array();
|
||||
|
||||
$a = $this->get_app();
|
||||
$a = $this->getApp();
|
||||
|
||||
$item = $this->getData();
|
||||
$edited = false;
|
||||
|
@ -136,7 +143,7 @@ class Item extends BaseObject
|
|||
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
|
||||
? t('Private Message')
|
||||
: false);
|
||||
$shareable = ((($conv->get_profile_owner() == local_user()) && ($item['private'] != 1)) ? true : false);
|
||||
$shareable = ((($conv->getProfileOwner() == local_user()) && ($item['private'] != 1)) ? true : false);
|
||||
if (local_user() && link_compare($a->contact['url'], $item['author-link'])) {
|
||||
if ($item["event-id"] != 0) {
|
||||
$edpost = array("events/event/".$item['event-id'], t("Edit"));
|
||||
|
@ -153,12 +160,12 @@ class Item extends BaseObject
|
|||
|
||||
$drop = array(
|
||||
'dropping' => $dropping,
|
||||
'pagedrop' => ((feature_enabled($conv->get_profile_owner(), 'multi_delete')) ? $item['pagedrop'] : ''),
|
||||
'pagedrop' => ((feature_enabled($conv->getProfileOwner(), 'multi_delete')) ? $item['pagedrop'] : ''),
|
||||
'select' => t('Select'),
|
||||
'delete' => t('Delete'),
|
||||
);
|
||||
|
||||
$filer = (($conv->get_profile_owner() == local_user()) ? t("save to folder") : false);
|
||||
$filer = (($conv->getProfileOwner() == local_user()) ? t("save to folder") : false);
|
||||
|
||||
$diff_author = ((link_compare($item['url'], $item['author-link'])) ? false : true);
|
||||
$profile_name = htmlentities(((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
|
||||
|
@ -179,7 +186,7 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
if (!isset($item['author-thumb']) || ($item['author-thumb'] == "")) {
|
||||
$author_contact = get_contact_details_by_url($item['author-link'], $conv->get_profile_owner());
|
||||
$author_contact = get_contact_details_by_url($item['author-link'], $conv->getProfileOwner());
|
||||
if ($author_contact["thumb"]) {
|
||||
$item['author-thumb'] = $author_contact["thumb"];
|
||||
} else {
|
||||
|
@ -188,7 +195,7 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
if (!isset($item['owner-thumb']) || ($item['owner-thumb'] == "")) {
|
||||
$owner_contact = get_contact_details_by_url($item['owner-link'], $conv->get_profile_owner());
|
||||
$owner_contact = get_contact_details_by_url($item['owner-link'], $conv->getProfileOwner());
|
||||
if ($owner_contact["thumb"]) {
|
||||
$item['owner-thumb'] = $owner_contact["thumb"];
|
||||
} else {
|
||||
|
@ -223,7 +230,7 @@ class Item extends BaseObject
|
|||
$response_verbs[] = 'attendyes';
|
||||
$response_verbs[] = 'attendno';
|
||||
$response_verbs[] = 'attendmaybe';
|
||||
if ($conv->is_writable()) {
|
||||
if ($conv->isWritable()) {
|
||||
$isevent = true;
|
||||
$attend = array( t('I will attend'), t('I will not attend'), t('I might attend'));
|
||||
}
|
||||
|
@ -247,7 +254,7 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
if ($this->isToplevel()) {
|
||||
if ($conv->get_profile_owner() == local_user()) {
|
||||
if ($conv->getProfileOwner() == local_user()) {
|
||||
$isstarred = (($item['starred']) ? "starred" : "unstarred");
|
||||
|
||||
$star = array(
|
||||
|
@ -271,7 +278,7 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
$tagger = '';
|
||||
if (feature_enabled($conv->get_profile_owner(), 'commtag')) {
|
||||
if (feature_enabled($conv->getProfileOwner(), 'commtag')) {
|
||||
$tagger = array(
|
||||
'add' => t("add tag"),
|
||||
'class' => "",
|
||||
|
@ -282,10 +289,10 @@ class Item extends BaseObject
|
|||
$indent = 'comment';
|
||||
}
|
||||
|
||||
if ($conv->is_writable()) {
|
||||
if ($conv->isWritable()) {
|
||||
$buttons = array(
|
||||
'like' => array( t("I like this \x28toggle\x29"), t("like")),
|
||||
'dislike' => ((feature_enabled($conv->get_profile_owner(), 'dislike')) ? array( t("I don't like this \x28toggle\x29"), t("dislike")) : ''),
|
||||
'dislike' => ((feature_enabled($conv->getProfileOwner(), 'dislike')) ? array( t("I don't like this \x28toggle\x29"), t("dislike")) : ''),
|
||||
);
|
||||
if ($shareable) {
|
||||
$buttons['share'] = array( t('Share this'), t('share'));
|
||||
|
@ -379,12 +386,12 @@ class Item extends BaseObject
|
|||
'owner_photo' => $a->remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)),
|
||||
'owner_name' => htmlentities($owner_name_e),
|
||||
'plink' => get_plink($item),
|
||||
'edpost' => ((feature_enabled($conv->get_profile_owner(), 'edit_posts')) ? $edpost : ''),
|
||||
'edpost' => ((feature_enabled($conv->getProfileOwner(), 'edit_posts')) ? $edpost : ''),
|
||||
'isstarred' => $isstarred,
|
||||
'star' => ((feature_enabled($conv->get_profile_owner(), 'star_posts')) ? $star : ''),
|
||||
'ignore' => ((feature_enabled($conv->get_profile_owner(), 'ignore_posts')) ? $ignore : ''),
|
||||
'star' => ((feature_enabled($conv->getProfileOwner(), 'star_posts')) ? $star : ''),
|
||||
'ignore' => ((feature_enabled($conv->getProfileOwner(), 'ignore_posts')) ? $ignore : ''),
|
||||
'tagger' => $tagger,
|
||||
'filer' => ((feature_enabled($conv->get_profile_owner(), 'filing')) ? $filer : ''),
|
||||
'filer' => ((feature_enabled($conv->getProfileOwner(), 'filing')) ? $filer : ''),
|
||||
'drop' => $drop,
|
||||
'vote' => $buttons,
|
||||
'like' => $responses['like']['output'],
|
||||
|
@ -392,7 +399,7 @@ class Item extends BaseObject
|
|||
'responses' => $responses,
|
||||
'switchcomment' => t('Comment'),
|
||||
'comment' => $comment,
|
||||
'previewing' => ($conv->is_preview() ? ' preview ' : ''),
|
||||
'previewing' => ($conv->isPreview() ? ' preview ' : ''),
|
||||
'wait' => t('Please wait'),
|
||||
'thread_level' => $thread_level,
|
||||
'edited' => $edited,
|
||||
|
@ -449,11 +456,17 @@ class Item extends BaseObject
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->getDataValue('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isThreaded()
|
||||
{
|
||||
return $this->threaded;
|
||||
|
@ -461,6 +474,10 @@ class Item extends BaseObject
|
|||
|
||||
/**
|
||||
* Add a child item
|
||||
*
|
||||
* @param object $item The child item to add
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function addChild(Item $item)
|
||||
{
|
||||
|
@ -489,6 +506,10 @@ class Item extends BaseObject
|
|||
|
||||
/**
|
||||
* Get a child by its ID
|
||||
*
|
||||
* @param integer $id The child id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChild($id)
|
||||
{
|
||||
|
@ -502,7 +523,9 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
/**
|
||||
* Get all ou children
|
||||
* Get all our children
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
|
@ -511,6 +534,10 @@ class Item extends BaseObject
|
|||
|
||||
/**
|
||||
* Set our parent
|
||||
*
|
||||
* @param object $item The item to set as parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setParent($item)
|
||||
{
|
||||
|
@ -525,6 +552,8 @@ class Item extends BaseObject
|
|||
|
||||
/**
|
||||
* Remove our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function removeParent()
|
||||
{
|
||||
|
@ -534,6 +563,10 @@ class Item extends BaseObject
|
|||
|
||||
/**
|
||||
* Remove a child
|
||||
*
|
||||
* @param object $item The child to be removed
|
||||
*
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public function removeChild($item)
|
||||
{
|
||||
|
@ -553,6 +586,8 @@ class Item extends BaseObject
|
|||
|
||||
/**
|
||||
* Get parent item
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
protected function getParent()
|
||||
{
|
||||
|
@ -560,11 +595,15 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
/**
|
||||
* set conversation
|
||||
* Set conversation
|
||||
*
|
||||
* @param object $conv The conversation
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setConversation($conv)
|
||||
{
|
||||
$previous_mode = ($this->conversation ? $this->conversation->get_mode() : '');
|
||||
$previous_mode = ($this->conversation ? $this->conversation->getMode() : '');
|
||||
|
||||
$this->conversation = $conv;
|
||||
|
||||
|
@ -575,7 +614,9 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
/**
|
||||
* get conversation
|
||||
* Get conversation
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getConversation()
|
||||
{
|
||||
|
@ -586,6 +627,8 @@ class Item extends BaseObject
|
|||
* Get raw data
|
||||
*
|
||||
* We shouldn't need this
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
|
@ -595,9 +638,10 @@ class Item extends BaseObject
|
|||
/**
|
||||
* Get a data value
|
||||
*
|
||||
* Returns:
|
||||
* _ value on success
|
||||
* _ false on failure
|
||||
* @param object $name key
|
||||
*
|
||||
* @return mixed value on success
|
||||
* false on failure
|
||||
*/
|
||||
public function getDataValue($name)
|
||||
{
|
||||
|
@ -611,6 +655,10 @@ class Item extends BaseObject
|
|||
|
||||
/**
|
||||
* Set template
|
||||
*
|
||||
* @param object $name template name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function setTemplate($name)
|
||||
{
|
||||
|
@ -624,6 +672,8 @@ class Item extends BaseObject
|
|||
|
||||
/**
|
||||
* Get template
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
private function getTemplate()
|
||||
{
|
||||
|
@ -632,6 +682,8 @@ class Item extends BaseObject
|
|||
|
||||
/**
|
||||
* Check if this is a toplevel post
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function isToplevel()
|
||||
{
|
||||
|
@ -640,6 +692,8 @@ class Item extends BaseObject
|
|||
|
||||
/**
|
||||
* Check if this is writable
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function isWritable()
|
||||
{
|
||||
|
@ -650,18 +704,20 @@ class Item extends BaseObject
|
|||
// and community forums even if somebody else wrote the post.
|
||||
|
||||
// bug #517 - this fixes for conversation owner
|
||||
if ($conv->get_mode() == 'profile' && $conv->get_profile_owner() == local_user()) {
|
||||
if ($conv->getMode() == 'profile' && $conv->getProfileOwner() == local_user()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// this fixes for visitors
|
||||
return ($this->writable || ($this->isVisiting() && $conv->get_mode() == 'profile'));
|
||||
return ($this->writable || ($this->isVisiting() && $conv->getMode() == 'profile'));
|
||||
}
|
||||
return $this->writable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the total of our descendants
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
private function countDescendants()
|
||||
{
|
||||
|
@ -678,6 +734,8 @@ class Item extends BaseObject
|
|||
|
||||
/**
|
||||
* Get the template for the comment box
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getCommentBoxTemplate()
|
||||
{
|
||||
|
@ -687,13 +745,14 @@ class Item extends BaseObject
|
|||
/**
|
||||
* Get the comment box
|
||||
*
|
||||
* Returns:
|
||||
* _ The comment box string (empty if no comment box)
|
||||
* _ false on failure
|
||||
* @param string $indent Indent value
|
||||
*
|
||||
* @return mixed The comment box string (empty if no comment box)
|
||||
* false on failure
|
||||
*/
|
||||
private function getCommentBox($indent)
|
||||
{
|
||||
$a = $this->get_app();
|
||||
$a = $this->getApp();
|
||||
if (!$this->isToplevel() && !(Config::get('system', 'thread_allow') && $a->theme_thread_allow)) {
|
||||
return '';
|
||||
}
|
||||
|
@ -702,11 +761,11 @@ class Item extends BaseObject
|
|||
$conv = $this->getConversation();
|
||||
$template = get_markup_template($this->getCommentBoxTemplate());
|
||||
$ww = '';
|
||||
if (($conv->get_mode() === 'network') && $this->isWallToWall()) {
|
||||
if (($conv->getMode() === 'network') && $this->isWallToWall()) {
|
||||
$ww = 'ww';
|
||||
}
|
||||
|
||||
if ($conv->is_writable() && $this->isWritable()) {
|
||||
if ($conv->isWritable() && $this->isWritable()) {
|
||||
$qc = $qcomment = null;
|
||||
|
||||
/*
|
||||
|
@ -723,13 +782,13 @@ class Item extends BaseObject
|
|||
array(
|
||||
'$return_path' => $a->query_string,
|
||||
'$threaded' => $this->isThreaded(),
|
||||
// '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''),
|
||||
// '$jsreload' => (($conv->getMode() === 'display') ? $_SESSION['return_url'] : ''),
|
||||
'$jsreload' => '',
|
||||
'$type' => (($conv->get_mode() === 'profile') ? 'wall-comment' : 'net-comment'),
|
||||
'$type' => (($conv->getMode() === 'profile') ? 'wall-comment' : 'net-comment'),
|
||||
'$id' => $this->getId(),
|
||||
'$parent' => $this->getId(),
|
||||
'$qcomment' => $qcomment,
|
||||
'$profile_uid' => $conv->get_profile_owner(),
|
||||
'$profile_uid' => $conv->getProfileOwner(),
|
||||
'$mylink' => $a->remove_baseurl($a->contact['url']),
|
||||
'$mytitle' => t('This is you'),
|
||||
'$myphoto' => $a->remove_baseurl($a->contact['thumb']),
|
||||
|
@ -743,10 +802,10 @@ class Item extends BaseObject
|
|||
'$edimg' => t('Image'),
|
||||
'$edurl' => t('Link'),
|
||||
'$edvideo' => t('Video'),
|
||||
'$preview' => ((feature_enabled($conv->get_profile_owner(), 'preview')) ? t('Preview') : ''),
|
||||
'$preview' => ((feature_enabled($conv->getProfileOwner(), 'preview')) ? t('Preview') : ''),
|
||||
'$indent' => $indent,
|
||||
'$sourceapp' => t($a->sourcename),
|
||||
'$ww' => (($conv->get_mode() === 'network') ? $ww : ''),
|
||||
'$ww' => (($conv->getMode() === 'network') ? $ww : ''),
|
||||
'$rand_num' => random_digits(12))
|
||||
);
|
||||
}
|
||||
|
@ -754,6 +813,9 @@ class Item extends BaseObject
|
|||
return $comment_box;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getRedirectUrl()
|
||||
{
|
||||
return $this->redirect_url;
|
||||
|
@ -761,15 +823,17 @@ class Item extends BaseObject
|
|||
|
||||
/**
|
||||
* Check if we are a wall to wall item and set the relevant properties
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function checkWallToWall()
|
||||
{
|
||||
$a = $this->get_app();
|
||||
$a = $this->getApp();
|
||||
$conv = $this->getConversation();
|
||||
$this->wall_to_wall = false;
|
||||
|
||||
if ($this->isToplevel()) {
|
||||
if ($conv->get_mode() !== 'profile') {
|
||||
if ($conv->getMode() !== 'profile') {
|
||||
if ($this->getDataValue('wall') && !$this->getDataValue('self')) {
|
||||
// On the network page, I am the owner. On the display page it will be the profile owner.
|
||||
// This will have been stored in $a->page_contact by our calling page.
|
||||
|
@ -819,26 +883,41 @@ class Item extends BaseObject
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
private function isWallToWall()
|
||||
{
|
||||
return $this->wall_to_wall;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getOwnerUrl()
|
||||
{
|
||||
return $this->owner_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getOwnerPhoto()
|
||||
{
|
||||
return $this->owner_photo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getOwnerName()
|
||||
{
|
||||
return $this->owner_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
private function isVisiting()
|
||||
{
|
||||
return $this->visiting;
|
||||
|
|
|
@ -322,7 +322,7 @@ class NotificationsManager
|
|||
'link' => System::baseUrl(true).'/display/'.$it['pguid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'url' => $it['author-link'],
|
||||
'text' => sprintf( t("%s is not attending %s's event"), $it['author-name'], $it['pname']),
|
||||
'text' => sprintf(t("%s is not attending %s's event"), $it['author-name'], $it['pname']),
|
||||
'when' => $default_item_when,
|
||||
'ago' => $default_item_ago,
|
||||
'seen' => $it['seen']
|
||||
|
@ -381,9 +381,9 @@ class NotificationsManager
|
|||
|
||||
/**
|
||||
* @brief Total number of network notifications
|
||||
* @param int|string $seen
|
||||
* If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
* @param int|string $seen If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
*
|
||||
* @return int Number of network notifications
|
||||
*/
|
||||
private function networkTotal($seen = 0)
|
||||
|
@ -413,9 +413,8 @@ class NotificationsManager
|
|||
/**
|
||||
* @brief Get network notifications
|
||||
*
|
||||
* @param int|string $seen
|
||||
* If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
* @param int|string $seen If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
* @param int $start Start the query at this point
|
||||
* @param int $limit Maximum number of query results
|
||||
*
|
||||
|
@ -465,9 +464,9 @@ class NotificationsManager
|
|||
|
||||
/**
|
||||
* @brief Total number of system notifications
|
||||
* @param int|string $seen
|
||||
* If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
* @param int|string $seen If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
*
|
||||
* @return int Number of system notifications
|
||||
*/
|
||||
private function systemTotal($seen = 0)
|
||||
|
@ -493,9 +492,8 @@ class NotificationsManager
|
|||
/**
|
||||
* @brief Get system notifications
|
||||
*
|
||||
* @param int|string $seen
|
||||
* If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
* @param int|string $seen If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
* @param int $start Start the query at this point
|
||||
* @param int $limit Maximum number of query results
|
||||
*
|
||||
|
@ -541,7 +539,7 @@ class NotificationsManager
|
|||
*
|
||||
* @return string The additional sql query
|
||||
*/
|
||||
private function _personal_sql_extra()
|
||||
private function personalSqlExtra()
|
||||
{
|
||||
$myurl = System::baseUrl(true) . '/profile/'. $this->a->user['nickname'];
|
||||
$myurl = substr($myurl, strpos($myurl, '://') + 3);
|
||||
|
@ -559,15 +557,15 @@ class NotificationsManager
|
|||
|
||||
/**
|
||||
* @brief Total number of personal notifications
|
||||
* @param int|string $seen
|
||||
* If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
* @param int|string $seen If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
*
|
||||
* @return int Number of personal notifications
|
||||
*/
|
||||
private function personalTotal($seen = 0)
|
||||
{
|
||||
$sql_seen = "";
|
||||
$sql_extra = $this->_personal_sql_extra();
|
||||
$sql_extra = $this->personalSqlExtra();
|
||||
|
||||
if ($seen === 0) {
|
||||
$sql_seen = " AND `item`.`unseen` = 1 ";
|
||||
|
@ -579,7 +577,7 @@ class NotificationsManager
|
|||
WHERE `item`.`visible` = 1
|
||||
$sql_extra
|
||||
$sql_seen
|
||||
AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 " ,
|
||||
AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ",
|
||||
intval(local_user())
|
||||
);
|
||||
|
||||
|
@ -593,9 +591,8 @@ class NotificationsManager
|
|||
/**
|
||||
* @brief Get personal notifications
|
||||
*
|
||||
* @param int|string $seen
|
||||
* If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
* @param int|string $seen If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
* @param int $start Start the query at this point
|
||||
* @param int $limit Maximum number of query results
|
||||
*
|
||||
|
@ -608,7 +605,7 @@ class NotificationsManager
|
|||
{
|
||||
$ident = 'personal';
|
||||
$total = $this->personalTotal($seen);
|
||||
$sql_extra = $this->_personal_sql_extra();
|
||||
$sql_extra = $this->personalSqlExtra();
|
||||
$notifs = array();
|
||||
$sql_seen = "";
|
||||
|
||||
|
@ -646,9 +643,9 @@ class NotificationsManager
|
|||
|
||||
/**
|
||||
* @brief Total number of home notifications
|
||||
* @param int|string $seen
|
||||
* If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
* @param int|string $seen If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
*
|
||||
* @return int Number of home notifications
|
||||
*/
|
||||
private function homeTotal($seen = 0)
|
||||
|
@ -677,9 +674,8 @@ class NotificationsManager
|
|||
/**
|
||||
* @brief Get home notifications
|
||||
*
|
||||
* @param int|string $seen
|
||||
* If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
* @param int|string $seen If 0 only include notifications into the query
|
||||
* which aren't marked as "seen"
|
||||
* @param int $start Start the query at this point
|
||||
* @param int $limit Maximum number of query results
|
||||
*
|
||||
|
@ -728,9 +724,9 @@ class NotificationsManager
|
|||
|
||||
/**
|
||||
* @brief Total number of introductions
|
||||
* @param bool $all
|
||||
* If false only include introductions into the query
|
||||
* which aren't marked as ignored
|
||||
* @param bool $all If false only include introductions into the query
|
||||
* which aren't marked as ignored
|
||||
*
|
||||
* @return int Number of introductions
|
||||
*/
|
||||
private function introTotal($all = false)
|
||||
|
@ -757,18 +753,18 @@ class NotificationsManager
|
|||
/**
|
||||
* @brief Get introductions
|
||||
*
|
||||
* @param bool $all
|
||||
* If false only include introductions into the query
|
||||
* which aren't marked as ignored
|
||||
* @param int $start Start the query at this point
|
||||
* @param int $limit Maximum number of query results
|
||||
* @param bool $all If false only include introductions into the query
|
||||
* which aren't marked as ignored
|
||||
* @param int $start Start the query at this point
|
||||
* @param int $limit Maximum number of query results
|
||||
*
|
||||
* @return array with
|
||||
* string 'ident' => Notification identifier
|
||||
* int 'total' => Total number of available introductions
|
||||
* array 'notifications' => Introductions
|
||||
*/
|
||||
public function introNotifs($all = false, $start = 0, $limit = 80) {
|
||||
public function introNotifs($all = false, $start = 0, $limit = 80)
|
||||
{
|
||||
$ident = 'introductions';
|
||||
$total = $this->introTotal($seen);
|
||||
$notifs = array();
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* @file src/Core/PConfig.php
|
||||
*/
|
||||
namespace Friendica\Core;
|
||||
|
||||
use Friendica\Database\DBM;
|
||||
|
@ -17,8 +20,8 @@ use dba;
|
|||
* The PConfig::get() functions return boolean false for keys that are unset,
|
||||
* and this could lead to subtle bugs.
|
||||
*/
|
||||
class PConfig {
|
||||
|
||||
class PConfig
|
||||
{
|
||||
private static $in_db;
|
||||
|
||||
/**
|
||||
|
@ -27,13 +30,13 @@ class PConfig {
|
|||
* All configuration values of the given user are stored in global cache
|
||||
* which is available under the global variable $a->config[$uid].
|
||||
*
|
||||
* @param string $uid
|
||||
* The user_id
|
||||
* @param string $family
|
||||
* The category of the configuration value
|
||||
* @param string $uid The user_id
|
||||
* @param string $family The category of the configuration value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function load($uid, $family) {
|
||||
public static function load($uid, $family)
|
||||
{
|
||||
$a = get_app();
|
||||
|
||||
$r = dba::select('pconfig', array('v', 'k'), array('cat' => $family, 'uid' => $uid));
|
||||
|
@ -57,20 +60,16 @@ class PConfig {
|
|||
* Get a particular user's config value from the given category ($family)
|
||||
* and the $key from a cached storage in $a->config[$uid].
|
||||
*
|
||||
* @param string $uid
|
||||
* The user_id
|
||||
* @param string $family
|
||||
* The category of the configuration value
|
||||
* @param string $key
|
||||
* The configuration key to query
|
||||
* @param mixed $default_value optional
|
||||
* The value to return if key is not set (default: null)
|
||||
* @param boolean $refresh optional
|
||||
* If true the config is loaded from the db and not from the cache (default: false)
|
||||
* @param string $uid The user_id
|
||||
* @param string $family The category of the configuration value
|
||||
* @param string $key The configuration key to query
|
||||
* @param mixed $default_value optional, The value to return if key is not set (default: null)
|
||||
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
|
||||
*
|
||||
* @return mixed Stored value or null if it does not exist
|
||||
*/
|
||||
public static function get($uid, $family, $key, $default_value = null, $refresh = false) {
|
||||
|
||||
public static function get($uid, $family, $key, $default_value = null, $refresh = false)
|
||||
{
|
||||
$a = get_app();
|
||||
|
||||
if (!$refresh) {
|
||||
|
@ -112,18 +111,15 @@ class PConfig {
|
|||
*
|
||||
* @note Please do not store booleans - convert to 0/1 integer values!
|
||||
*
|
||||
* @param string $uid
|
||||
* The user_id
|
||||
* @param string $family
|
||||
* The category of the configuration value
|
||||
* @param string $key
|
||||
* The configuration key to set
|
||||
* @param string $value
|
||||
* The value to store
|
||||
* @param string $uid The user_id
|
||||
* @param string $family The category of the configuration value
|
||||
* @param string $key The configuration key to set
|
||||
* @param string $value The value to store
|
||||
*
|
||||
* @return mixed Stored $value or false
|
||||
*/
|
||||
public static function set($uid, $family, $key, $value) {
|
||||
|
||||
public static function set($uid, $family, $key, $value)
|
||||
{
|
||||
$a = get_app();
|
||||
|
||||
// We store our setting values in a string variable.
|
||||
|
@ -157,15 +153,14 @@ class PConfig {
|
|||
* Removes the configured value from the stored cache in $a->config[$uid]
|
||||
* and removes it from the database.
|
||||
*
|
||||
* @param string $uid The user_id
|
||||
* @param string $family
|
||||
* The category of the configuration value
|
||||
* @param string $key
|
||||
* The configuration key to delete
|
||||
* @param string $uid The user_id
|
||||
* @param string $family The category of the configuration value
|
||||
* @param string $key The configuration key to delete
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function delete($uid,$family,$key) {
|
||||
|
||||
public static function delete($uid, $family, $key)
|
||||
{
|
||||
$a = get_app();
|
||||
|
||||
if (x($a->config[$uid][$family], $key)) {
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* @file src/Core/System.php
|
||||
*/
|
||||
namespace Friendica\Core;
|
||||
|
||||
use Friendica\App;
|
||||
|
@ -13,14 +16,16 @@ use Friendica\App;
|
|||
/**
|
||||
* @brief System methods
|
||||
*/
|
||||
class System {
|
||||
|
||||
class System
|
||||
{
|
||||
private static $a;
|
||||
|
||||
/**
|
||||
* @brief Initializes the static class variable
|
||||
* @return void
|
||||
*/
|
||||
private static function init() {
|
||||
private static function init()
|
||||
{
|
||||
global $a;
|
||||
|
||||
if (!is_object(self::$a)) {
|
||||
|
@ -34,7 +39,8 @@ class System {
|
|||
* @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN
|
||||
* @return string Friendica server base URL
|
||||
*/
|
||||
public static function baseUrl($ssl = false) {
|
||||
public static function baseUrl($ssl = false)
|
||||
{
|
||||
self::init();
|
||||
return self::$a->get_baseurl($ssl);
|
||||
}
|
||||
|
@ -42,21 +48,23 @@ class System {
|
|||
/**
|
||||
* @brief Removes the baseurl from an url. This avoids some mixed content problems.
|
||||
*
|
||||
* @param string $orig_url
|
||||
* @param string $orig_url The url to be cleaned
|
||||
*
|
||||
* @return string The cleaned url
|
||||
*/
|
||||
public static function removedBaseUrl($orig_url) {
|
||||
public static function removedBaseUrl($orig_url)
|
||||
{
|
||||
self::init();
|
||||
return self::$a->remove_baseurl($orig_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a string with a callstack. Can be used for logging.
|
||||
*
|
||||
* @param integer $depth optional, default 4
|
||||
* @return string
|
||||
*/
|
||||
public static function callstack($depth = 4) {
|
||||
public static function callstack($depth = 4)
|
||||
{
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
|
||||
// We remove the first two items from the list since they contain data that we don't need.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue