if ($item['id'] == $item['parent']) {
$item_object = new Item($item);
- $conv->add_thread($item_object);
+ $conv->addThread($item_object);
}
}
- $threads = $conv->get_template_data($conv_responses);
+ $threads = $conv->getTemplateData($conv_responses);
if (!$threads) {
logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
if (empty($a)) {
$a = new App(__DIR__);
}
-BaseObject::set_app($a);
+BaseObject::setApp($a);
// We assume that the index.php is called by a frontend process
// The value is set to "true" by default in boot.php
}
/**
- *
* Try to open the database;
- *
*/
require_once "include/dba.php";
die("System is currently unavailable. Please try again later");
}
- if (Config::get('system', 'force_ssl') && ($a->get_scheme() == "http") &&
- (intval(Config::get('system', 'ssl_policy')) == SSL_POLICY_FULL) &&
- (substr(System::baseUrl(), 0, 8) == "https://")) {
+ if (Config::get('system', 'force_ssl') && ($a->get_scheme() == "http")
+ && (intval(Config::get('system', 'ssl_policy')) == SSL_POLICY_FULL)
+ && (substr(System::baseUrl(), 0, 8) == "https://")
+ ) {
header("HTTP/1.1 302 Moved Temporarily");
header("Location: " . System::baseUrl() . "/" . $a->query_string);
exit();
load_translation_table($lang);
/**
- *
* Important stuff we always need to do.
*
* The order of these may be important so use caution if you think they're all
* intertwingled with no logical order and decide to sort it out. Some of the
* dependencies have changed, but at least at one time in the recent past - the
* order was critical to everything working properly
- *
*/
// Exclude the backend processes from the session management
* Language was set earlier, but we can over-ride it in the session.
* We have to do it here because the session was just now opened.
*/
-if (x($_SESSION,'authenticated') && !x($_SESSION,'language')) {
+if (x($_SESSION, 'authenticated') && !x($_SESSION, 'language')) {
// we didn't loaded user data yet, but we need user language
$r = dba::select('user', array('language'), array('uid' => $_SESSION['uid']), array('limit' => 1));
$_SESSION['language'] = $lang;
}
}
-if ((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
+if ((x($_SESSION, 'language')) && ($_SESSION['language'] !== $lang)) {
$lang = $_SESSION['language'];
load_translation_table($lang);
}
-if ((x($_GET,'zrl')) && (!$install && !$maintenance)) {
+if ((x($_GET, 'zrl')) && (!$install && !$maintenance)) {
// Only continue when the given profile link seems valid
// Valid profile links contain a path with "/profile/" and no query parameters
- if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "") &&
- strstr(parse_url($_GET['zrl'], PHP_URL_PATH), "/profile/")) {
+ if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "")
+ && strstr(parse_url($_GET['zrl'], PHP_URL_PATH), "/profile/")
+ ) {
$_SESSION['my_url'] = $_GET['zrl'];
- $a->query_string = preg_replace('/[\?&]zrl=(.*?)([\?&]|$)/is','',$a->query_string);
+ $a->query_string = preg_replace('/[\?&]zrl=(.*?)([\?&]|$)/is', '', $a->query_string);
zrl_init($a);
} else {
// Someone came with an invalid parameter, maybe as a DDoS attempt
}
/**
- *
* For Mozilla auth manager - still needs sorting, and this might conflict with LRDD header.
* Apache/PHP lumps the Link: headers into one - and other services might not be able to parse it
* this way. There's a PHP flag to link the headers because by default this will over-write any other
* link header.
*
* What we really need to do is output the raw headers ourselves so we can keep them separate.
- *
*/
// header('Link: <' . System::baseUrl() . '/amcd>; rel="acct-mgmt";');
-if (x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login')) {
- require("include/auth.php");
+if (x($_COOKIE["Friendica"]) || (x($_SESSION, 'authenticated')) || (x($_POST, 'auth-params')) || ($a->module === 'login')) {
+ require "include/auth.php";
}
-if (! x($_SESSION,'authenticated')) {
+if (! x($_SESSION, 'authenticated')) {
header('X-Account-Management-Status: none');
}
$a->page['end'] = '';
-if (! x($_SESSION,'sysmsg')) {
+if (! x($_SESSION, 'sysmsg')) {
$_SESSION['sysmsg'] = array();
}
-if (! x($_SESSION,'sysmsg_info')) {
+if (! x($_SESSION, 'sysmsg_info')) {
$_SESSION['sysmsg_info'] = array();
}
// Array for informations about last received items
-if (! x($_SESSION,'last_updated')) {
+if (! x($_SESSION, 'last_updated')) {
$_SESSION['last_updated'] = array();
}
/*
nav_set_selected('nothing');
//Don't populate apps_menu if apps are private
-$privateapps = Config::get('config','private_addons');
+$privateapps = Config::get('config', 'private_addons');
if ((local_user()) || (! $privateapps === "1")) {
$arr = array('app_menu' => $a->apps);
}
/**
- *
* We have already parsed the server path into $a->argc and $a->argv
*
* $a->argv[0] is our module name. We will load the file mod/{$a->argv[0]}.php
if (strlen($a->module)) {
/**
- *
* We will always have a module name.
* First see if we have a plugin which is masquerading as a module.
- *
*/
// Compatibility with the Android Diaspora client
$a->module = "login";
}
- $privateapps = Config::get('config','private_addons');
+ $privateapps = Config::get('config', 'private_addons');
- if (is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
+ if (is_array($a->plugins) && in_array($a->module, $a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
//Check if module is an app and if public access to apps is allowed or not
if ((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
- info( t("You must be logged in to use addons. "));
+ info(t("You must be logged in to use addons. "));
} else {
- include_once("addon/{$a->module}/{$a->module}.php");
+ include_once "addon/{$a->module}/{$a->module}.php";
if (function_exists($a->module . '_module')) {
$a->module_loaded = true;
}
*/
if ((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) {
- include_once("mod/{$a->module}.php");
+ include_once "mod/{$a->module}.php";
$a->module_loaded = true;
}
/**
- *
* The URL provided does not resolve to a valid module.
*
* On Dreamhost sites, quite often things go wrong for no apparent reason and they send us to '/internal_error.html'.
* this will often succeed and eventually do the right thing.
*
* Otherwise we are going to emit a 404 not found.
- *
*/
if (! $a->module_loaded) {
-
// Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit.
- if ((x($_SERVER,'QUERY_STRING')) && preg_match('/{[0-9]}/',$_SERVER['QUERY_STRING']) !== 0) {
+ if ((x($_SERVER, 'QUERY_STRING')) && preg_match('/{[0-9]}/', $_SERVER['QUERY_STRING']) !== 0) {
killme();
}
- if ((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
+ if ((x($_SERVER, 'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
goaway(System::baseUrl() . $_SERVER['REQUEST_URI']);
}
logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG);
header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
$tpl = get_markup_template("404.tpl");
- $a->page['content'] = replace_macros($tpl, array(
- '$message' => t('Page not found.' )
- ));
+ $a->page['content'] = replace_macros(
+ $tpl,
+ array(
+ '$message' => t('Page not found.'))
+ );
}
}
/**
- * load current theme info
+ * Load current theme info
*/
$theme_info_file = "view/theme/".current_theme()."/theme.php";
-if (file_exists($theme_info_file)){
- require_once($theme_info_file);
+if (file_exists($theme_info_file)) {
+ require_once $theme_info_file;
}
/* initialise content region */
-if (! x($a->page,'content')) {
+if (! x($a->page, 'content')) {
$a->page['content'] = '';
}
if (!$install && !$maintenance) {
- call_hooks('page_content_top',$a->page['content']);
+ call_hooks('page_content_top', $a->page['content']);
}
/**
$func($a);
}
- if (function_exists(str_replace('-','_',current_theme()) . '_init')) {
- $func = str_replace('-','_',current_theme()) . '_init';
+ if (function_exists(str_replace('-', '_', current_theme()) . '_init')) {
+ $func = str_replace('-', '_', current_theme()) . '_init';
$func($a);
}
if (($_SERVER['REQUEST_METHOD'] === 'POST') && (! $a->error)
&& (function_exists($a->module . '_post'))
- && (! x($_POST,'auth-params'))) {
+ && (! x($_POST, 'auth-params'))
+ ) {
call_hooks($a->module . '_mod_post', $_POST);
$func = $a->module . '_post';
$func($a);
}
if ((! $a->error) && (function_exists($a->module . '_afterpost'))) {
- call_hooks($a->module . '_mod_afterpost',$placeholder);
+ call_hooks($a->module . '_mod_afterpost', $placeholder);
$func = $a->module . '_afterpost';
$func($a);
}
$a->page['content'] .= $arr['content'];
}
- if (function_exists(str_replace('-','_',current_theme()) . '_content_loaded')) {
- $func = str_replace('-','_',current_theme()) . '_content_loaded';
+ if (function_exists(str_replace('-', '_', current_theme()) . '_content_loaded')) {
+ $func = str_replace('-', '_', current_theme()) . '_content_loaded';
$func($a);
}
}
} else {
$link = 'toggle_mobile?off=1&address=' . curPageURL();
}
- $a->page['footer'] = replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array(
- '$toggle_link' => $link,
- '$toggle_text' => t('toggle mobile')
- ));
+ $a->page['footer'] = replace_macros(
+ get_markup_template("toggle_mobile_footer.tpl"),
+ array(
+ '$toggle_link' => $link,
+ '$toggle_text' => t('toggle mobile'))
+ );
}
/**
$stylesheet = $a->theme['stylesheet'];
}
-$a->page['htmlhead'] = str_replace('{{$stylesheet}}',$stylesheet,$a->page['htmlhead']);
+$a->page['htmlhead'] = str_replace('{{$stylesheet}}', $stylesheet, $a->page['htmlhead']);
//$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => $stylesheet));
if (isset($_GET["mode"]) && (($_GET["mode"] == "raw") || ($_GET["mode"] == "minimal"))) {
}
if (isset($_GET["mode"]) && ($_GET["mode"] == "raw")) {
-
header("Content-type: text/html; charset=utf-8");
echo substr($target->saveHTML(), 6, -8);
use Friendica\App;
use Friendica\Content\Smilies;
-function smilies_content(App $a)
+function smiliesContent(App $a)
{
if ($a->argv[1] === "json") {
- $tmp = Smilies::get_list();
+ $tmp = Smilies::getList();
$results = array();
for ($i = 0; $i < count($tmp['texts']); $i++) {
$results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]);
* @param array $b Array of emoticons
* @param string $smiley The text smilie
* @param string $representation The replacement
+ *
+ * @return void
*/
public static function add(&$b, $smiley, $representation)
{
*
* @hook smilie ('texts' => smilies texts array, 'icons' => smilies html array)
*/
- public static function get_list()
+ public static function getList()
{
$texts = array(
'<3',
* bbcode source for HTML display
*
* @param string $s Text that should be replaced
- * @param boolean $sample
+ * @param boolean $sample optional, default false
* @param boolean $no_images Only replace emoticons without images
*
* @return string HML Output of the Smilie
$s = preg_replace_callback('/<pre>(.*?)<\/pre>/ism', 'self::encode', $s);
$s = preg_replace_callback('/<code>(.*?)<\/code>/ism', 'self::encode', $s);
- $params = self::get_list();
+ $params = self::getList();
if ($no_images) {
$cleaned = array('texts' => array(), 'icons' => array());
$s .= '<dl><dt>' . $params['texts'][$x] . '</dt><dd>' . $params['icons'][$x] . '</dd></dl>';
}
} else {
- $params['string'] = preg_replace_callback('/<(3+)/', 'self::preg_heart', $params['string']);
+ $params['string'] = preg_replace_callback('/<(3+)/', 'self::pregHeart', $params['string']);
$s = str_replace($params['texts'], $params['icons'], $params['string']);
}
return $s;
}
+ /**
+ * @param string $m string
+ *
+ * @return string base64 encoded string
+ */
private static function encode($m)
{
return(str_replace($m[1], base64url_encode($m[1]), $m[0]));
}
+ /**
+ * @param string $m string
+ *
+ * @return string base64 decoded string
+ */
private static function decode($m)
{
return(str_replace($m[1], base64url_decode($m[1]), $m[0]));
/**
* @brief expand <3333 to the correct number of hearts
*
- * @param string $x
+ * @param string $x string
*
* @return string HTML Output
*
* @todo: Rework because it doesn't work correctly
*/
- private static function preg_heart($x)
+ private static function pregHeart($x)
{
if (strlen($x[1]) == 1) {
return $x[0];
* 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;
* Set the app
*
* @param object $app App
+ *
+ * @return void
*/
- public static function set_app($app)
+ public static function setApp($app)
{
self::$app = $app;
}
* @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)
{
* @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)
{
* 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;
* 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') {
* 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) {
*
* 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.
* 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]);
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':
$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;
}
/**
* 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;
}
/**
* 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;
}
* 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;
}
*
* 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;
$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;
/**
* 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) {
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');
/**
* 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)
{
$result = array();
- $a = $this->get_app();
+ $a = $this->getApp();
$item = $this->getData();
$edited = false;
|| 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"));
$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']);
}
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 {
}
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 {
$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'));
}
}
if ($this->isToplevel()) {
- if ($conv->get_profile_owner() == local_user()) {
+ if ($conv->getProfileOwner() == local_user()) {
$isstarred = (($item['starred']) ? "starred" : "unstarred");
$star = array(
}
$tagger = '';
- if (feature_enabled($conv->get_profile_owner(), 'commtag')) {
+ if (feature_enabled($conv->getProfileOwner(), 'commtag')) {
$tagger = array(
'add' => t("add tag"),
'class' => "",
$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'));
'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'],
'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,
return $result;
}
+ /**
+ * @return integer
+ */
public function getId()
{
return $this->getDataValue('id');
}
+ /**
+ * @return boolean
+ */
public function isThreaded()
{
return $this->threaded;
/**
* Add a child item
+ *
+ * @param object $item The child item to add
+ *
+ * @return mixed
*/
public function addChild(Item $item)
{
/**
* Get a child by its ID
+ *
+ * @param integer $id The child id
+ *
+ * @return mixed
*/
public function getChild($id)
{
}
/**
- * Get all ou children
+ * Get all our children
+ *
+ * @return object
*/
public function getChildren()
{
/**
* Set our parent
+ *
+ * @param object $item The item to set as parent
+ *
+ * @return void
*/
protected function setParent($item)
{
/**
* Remove our parent
+ *
+ * @return void
*/
protected function removeParent()
{
/**
* Remove a child
+ *
+ * @param object $item The child to be removed
+ *
+ * @return boolean Success or failure
*/
public function removeChild($item)
{
/**
* Get parent item
+ *
+ * @return object
*/
protected function getParent()
{
}
/**
- * 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;
}
/**
- * get conversation
+ * Get conversation
+ *
+ * @return object
*/
public function getConversation()
{
* Get raw data
*
* We shouldn't need this
+ *
+ * @return array
*/
public function getData()
{
/**
* 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)
{
/**
* Set template
+ *
+ * @param object $name template name
+ *
+ * @return void
*/
private function setTemplate($name)
{
/**
* Get template
+ *
+ * @return object
*/
private function getTemplate()
{
/**
* Check if this is a toplevel post
+ *
+ * @return boolean
*/
private function isToplevel()
{
/**
* Check if this is writable
+ *
+ * @return boolean
*/
private function isWritable()
{
// 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()
{
/**
* Get the template for the comment box
+ *
+ * @return string
*/
private function getCommentBoxTemplate()
{
/**
* 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 '';
}
$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;
/*
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']),
'$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))
);
}
return $comment_box;
}
+ /**
+ * @return string
+ */
private function getRedirectUrl()
{
return $this->redirect_url;
/**
* 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.
}
}
+ /**
+ * @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;
'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']
/**
* @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)
/**
* @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
*
/**
* @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)
/**
* @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
*
*
* @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);
/**
* @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 ";
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())
);
/**
* @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
*
{
$ident = 'personal';
$total = $this->personalTotal($seen);
- $sql_extra = $this->_personal_sql_extra();
+ $sql_extra = $this->personalSqlExtra();
$notifs = array();
$sql_seen = "";
/**
* @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)
/**
* @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
*
/**
* @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)
/**
* @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();
<?php
+/**
+ * @file src/Core/PConfig.php
+ */
namespace Friendica\Core;
use Friendica\Database\DBM;
* 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;
/**
* 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));
* 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) {
*
* @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.
* 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)) {
<?php
+/**
+ * @file src/Core/System.php
+ */
namespace Friendica\Core;
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)) {
* @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);
}
/**
* @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.