/**
* @file include/conversation.php
*/
+
use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
+use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
-use Friendica\Object\Thread;
use Friendica\Object\Post;
+use Friendica\Object\Thread;
+use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Temporal;
+use Friendica\Util\XML;
-require_once "include/bbcode.php";
require_once "include/acl_selectors.php";
function item_extract_images($body) {
$newbody = '';
$cnt = 1;
- $pos = get_bb_tag_pos($origbody, 'url', 1);
+ $pos = BBCode::getTagPosition($origbody, 'url', 0);
while ($pos !== false && $cnt < 1000) {
$search = '/\[url\=(.*?)\]\[!#saved_image([0-9]*)#!\]\[\/url\]' . '/is';
$newbody .= $subject;
$cnt++;
- $pos = get_bb_tag_pos($origbody, 'url', 1);
+ // Isn't this supposed to use $cnt value for $occurrences? - @MrPetovan
+ $pos = BBCode::getTagPosition($origbody, 'url', 0);
}
$newbody .= $origbody;
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
- $obj = parse_xml_string($xmlhead.$item['object']);
- $links = parse_xml_string($xmlhead."<links>".unxmlify($obj->link)."</links>");
+ $obj = XML::parseString($xmlhead.$item['object']);
+ $links = XML::parseString($xmlhead."<links>".unxmlify($obj->link)."</links>");
$Bname = $obj->title;
$Blink = ""; $Bphoto = "";
$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
- $obj = parse_xml_string($xmlhead.$item['object']);
- $links = parse_xml_string($xmlhead."<links>".unxmlify($obj->link)."</links>");
+ $obj = XML::parseString($xmlhead.$item['object']);
+ $links = XML::parseString($xmlhead."<links>".unxmlify($obj->link)."</links>");
$Bname = $obj->title;
$Blink = "";
}
$plink = '[url=' . $obj['plink'] . ']' . $post_type . '[/url]';
- $parsedobj = parse_xml_string($xmlhead.$item['object']);
+ $parsedobj = XML::parseString($xmlhead.$item['object']);
$tag = sprintf('#[url=%s]%s[/url]', $parsedobj->id, $parsedobj->content);
$item['body'] = L10n::t('%1$s tagged %2$s\'s %3$s with %4$s', $author, $objauthor, $plink, $tag );
$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
- $obj = parse_xml_string($xmlhead.$item['object']);
+ $obj = XML::parseString($xmlhead.$item['object']);
if (strlen($obj->id)) {
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($obj->id),
$photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is";
if (preg_match($photo_pattern, $item['body'])) {
$photo_replace = '[url=' . Profile::zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]';
- $item['body'] = bb_tag_preg_replace($photo_pattern, $photo_replace, 'url', $item['body']);
+ $item['body'] = BBCode::pregReplaceInTag($photo_pattern, $photo_replace, 'url', $item['body']);
}
// add sparkle links to appropriate permalinks
`item`.`forum_mode`,
`item`.`mention`,
`item`.`global`,
-`item`.`gcontact-id`,
`item`.`shadow`,
*/
*
*/
function conversation(App $a, $items, $mode, $update, $preview = false) {
- require_once 'include/bbcode.php';
require_once 'mod/proxy.php';
$ssl_state = ((local_user()) ? true : false);
. " var profile_page = 1; </script>";
}
} elseif ($mode === 'community') {
- if (!$community_readonly) {
- $items = community_add_items($items);
- }
+ $items = community_add_items($items);
$profile_owner = 0;
if (!$update) {
$live_update_div = '<div id="live-community"></div>' . "\r\n"
$page_template = get_markup_template("conversation.tpl");
if ($items && count($items)) {
- $community_readonly = ($mode === 'community');
-
- // Currently behind a config value. This allows the commenting and sharing of every public item.
- if (Config::get('system', 'comment_public')) {
- if ($mode === 'community') {
- $community_readonly = false;
- $writable = true;
- } else {
- $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN]);
- }
+ if ($mode === 'community') {
+ $writable = true;
} else {
- $writable = false;
+ $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN]);
}
if (!local_user()) {
$writable = false;
}
- if (in_array($mode, ['network-new', 'search', 'contact-posts']) || $community_readonly) {
+ if (in_array($mode, ['network-new', 'search', 'contact-posts'])) {
/*
* "New Item View" on network page or search page results
* - just loop through the items and format them minimally for display
*/
- /// @TODO old lost code?
- // $tpl = get_markup_template('search_item.tpl');
$tpl = 'search_item.tpl';
foreach ($items as $item) {
'categories' => $categories,
'folders' => $folders,
'text' => strip_tags($body_e),
- 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'),
- 'ago' => (($item['app']) ? L10n::t('%s from %s', relative_date($item['created']),$item['app']) : relative_date($item['created'])),
+ 'localtime' => DateTimeFormat::local($item['created'], 'r'),
+ 'ago' => (($item['app']) ? L10n::t('%s from %s', Temporal::getRelativeDate($item['created']),$item['app']) : Temporal::getRelativeDate($item['created'])),
'location' => $location_e,
'indent' => '',
'owner_name' => $owner_name_e,
foreach ($parents AS $parent) {
$thread_items = dba::p(item_query()." AND `item`.`uid` = ?
AND `item`.`parent-uri` = ?
+ AND NOT `author`.`hidden` AND NOT `author`.`blocked`
ORDER BY `item`.`commented` DESC LIMIT ".intval($max_comments + 1),
local_user(),
$parent['uri']
* @param array $arr = array of pre-linked names of likers/dislikers
* @param string $type = one of 'like, 'dislike', 'attendyes', 'attendno', 'attendmaybe'
* @param int $id = item id
- * @return formatted text
+ * @return string formatted text
*/
function format_like($cnt, array $arr, $type, $id) {
$o = '';