aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-04-17 19:42:43 -0700
committerredmatrix <git@macgirvin.com>2016-04-17 19:42:43 -0700
commitd2e61122c5aef942ea8160fabb4dbac72fb37caa (patch)
treef3c0193842d55692ef76dca0516ed528e70b3324
parentc366bbaa54973239fbecdd2cbc3116343d7ca55a (diff)
parent521d404013bd677f26e1343a8612631f49ac2fca (diff)
downloadvolse-hubzilla-d2e61122c5aef942ea8160fabb4dbac72fb37caa.tar.gz
volse-hubzilla-d2e61122c5aef942ea8160fabb4dbac72fb37caa.tar.bz2
volse-hubzilla-d2e61122c5aef942ea8160fabb4dbac72fb37caa.zip
Merge commit '521d404' into dev
-rw-r--r--Zotlabs/Module/Channel.php (renamed from mod/channel.php)90
-rw-r--r--Zotlabs/Module/Update_channel.php (renamed from mod/update_channel.php)11
-rw-r--r--Zotlabs/Web/Controller.php12
-rw-r--r--Zotlabs/Web/Router.php64
-rwxr-xr-xinclude/items.php4
5 files changed, 115 insertions, 66 deletions
diff --git a/mod/channel.php b/Zotlabs/Module/Channel.php
index 9bc7332dc..cae561266 100644
--- a/mod/channel.php
+++ b/Zotlabs/Module/Channel.php
@@ -1,4 +1,6 @@
<?php
+namespace Zotlabs\Module;
+
require_once('include/contact_widgets.php');
require_once('include/items.php');
@@ -8,15 +10,16 @@ require_once('include/conversation.php');
require_once('include/acl_selectors.php');
require_once('include/permissions.php');
+class Channel extends \Zotlabs\Web\Controller {
-function channel_init(&$a) {
+function init() {
$which = null;
if(argc() > 1)
$which = argv(1);
if(! $which) {
if(local_channel()) {
- $channel = App::get_channel();
+ $channel = \App::get_channel();
if($channel && $channel['channel_address'])
$which = $channel['channel_address'];
}
@@ -27,19 +30,19 @@ function channel_init(&$a) {
}
$profile = 0;
- $channel = App::get_channel();
+ $channel = \App::get_channel();
if((local_channel()) && (argc() > 2) && (argv(2) === 'view')) {
$which = $channel['channel_address'];
$profile = argv(1);
}
- App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" title="' . t('Posts and comments') . '" href="' . z_root() . '/feed/' . $which . '" />' . "\r\n" ;
- App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" title="' . t('Only posts') . '" href="' . z_root() . '/feed/' . $which . '?top=1" />' . "\r\n" ;
+ \App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" title="' . t('Posts and comments') . '" href="' . z_root() . '/feed/' . $which . '" />' . "\r\n" ;
+ \App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" title="' . t('Only posts') . '" href="' . z_root() . '/feed/' . $which . '?top=1" />' . "\r\n" ;
// Not yet ready for prime time
-// App::$page['htmlhead'] .= '<link rel="openid.server" href="' . z_root() . '/id/' . $which .'?f=" />' . "\r\n" ;
-// App::$page['htmlhead'] .= '<link rel="openid.delegate" href="' . z_root() . '/channel/' . $which .'" />' . "\r\n" ;
+// \App::$page['htmlhead'] .= '<link rel="openid.server" href="' . z_root() . '/id/' . $which .'?f=" />' . "\r\n" ;
+// \App::$page['htmlhead'] .= '<link rel="openid.delegate" href="' . z_root() . '/channel/' . $which .'" />' . "\r\n" ;
// Run profile_load() here to make sure the theme is set before
// we start loading content
@@ -48,13 +51,13 @@ function channel_init(&$a) {
}
-function channel_content(&$a, $update = 0, $load = false) {
+function get($update = 0, $load = false) {
if($load)
$_SESSION['loadtime'] = datetime_convert();
- $checkjs = new Zotlabs\Web\CheckJS();
+ $checkjs = new \Zotlabs\Web\CheckJS();
$category = $datequery = $datequery2 = '';
@@ -76,27 +79,27 @@ function channel_content(&$a, $update = 0, $load = false) {
if($update) {
// Ensure we've got a profile owner if updating.
- App::$profile['profile_uid'] = App::$profile_uid = $update;
+ \App::$profile['profile_uid'] = \App::$profile_uid = $update;
}
else {
- if(App::$profile['profile_uid'] == local_channel()) {
+ if(\App::$profile['profile_uid'] == local_channel()) {
nav_set_selected('home');
}
}
- $is_owner = (((local_channel()) && (App::$profile['profile_uid'] == local_channel())) ? true : false);
+ $is_owner = (((local_channel()) && (\App::$profile['profile_uid'] == local_channel())) ? true : false);
- $channel = App::get_channel();
- $observer = App::get_observer();
+ $channel = \App::get_channel();
+ $observer = \App::get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
- $perms = get_all_perms(App::$profile['profile_uid'],$ob_hash);
+ $perms = get_all_perms(\App::$profile['profile_uid'],$ob_hash);
if(! $perms['view_stream']) {
// We may want to make the target of this redirect configurable
if($perms['view_profile']) {
notice( t('Insufficient permissions. Request redirected to profile page.') . EOL);
- goaway (z_root() . "/profile/" . App::$profile['channel_address']);
+ goaway (z_root() . "/profile/" . \App::$profile['channel_address']);
}
notice( t('Permission denied.') . EOL);
return;
@@ -105,9 +108,9 @@ function channel_content(&$a, $update = 0, $load = false) {
if(! $update) {
- $o .= profile_tabs($a, $is_owner, App::$profile['channel_address']);
+ $o .= profile_tabs($a, $is_owner, \App::$profile['channel_address']);
- $o .= common_friends_visitor_widget(App::$profile['profile_uid']);
+ $o .= common_friends_visitor_widget(\App::$profile['profile_uid']);
if($channel && $is_owner) {
$channel_acl = array(
@@ -125,15 +128,15 @@ function channel_content(&$a, $update = 0, $load = false) {
$x = array(
'is_owner' => $is_owner,
- 'allow_location' => ((($is_owner || $observer) && (intval(get_pconfig(App::$profile['profile_uid'],'system','use_browser_location')))) ? true : false),
- 'default_location' => (($is_owner) ? App::$profile['channel_location'] : ''),
- 'nickname' => App::$profile['channel_address'],
- 'lockstate' => (((strlen(App::$profile['channel_allow_cid'])) || (strlen(App::$profile['channel_allow_gid'])) || (strlen(App::$profile['channel_deny_cid'])) || (strlen(App::$profile['channel_deny_gid']))) ? 'lock' : 'unlock'),
- 'acl' => (($is_owner) ? populate_acl($channel_acl,true,((App::$profile['channel_r_stream'] & PERMS_PUBLIC) ? t('Public') : '')) : ''),
+ 'allow_location' => ((($is_owner || $observer) && (intval(get_pconfig(\App::$profile['profile_uid'],'system','use_browser_location')))) ? true : false),
+ 'default_location' => (($is_owner) ? \App::$profile['channel_location'] : ''),
+ 'nickname' => \App::$profile['channel_address'],
+ 'lockstate' => (((strlen(\App::$profile['channel_allow_cid'])) || (strlen(\App::$profile['channel_allow_gid'])) || (strlen(\App::$profile['channel_deny_cid'])) || (strlen(\App::$profile['channel_deny_gid']))) ? 'lock' : 'unlock'),
+ 'acl' => (($is_owner) ? populate_acl($channel_acl,true,((\App::$profile['channel_r_stream'] & PERMS_PUBLIC) ? t('Public') : '')) : ''),
'showacl' => (($is_owner) ? 'yes' : ''),
'bang' => '',
'visitor' => (($is_owner || $observer) ? true : false),
- 'profile_uid' => App::$profile['profile_uid'],
+ 'profile_uid' => \App::$profile['profile_uid'],
'editor_autocomplete' => true,
'bbco_autocomplete' => 'bbcode',
'bbcode' => true
@@ -150,18 +153,18 @@ function channel_content(&$a, $update = 0, $load = false) {
*/
$item_normal = item_normal();
- $sql_extra = item_permissions_sql(App::$profile['profile_uid']);
+ $sql_extra = item_permissions_sql(\App::$profile['profile_uid']);
- if(get_pconfig(App::$profile['profile_uid'],'system','channel_list_mode') && (! $mid))
+ if(get_pconfig(\App::$profile['profile_uid'],'system','channel_list_mode') && (! $mid))
$page_mode = 'list';
else
$page_mode = 'client';
- $abook_uids = " and abook.abook_channel = " . intval(App::$profile['profile_uid']) . " ";
+ $abook_uids = " and abook.abook_channel = " . intval(\App::$profile['profile_uid']) . " ";
$simple_update = (($update) ? " AND item_unseen = 1 " : '');
- App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . App::$query_string) . '" title="oembed" />' . "\r\n";
+ \App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string) . '" title="oembed" />' . "\r\n";
if($update && $_SESSION['loadtime'])
$simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) ";
@@ -174,7 +177,7 @@ function channel_content(&$a, $update = 0, $load = false) {
$r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d $item_normal
AND item_wall = 1 AND item_unseen = 1 $sql_extra limit 1",
dbesc($mid . '%'),
- intval(App::$profile['profile_uid'])
+ intval(\App::$profile['profile_uid'])
);
} else {
$r = q("SELECT distinct parent AS `item_id`, created from item
@@ -184,7 +187,7 @@ function channel_content(&$a, $update = 0, $load = false) {
AND (abook.abook_blocked = 0 or abook.abook_flags is null)
$sql_extra
ORDER BY created DESC",
- intval(App::$profile['profile_uid'])
+ intval(\App::$profile['profile_uid'])
);
$_SESSION['loadtime'] = datetime_convert();
}
@@ -207,15 +210,15 @@ function channel_content(&$a, $update = 0, $load = false) {
}
$itemspage = get_pconfig(local_channel(),'system','itemspage');
- App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
- $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
+ \App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
+ $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
if($load || ($checkjs->disabled())) {
if ($mid) {
$r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d $item_normal
AND item_wall = 1 $sql_extra limit 1",
dbesc($mid),
- intval(App::$profile['profile_uid'])
+ intval(\App::$profile['profile_uid'])
);
if (! $r) {
notice( t('Permission denied.') . EOL);
@@ -229,7 +232,7 @@ function channel_content(&$a, $update = 0, $load = false) {
AND (abook_blocked = 0 or abook.abook_flags is null)
$sql_extra $sql_extra2
ORDER BY created DESC $pager_sql ",
- intval(App::$profile['profile_uid'])
+ intval(\App::$profile['profile_uid'])
);
}
}
@@ -247,7 +250,7 @@ function channel_content(&$a, $update = 0, $load = false) {
WHERE `item`.`uid` = %d $item_normal
AND `item`.`parent` IN ( %s )
$sql_extra ",
- intval(App::$profile['profile_uid']),
+ intval(\App::$profile['profile_uid']),
dbesc($parents_str)
);
@@ -270,19 +273,19 @@ function channel_content(&$a, $update = 0, $load = false) {
// This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
// because browser prefetching might change it on us. We have to deliver it with the page.
- $maxheight = get_pconfig(App::$profile['profile_uid'],'system','channel_divmore_height');
+ $maxheight = get_pconfig(\App::$profile['profile_uid'],'system','channel_divmore_height');
if(! $maxheight)
$maxheight = 400;
$o .= '<div id="live-channel"></div>' . "\r\n";
- $o .= "<script> var profile_uid = " . App::$profile['profile_uid']
- . "; var netargs = '?f='; var profile_page = " . App::$pager['page']
+ $o .= "<script> var profile_uid = " . \App::$profile['profile_uid']
+ . "; var netargs = '?f='; var profile_page = " . \App::$pager['page']
. "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
- App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
+ \App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
'$baseurl' => z_root(),
'$pgtype' => 'channel',
- '$uid' => ((App::$profile['profile_uid']) ? App::$profile['profile_uid'] : '0'),
+ '$uid' => ((\App::$profile['profile_uid']) ? \App::$profile['profile_uid'] : '0'),
'$gid' => '0',
'$cid' => '0',
'$cmin' => '0',
@@ -294,7 +297,7 @@ function channel_content(&$a, $update = 0, $load = false) {
'$nouveau' => '0',
'$wall' => '1',
'$fh' => '0',
- '$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1),
+ '$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1),
'$search' => '',
'$order' => '',
'$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
@@ -348,7 +351,7 @@ function channel_content(&$a, $update = 0, $load = false) {
if((! $update) || ($checkjs->disabled())) {
$o .= alt_pager($a,count($items));
if ($mid && $items[0]['title'])
- App::$page['title'] = $items[0]['title'] . " - " . App::$page['title'];
+ \App::$page['title'] = $items[0]['title'] . " - " . \App::$page['title'];
}
if($mid)
@@ -356,3 +359,6 @@ function channel_content(&$a, $update = 0, $load = false) {
return $o;
}
+
+
+} \ No newline at end of file
diff --git a/mod/update_channel.php b/Zotlabs/Module/Update_channel.php
index 63a3735ea..b1b2d5103 100644
--- a/mod/update_channel.php
+++ b/Zotlabs/Module/Update_channel.php
@@ -1,5 +1,7 @@
<?php
+namespace Zotlabs\Module;
+
/**
* Module: update_profile
* Purpose: AJAX synchronisation of profile page
@@ -7,9 +9,9 @@
*/
-require_once('mod/channel.php');
+class Update_channel extends \Zotlabs\Web\Controller {
-function update_channel_content(&$a) {
+function get() {
$profile_uid = intval($_GET['p']);
$load = (((argc() > 1) && (argv(1) == 'load')) ? 1 : 0);
@@ -33,7 +35,9 @@ function update_channel_content(&$a) {
*
*/
- $text = channel_content($a,$profile_uid,$load);
+ $mod = new Channel();
+
+ $text = $mod->get($profile_uid,$load);
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\"";
@@ -62,4 +66,5 @@ function update_channel_content(&$a) {
echo "</body></html>\r\n";
killme();
+}
} \ No newline at end of file
diff --git a/Zotlabs/Web/Controller.php b/Zotlabs/Web/Controller.php
new file mode 100644
index 000000000..ac835e008
--- /dev/null
+++ b/Zotlabs/Web/Controller.php
@@ -0,0 +1,12 @@
+<?php
+
+namespace Zotlabs\Web;
+
+
+class Controller {
+
+ function init() {}
+ function post() {}
+ function get() {}
+
+} \ No newline at end of file
diff --git a/Zotlabs/Web/Router.php b/Zotlabs/Web/Router.php
index 29f2b5206..6330efa17 100644
--- a/Zotlabs/Web/Router.php
+++ b/Zotlabs/Web/Router.php
@@ -5,6 +5,9 @@ namespace Zotlabs\Web;
class Router {
+ private $modname = '';
+ private $controller = null;
+
function __construct(&$a) {
/**
@@ -54,15 +57,26 @@ class Router {
*/
if(! (\App::$module_loaded)) {
- if(file_exists("mod/site/{$module}.php")) {
- include_once("mod/site/{$module}.php");
- \App::$module_loaded = true;
+ try {
+ $modname = "Zotlabs\\Module\\" . ucfirst($module);
+ $filename = 'Zotlabs/Module/'. ucfirst($module). '.php';
+ if(file_exists($filename)) {
+ $this->controller = new $modname;
+ \App::$module_loaded = true;
+ }
+ else throw new \Exception('Module not found');
}
- elseif(file_exists("mod/{$module}.php")) {
- include_once("mod/{$module}.php");
- \App::$module_loaded = true;
+ catch(\Exception $e) {
+ if(file_exists("mod/site/{$module}.php")) {
+ include_once("mod/site/{$module}.php");
+ \App::$module_loaded = true;
+ }
+ elseif(file_exists("mod/{$module}.php")) {
+ include_once("mod/{$module}.php");
+ \App::$module_loaded = true;
+ }
+ else logger("mod/{$module}.php not found.");
}
- else logger("mod/{$module}.php not found.");
}
@@ -133,10 +147,13 @@ class Router {
* to over-ride them.
*/
- if(function_exists(\App::$module . '_init')) {
- $arr = array('init' => true, 'replace' => false);
- call_hooks(\App::$module . '_mod_init', $arr);
- if(! $arr['replace']) {
+ $arr = array('init' => true, 'replace' => false);
+ call_hooks(\App::$module . '_mod_init', $arr);
+ if(! $arr['replace']) {
+ if($this->controller && method_exists($this->controller,'init')) {
+ $this->controller->init();
+ }
+ elseif(function_exists(\App::$module . '_init')) {
$func = \App::$module . '_init';
$func($a);
}
@@ -179,21 +196,30 @@ class Router {
}
}
- if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! \App::$error)
- && (function_exists(\App::$module . '_post'))
- && (! x($_POST, 'auth-params'))) {
+ if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! \App::$error) && (! x($_POST, 'auth-params'))) {
call_hooks(\App::$module . '_mod_post', $_POST);
- $func = \App::$module . '_post';
- $func($a);
+
+ if($this->controller && method_exists($this->controller,'post')) {
+ $this->controller->post();
+ }
+ elseif(function_exists(\App::$module . '_post')) {
+ $func = \App::$module . '_post';
+ $func($a);
+ }
}
- if((! \App::$error) && (function_exists(\App::$module . '_content'))) {
+ if(! \App::$error) {
$arr = array('content' => \App::$page['content'], 'replace' => false);
call_hooks(\App::$module . '_mod_content', $arr);
\App::$page['content'] = $arr['content'];
if(! $arr['replace']) {
- $func = \App::$module . '_content';
- $arr = array('content' => $func($a));
+ if($this->controller && method_exists($this->controller,'get')) {
+ $arr = array('content' => $this->controller->get());
+ }
+ elseif(function_exists(\App::$module . '_content')) {
+ $func = \App::$module . '_content';
+ $arr = array('content' => $func($a));
+ }
}
call_hooks(\App::$module . '_mod_aftercontent', $arr);
\App::$page['content'] .= $arr['content'];
diff --git a/include/items.php b/include/items.php
index 95822c0ba..fde7ca9a2 100755
--- a/include/items.php
+++ b/include/items.php
@@ -555,8 +555,8 @@ function get_public_feed($channel, $params) {
// put a sane lower limit on feed requests if not specified
- if($params['begin'] === NULL_DATE)
- $params['begin'] = datetime_convert('UTC','UTC','now - 1 month');
+// if($params['begin'] === NULL_DATE)
+// $params['begin'] = datetime_convert('UTC','UTC','now - 1 month');
switch($params['type']) {
case 'json':