mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:15:14 +00:00
rework the conversation object stuff at a high level - still needs a bit of refactoring
This commit is contained in:
parent
bc20cf9fa3
commit
d8ace38041
21 changed files with 44 additions and 98 deletions
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Zotlabs\Project;
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
class System {
|
||||
|
|
@ -1,17 +1,15 @@
|
|||
<?php /** @file */
|
||||
|
||||
if(class_exists('Item'))
|
||||
return;
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
require_once('include/BaseObject.php');
|
||||
require_once('include/text.php');
|
||||
require_once('boot.php');
|
||||
|
||||
/**
|
||||
* An item
|
||||
* A thread item
|
||||
*/
|
||||
|
||||
class Item extends BaseObject {
|
||||
class ThreadItem {
|
||||
|
||||
public $data = array();
|
||||
private $template = 'conv_item.tpl';
|
||||
private $comment_box_template = 'comment_item.tpl';
|
||||
|
@ -32,7 +30,6 @@ class Item extends BaseObject {
|
|||
|
||||
|
||||
public function __construct($data) {
|
||||
$a = $this->get_app();
|
||||
|
||||
$this->data = $data;
|
||||
$this->toplevel = ($this->get_id() == $this->get_data_value('parent'));
|
||||
|
@ -49,7 +46,7 @@ class Item extends BaseObject {
|
|||
continue;
|
||||
}
|
||||
|
||||
$child = new Item($item);
|
||||
$child = new ThreadItem($item);
|
||||
$this->add_child($child);
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +64,6 @@ class Item extends BaseObject {
|
|||
|
||||
$result = array();
|
||||
|
||||
$a = $this->get_app();
|
||||
$item = $this->get_data();
|
||||
|
||||
$commentww = '';
|
||||
|
@ -219,7 +215,8 @@ class Item extends BaseObject {
|
|||
);
|
||||
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$indent = 'comment';
|
||||
}
|
||||
|
||||
|
@ -675,7 +672,6 @@ class Item extends BaseObject {
|
|||
|
||||
$template = get_markup_template($this->get_comment_box_template());
|
||||
|
||||
$a = $this->get_app();
|
||||
$observer = $conv->get_observer();
|
||||
|
||||
$qc = ((local_channel()) ? get_pconfig(local_channel(),'system','qcomment') : null);
|
||||
|
@ -714,7 +710,7 @@ class Item extends BaseObject {
|
|||
'$feature_encrypt' => ((feature_enabled($conv->get_profile_owner(),'content_encrypt')) ? true : false),
|
||||
'$encrypt' => t('Encrypt text'),
|
||||
'$cipher' => $conv->get_cipher(),
|
||||
'$sourceapp' => App::$sourcename
|
||||
'$sourceapp' => \App::$sourcename
|
||||
|
||||
));
|
||||
|
|
@ -1,11 +1,8 @@
|
|||
<?php /** @file */
|
||||
|
||||
if(class_exists('Conversation'))
|
||||
return;
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
require_once('boot.php');
|
||||
require_once('include/BaseObject.php');
|
||||
require_once('include/ItemObject.php');
|
||||
require_once('include/text.php');
|
||||
require_once('include/items.php');
|
||||
|
||||
|
@ -14,7 +11,7 @@ require_once('include/items.php');
|
|||
*
|
||||
*/
|
||||
|
||||
class Conversation extends BaseObject {
|
||||
class ThreadStream {
|
||||
|
||||
private $threads = array();
|
||||
private $mode = null;
|
||||
|
@ -46,9 +43,7 @@ class Conversation extends BaseObject {
|
|||
if($this->get_mode() == $mode)
|
||||
return;
|
||||
|
||||
$a = $this->get_app();
|
||||
|
||||
$this->observer = App::get_observer();
|
||||
$this->observer = \App::get_observer();
|
||||
$ob_hash = (($this->observer) ? $this->observer['xchan_hash'] : '');
|
||||
|
||||
switch($mode) {
|
||||
|
@ -57,7 +52,7 @@ class Conversation extends BaseObject {
|
|||
$this->writable = true;
|
||||
break;
|
||||
case 'channel':
|
||||
$this->profile_owner = App::$profile['profile_uid'];
|
||||
$this->profile_owner = \App::$profile['profile_uid'];
|
||||
$this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments');
|
||||
break;
|
||||
case 'display':
|
||||
|
@ -67,7 +62,7 @@ class Conversation extends BaseObject {
|
|||
$this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments');
|
||||
break;
|
||||
case 'page':
|
||||
$this->profile_owner = App::$profile['uid'];
|
||||
$this->profile_owner = \App::$profile['uid'];
|
||||
$this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments');
|
||||
break;
|
||||
default:
|
|
@ -64,7 +64,7 @@ class Dav extends \Zotlabs\Web\Controller {
|
|||
|
||||
|
||||
$auth = new \Zotlabs\Storage\BasicAuth();
|
||||
$auth->setRealm(ucfirst(\Zotlabs\Project\System::get_platform_name()) . 'WebDAV');
|
||||
$auth->setRealm(ucfirst(\Zotlabs\Lib\System::get_platform_name()) . 'WebDAV');
|
||||
|
||||
// $authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function($userName,$password) {
|
||||
// if(account_verify_password($userName,$password))
|
||||
|
|
|
@ -37,7 +37,7 @@ class Help extends \Zotlabs\Web\Controller {
|
|||
$path = trim(substr($dirname,4),'/');
|
||||
|
||||
$o .= '<li><a href="help/' . (($path) ? $path . '/' : '') . $fname . '" >' . ucwords(str_replace('_',' ',notags($fname))) . '</a><br />' .
|
||||
str_replace('$Projectname',\Zotlabs\Project\System::get_platform_name(),substr($rr['text'],0,200)) . '...<br /><br /></li>';
|
||||
str_replace('$Projectname',\Zotlabs\Lib\System::get_platform_name(),substr($rr['text'],0,200)) . '...<br /><br /></li>';
|
||||
|
||||
}
|
||||
$o .= '</ul>';
|
||||
|
|
|
@ -115,7 +115,7 @@ class Linkinfo extends \Zotlabs\Web\Controller {
|
|||
|
||||
// If this is a Red site, use zrl rather than url so they get zids sent to them by default
|
||||
|
||||
if( x($siteinfo,'generator') && (strpos($siteinfo['generator'], \Zotlabs\Project\System::get_platform_name() . ' ') === 0))
|
||||
if( x($siteinfo,'generator') && (strpos($siteinfo['generator'], \Zotlabs\Lib\System::get_platform_name() . ' ') === 0))
|
||||
$template = str_replace('url','zrl',$template);
|
||||
|
||||
if($siteinfo["title"] == "") {
|
||||
|
|
|
@ -31,7 +31,7 @@ class Pubsites extends \Zotlabs\Web\Controller {
|
|||
$o .= '<table class="table table-striped table-hover"><tr><td>' . t('Hub URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td><td>' . t('Software') . '</td><td colspan="2">' . t('Ratings') . '</td></tr>';
|
||||
if($j['sites']) {
|
||||
foreach($j['sites'] as $jj) {
|
||||
if(strpos($jj['project'],\Zotlabs\Project\System::get_platform_name()) === false)
|
||||
if(strpos($jj['project'],\Zotlabs\Lib\System::get_platform_name()) === false)
|
||||
continue;
|
||||
$host = strtolower(substr($jj['url'],strpos($jj['url'],'://')+3));
|
||||
$rate_links = ((local_channel()) ? '<td><a href="rate?f=&target=' . $host . '" class="btn-btn-default"><i class="fa fa-check-square-o"></i> ' . t('Rate') . '</a></td>' : '');
|
||||
|
|
|
@ -6,7 +6,7 @@ class Rsd_xml extends \Zotlabs\Web\Controller {
|
|||
function init() {
|
||||
header ("Content-Type: text/xml");
|
||||
echo replace_macros(get_markup_template('rsd.tpl'),array(
|
||||
'$project' => \Zotlabs\Project\System::get_platform_name(),
|
||||
'$project' => \Zotlabs\Lib\System::get_platform_name(),
|
||||
'$baseurl' => z_root(),
|
||||
'$apipath' => z_root() . '/api/'
|
||||
));
|
||||
|
|
|
@ -1047,7 +1047,7 @@ class Settings extends \Zotlabs\Web\Controller {
|
|||
|
||||
'$h_prv' => t('Security and Privacy Settings'),
|
||||
'$permissions_set' => $permissions_set,
|
||||
'$server_role' => \Zotlabs\Project\System::get_server_role(),
|
||||
'$server_role' => \Zotlabs\Lib\System::get_server_role(),
|
||||
'$perms_set_msg' => t('Your permissions are already configured. Click to view/adjust'),
|
||||
|
||||
'$hide_presence' => array('hide_presence', t('Hide my online presence'),$hide_presence, t('Prevents displaying in your profile that you are online'), $yes_no),
|
||||
|
|
|
@ -16,10 +16,10 @@ class Siteinfo extends \Zotlabs\Web\Controller {
|
|||
function get() {
|
||||
|
||||
if(! get_config('system','hidden_version_siteinfo')) {
|
||||
$version = sprintf( t('Version %s'), \Zotlabs\Project\System::get_project_version());
|
||||
$version = sprintf( t('Version %s'), \Zotlabs\Lib\System::get_project_version());
|
||||
if(@is_dir('.git') && function_exists('shell_exec')) {
|
||||
$commit = @shell_exec('git log -1 --format="%h"');
|
||||
$tag = \Zotlabs\Project\System::get_std_version(); // @shell_exec('git describe --tags --abbrev=0');
|
||||
$tag = \Zotlabs\Lib\System::get_std_version(); // @shell_exec('git describe --tags --abbrev=0');
|
||||
}
|
||||
if(! isset($commit) || strlen($commit) > 16)
|
||||
$commit = '';
|
||||
|
|
8
boot.php
8
boot.php
|
@ -37,7 +37,6 @@ require_once('include/nav.php');
|
|||
require_once('include/cache.php');
|
||||
require_once('include/permissions.php');
|
||||
require_once('library/Mobile_Detect/Mobile_Detect.php');
|
||||
require_once('include/BaseObject.php');
|
||||
require_once('include/features.php');
|
||||
require_once('include/taxonomy.php');
|
||||
require_once('include/identity.php');
|
||||
|
@ -903,13 +902,10 @@ class App {
|
|||
|
||||
self::head_set_icon('/images/hz-32.png');
|
||||
|
||||
BaseObject::set_app($this);
|
||||
|
||||
/*
|
||||
* register template engines
|
||||
*/
|
||||
|
||||
|
||||
spl_autoload_register('ZotlabsAutoloader::loader');
|
||||
|
||||
self::$meta= new Zotlabs\Web\HttpMeta();
|
||||
|
@ -1080,7 +1076,7 @@ class App {
|
|||
if(! self::$meta->get_field('og:title'))
|
||||
self::$meta->set('og:title',self::$page['title']);
|
||||
|
||||
self::$meta->set('generator', Zotlabs\Project\System::get_platform_name());
|
||||
self::$meta->set('generator', Zotlabs\Lib\System::get_platform_name());
|
||||
|
||||
/* put the head template at the beginning of page['htmlhead']
|
||||
* since the code added by the modules frequently depends on it
|
||||
|
@ -1095,7 +1091,7 @@ class App {
|
|||
'$local_channel' => local_channel(),
|
||||
'$metas' => self::$meta->get(),
|
||||
'$update_interval' => $interval,
|
||||
'osearch' => sprintf( t('Search %1$s (%2$s)','opensearch'), Zotlabs\Project\System::get_site_name(), t('$Projectname','opensearch')),
|
||||
'osearch' => sprintf( t('Search %1$s (%2$s)','opensearch'), Zotlabs\Lib\System::get_site_name(), t('$Projectname','opensearch')),
|
||||
'$icon' => head_get_icon(),
|
||||
'$head_css' => head_get_css(),
|
||||
'$head_js' => head_get_js(),
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
<?php /** @file */
|
||||
|
||||
if(class_exists('BaseObject'))
|
||||
return;
|
||||
|
||||
require_once('boot.php');
|
||||
|
||||
/**
|
||||
* Basic object
|
||||
*
|
||||
* Contains what is usefull to any object
|
||||
*/
|
||||
class BaseObject {
|
||||
private static $app = null;
|
||||
|
||||
/**
|
||||
* Get the app
|
||||
*
|
||||
* Same as get_app from boot.php
|
||||
*/
|
||||
public function get_app() {
|
||||
if(self::$app)
|
||||
return self::$app;
|
||||
|
||||
global $a;
|
||||
self::$app = $a;
|
||||
|
||||
return self::$app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the app
|
||||
*/
|
||||
public static function set_app($app) {
|
||||
self::$app = $app;
|
||||
}
|
||||
}
|
||||
|
|
@ -2107,10 +2107,10 @@ require_once('include/api_auth.php');
|
|||
'private' => $private, 'textlimit' => $textlimit, 'sslserver' => $sslserver, 'ssl' => $ssl,
|
||||
'shorturllength' => '30',
|
||||
'hubzilla' => array(
|
||||
'PLATFORM_NAME' => Zotlabs\Project\System::get_platform_name(),
|
||||
'STD_VERSION' => Zotlabs\Project\System::get_project_version(),
|
||||
'PLATFORM_NAME' => Zotlabs\Lib\System::get_platform_name(),
|
||||
'STD_VERSION' => Zotlabs\Lib\System::get_project_version(),
|
||||
'ZOT_REVISION' => ZOT_REVISION,
|
||||
'DB_UPDATE_VERSION' => Zotlabs\Project\System::get_update_version()
|
||||
'DB_UPDATE_VERSION' => Zotlabs\Lib\System::get_update_version()
|
||||
)
|
||||
));
|
||||
|
||||
|
@ -2143,12 +2143,12 @@ require_once('include/api_auth.php');
|
|||
|
||||
if($type === 'xml') {
|
||||
header("Content-type: application/xml");
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" . '<version>' . Zotlabs\Project\System::get_project_version() . '</version>' . "\r\n";
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" . '<version>' . Zotlabs\Lib\System::get_project_version() . '</version>' . "\r\n";
|
||||
killme();
|
||||
}
|
||||
elseif($type === 'json') {
|
||||
header("Content-type: application/json");
|
||||
echo '"' . Zotlabs\Project\System::get_project_version() . '"';
|
||||
echo '"' . Zotlabs\Lib\System::get_project_version() . '"';
|
||||
killme();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -754,10 +754,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||
// Normal View
|
||||
// logger('conv: items: ' . print_r($items,true));
|
||||
|
||||
require_once('include/ConversationObject.php');
|
||||
require_once('include/ItemObject.php');
|
||||
|
||||
$conv = new Conversation($mode, $preview, $prepared_item);
|
||||
$conv = new Zotlabs\Lib\ThreadStream($mode, $preview, $prepared_item);
|
||||
|
||||
// In the display mode we don't have a profile owner.
|
||||
|
||||
|
@ -806,7 +803,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||
|
||||
if($item['id'] == $item['parent']) {
|
||||
|
||||
$item_object = new Item($item);
|
||||
$item_object = new Zotlabs\Lib\ThreadItem($item);
|
||||
$conv->add_thread($item_object);
|
||||
if($page_mode === 'list') {
|
||||
$item_object->set_template('conv_list.tpl');
|
||||
|
|
|
@ -529,7 +529,7 @@ function notification($params) {
|
|||
$tpl = get_markup_template('email_notify_html.tpl');
|
||||
$email_html_body = replace_macros($tpl,array(
|
||||
'$banner' => $datarray['banner'],
|
||||
'$notify_icon' => Zotlabs\Project\System::get_notify_icon(),
|
||||
'$notify_icon' => Zotlabs\Lib\System::get_notify_icon(),
|
||||
'$product' => $datarray['product'],
|
||||
'$preamble' => $datarray['preamble'],
|
||||
'$sitename' => $datarray['sitename'],
|
||||
|
|
|
@ -67,7 +67,7 @@ function ical_wrapper($ev) {
|
|||
$o .= "BEGIN:VCALENDAR";
|
||||
$o .= "\r\nVERSION:2.0";
|
||||
$o .= "\r\nMETHOD:PUBLISH";
|
||||
$o .= "\r\nPRODID:-//" . get_config('system','sitename') . "//" . Zotlabs\Project\System::get_platform_name() . "//" . strtoupper(App::$language). "\r\n";
|
||||
$o .= "\r\nPRODID:-//" . get_config('system','sitename') . "//" . Zotlabs\Lib\System::get_platform_name() . "//" . strtoupper(App::$language). "\r\n";
|
||||
if(array_key_exists('start', $ev))
|
||||
$o .= format_event_ical($ev);
|
||||
else {
|
||||
|
|
|
@ -88,8 +88,8 @@ function get_feed_for($channel, $observer_hash, $params) {
|
|||
$atom = '';
|
||||
|
||||
$atom .= replace_macros($feed_template, array(
|
||||
'$version' => xmlify(Zotlabs\Project\System::get_project_version()),
|
||||
'$red' => xmlify(Zotlabs\Project\System::get_platform_name()),
|
||||
'$version' => xmlify(Zotlabs\Lib\System::get_project_version()),
|
||||
'$red' => xmlify(Zotlabs\Lib\System::get_platform_name()),
|
||||
'$feed_id' => xmlify($channel['xchan_url']),
|
||||
'$feed_title' => xmlify($channel['channel_name']),
|
||||
'$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 'now' , ATOM_TIME)) ,
|
||||
|
|
|
@ -491,7 +491,7 @@ function identity_basic_export($channel_id, $items = false) {
|
|||
|
||||
// use constants here as otherwise we will have no idea if we can import from a site
|
||||
// with a non-standard platform and version.
|
||||
$ret['compatibility'] = array('project' => PLATFORM_NAME, 'version' => STD_VERSION, 'database' => DB_UPDATE_VERSION, 'server_role' => Zotlabs\Project\System::get_server_role());
|
||||
$ret['compatibility'] = array('project' => PLATFORM_NAME, 'version' => STD_VERSION, 'database' => DB_UPDATE_VERSION, 'server_role' => Zotlabs\Lib\System::get_server_role());
|
||||
|
||||
$r = q("select * from channel where channel_id = %d limit 1",
|
||||
intval($channel_id)
|
||||
|
|
|
@ -189,7 +189,7 @@ function t($s, $ctx = '') {
|
|||
|
||||
function translate_projectname($s) {
|
||||
|
||||
return str_replace(array('$projectname','$Projectname'),array(Zotlabs\Project\System::get_platform_name(),ucfirst(Zotlabs\Project\System::get_platform_name())),$s);
|
||||
return str_replace(array('$projectname','$Projectname'),array(Zotlabs\Lib\System::get_platform_name(),ucfirst(Zotlabs\Lib\System::get_platform_name())),$s);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1839,7 +1839,7 @@ function format_and_send_email($sender,$xchan,$item) {
|
|||
$tpl = get_markup_template('email_notify_html.tpl');
|
||||
$email_html_body = replace_macros($tpl,array(
|
||||
'$banner' => $banner,
|
||||
'$notify_icon' => Zotlabs\Project\System::get_notify_icon(),
|
||||
'$notify_icon' => Zotlabs\Lib\System::get_notify_icon(),
|
||||
'$product' => $product,
|
||||
'$preamble' => '',
|
||||
'$sitename' => $sitename,
|
||||
|
@ -1990,8 +1990,8 @@ function get_site_info() {
|
|||
$site_info = get_config('system','info');
|
||||
$site_name = get_config('system','sitename');
|
||||
if(! get_config('system','hidden_version_siteinfo')) {
|
||||
$version = Zotlabs\Project\System::get_project_version();
|
||||
$tag = Zotlabs\Project\System::get_std_version();
|
||||
$version = Zotlabs\Lib\System::get_project_version();
|
||||
$tag = Zotlabs\Lib\System::get_std_version();
|
||||
|
||||
if(@is_dir('.git') && function_exists('shell_exec')) {
|
||||
$commit = trim( @shell_exec('git log -1 --format="%h"'));
|
||||
|
@ -2027,7 +2027,7 @@ function get_site_info() {
|
|||
$data = Array(
|
||||
'version' => $version,
|
||||
'version_tag' => $tag,
|
||||
'server_role' => Zotlabs\Project\System::get_server_role(),
|
||||
'server_role' => Zotlabs\Lib\System::get_server_role(),
|
||||
'commit' => $commit,
|
||||
'url' => z_root(),
|
||||
'plugins' => $visible_plugins,
|
||||
|
@ -2041,7 +2041,7 @@ function get_site_info() {
|
|||
'locked_features' => $locked_features,
|
||||
'admin' => $admin,
|
||||
'site_name' => (($site_name) ? $site_name : ''),
|
||||
'platform' => Zotlabs\Project\System::get_platform_name(),
|
||||
'platform' => Zotlabs\Lib\System::get_platform_name(),
|
||||
'dbdriver' => $db->getdriver(),
|
||||
'lastpoll' => get_config('system','lastpoll'),
|
||||
'info' => (($site_info) ? $site_info : ''),
|
||||
|
|
|
@ -3924,7 +3924,7 @@ function zotinfo($arr) {
|
|||
$ret['site']['channels'] = channel_total();
|
||||
|
||||
|
||||
$ret['site']['version'] = Zotlabs\Project\System::get_platform_name() . ' ' . STD_VERSION . '[' . DB_UPDATE_VERSION . ']';
|
||||
$ret['site']['version'] = Zotlabs\Lib\System::get_platform_name() . ' ' . STD_VERSION . '[' . DB_UPDATE_VERSION . ']';
|
||||
|
||||
$ret['site']['admin'] = get_config('system','admin_email');
|
||||
|
||||
|
@ -3944,7 +3944,7 @@ function zotinfo($arr) {
|
|||
$ret['site']['sellpage'] = get_config('system','sellpage');
|
||||
$ret['site']['location'] = get_config('system','site_location');
|
||||
$ret['site']['realm'] = get_directory_realm();
|
||||
$ret['site']['project'] = Zotlabs\Project\System::get_platform_name() . Zotlabs\Project\System::get_server_role();
|
||||
$ret['site']['project'] = Zotlabs\Lib\System::get_platform_name() . Zotlabs\Lib\System::get_server_role();
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue