* @file include/text.php
*/
use Friendica\App;
-use Friendica\Content\Features;
+use Friendica\Content\ContactSelector;
+use Friendica\Content\Feature;
use Friendica\Content\Smilies;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
+use Friendica\Util\Map;
require_once "include/friendica_smarty.php";
-require_once "include/map.php";
require_once "mod/proxy.php";
require_once "include/conversation.php";
function micropro($contact, $redirect = false, $class = '', $textmode = false) {
// Use the contact URL if no address is available
- if ($contact["addr"] == "") {
+ if (!x($contact, "addr")) {
$contact["addr"] = $contact["url"];
}
$redir = false;
if ($redirect) {
- $a = get_app();
$redirect_url = 'redir/' . $contact['id'];
if (local_user() && ($contact['uid'] == local_user()) && ($contact['network'] === NETWORK_DFRN)) {
$redir = true;
}
return replace_macros(get_markup_template(($textmode)?'micropro_txt.tpl':'micropro_img.tpl'),array(
- '$click' => (($contact['click']) ? $contact['click'] : ''),
+ '$click' => defaults($contact, 'click', ''),
'$class' => $class,
'$url' => $url,
'$photo' => proxy_url($contact['thumb'], false, PROXY_SIZE_THUMB),
* @param boolean $savedsearch show save search button
*/
function search($s, $id = 'search-box', $url = 'search', $save = false, $aside = true) {
- $a = get_app();
-
$values = array(
'$s' => htmlspecialchars($s),
'$id' => $id,
}
/**
- * Check if $x is a valid email string
+ * @brief Check for a valid email string
*
- * @param string $x
+ * @param string $email_address
* @return boolean
*/
-function valid_email($x){
-
- /// @TODO Removed because Fabio told me so.
- //if (Config::get('system','disable_email_validation'))
- // return true;
- return preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/', $x);
+function valid_email($email_address)
+{
+ return preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/', $email_address);
}
return $arr;
}
-/**
- * Load moods
- * @return array index is mood, value is translated mood
- * @hook mood_verbs moods array
- */
-function get_mood_verbs() {
-
- $arr = array(
- 'happy' => t('happy'),
- 'sad' => t('sad'),
- 'mellow' => t('mellow'),
- 'tired' => t('tired'),
- 'perky' => t('perky'),
- 'angry' => t('angry'),
- 'stupefied' => t('stupified'),
- 'puzzled' => t('puzzled'),
- 'interested' => t('interested'),
- 'bitter' => t('bitter'),
- 'cheerful' => t('cheerful'),
- 'alive' => t('alive'),
- 'annoyed' => t('annoyed'),
- 'anxious' => t('anxious'),
- 'cranky' => t('cranky'),
- 'disturbed' => t('disturbed'),
- 'frustrated' => t('frustrated'),
- 'motivated' => t('motivated'),
- 'relaxed' => t('relaxed'),
- 'surprised' => t('surprised'),
- );
-
- call_hooks('mood_verbs', $arr);
- return $arr;
-}
-
/**
* @brief Translate days and months names.
*
*/
function day_short_translate($s) {
$ret = str_replace(array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'),
- array(t('Mon'), t('Tue'), t('Wed'), t('Thu'), t('Fri'), t('Sat'), t('Sund')),
+ array(t('Mon'), t('Tue'), t('Wed'), t('Thu'), t('Fri'), t('Sat'), t('Sun')),
$s);
$ret = str_replace(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov','Dec'),
array(t('Jan'), t('Feb'), t('Mar'), t('Apr'), t('May'), ('Jun'), t('Jul'), t('Aug'), t('Sep'), t('Oct'), t('Nov'), t('Dec')),
}
}
-function put_item_in_cache(&$item, $update = false) {
-
- if (($item["rendered-hash"] != hash("md5", $item["body"])) || ($item["rendered-hash"] == "") ||
- ($item["rendered-html"] == "") || Config::get("system", "ignore_cache")) {
+function put_item_in_cache(&$item, $update = false)
+{
+ $rendered_hash = defaults($item, 'rendered-hash', '');
+ if ($rendered_hash == ''
+ || $item["rendered-html"] == ""
+ || $rendered_hash != hash("md5", $item["body"])
+ || Config::get("system", "ignore_cache")
+ ) {
// The function "redir_private_images" changes the body.
// I'm not sure if we should store it permanently, so we save the old value.
$body = $item["body"];
// Map.
if (strpos($s, '<div class="map">') !== false && x($item, 'coord')) {
- $x = generate_map(trim($item['coord']));
+ $x = Map::byCoordinates(trim($item['coord']));
if ($x) {
$s = preg_replace('/\<div class\=\"map\"\>/', '$0' . $x, $s);
}
* ]
* ]
*/
-function get_cats_and_terms($item) {
-
- $a = get_app();
+function get_cats_and_terms($item)
+{
$categories = array();
$folders = array();
/**
- * transorm link href and img src from relative to absolute
+ * transform link href and img src from relative to absolute
*
* @param string $text
* @param string $base base url
function file_tag_save_file($uid, $item, $file) {
require_once "include/files.php";
- $result = false;
- if (! intval($uid))
+ if (! intval($uid)) {
return false;
+ }
+
$r = q("SELECT `file` FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($item),
intval($uid)
function file_tag_unsave_file($uid, $item, $file, $cat = false) {
require_once "include/files.php";
- $result = false;
- if (! intval($uid))
+ if (! intval($uid)) {
return false;
+ }
if ($cat == true) {
$pattern = '<' . file_tag_encode($file) . '>' ;
$termtype = TERM_FILE;
}
-
$r = q("SELECT `file` FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($item),
intval($uid)
dbesc($file),
intval(TERM_OBJ_POST),
intval($termtype),
- intval($uid));
-
+ intval($uid)
+ );
if (!DBM::is_result($r)) {
$saved = PConfig::get($uid, 'system', 'filetags');
PConfig::set($uid, 'system', 'filetags', str_replace($pattern, '', $saved));
}
function formatBytes($bytes, $precision = 2) {
- $units = array('B', 'KB', 'MB', 'GB', 'TB');
+ $units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
*/
function format_network_name($network, $url = 0) {
if ($network != "") {
- require_once 'include/contact_selectors.php';
if ($url != "") {
- $network_name = '<a href="'.$url.'">'.network_to_name($network, $url)."</a>";
+ $network_name = '<a href="'.$url.'">'.ContactSelector::networkToName($network, $url)."</a>";
} else {
- $network_name = network_to_name($network);
+ $network_name = ContactSelector::networkToName($network);
}
return $network_name;
}
-
}
/**