create a widget registry for pages so themes can reorder, insert/delete, and relocate widgets to different regions of the page
This commit is contained in:
parent
ba4fe4ff91
commit
d261fe271f
20
boot.php
20
boot.php
@ -369,6 +369,7 @@ if(! class_exists('App')) {
|
||||
|
||||
public $account = null;
|
||||
private $channel = null;
|
||||
private $widgets = array();
|
||||
|
||||
public $language;
|
||||
public $module_loaded = false;
|
||||
@ -603,6 +604,20 @@ if(! class_exists('App')) {
|
||||
return $this->channel;
|
||||
}
|
||||
|
||||
function set_widget($title,$html, $location = 'aside') {
|
||||
$this->widgets[] = array('title' => $title, 'html' => $html, 'location' => $location);
|
||||
}
|
||||
|
||||
function get_widgets($location) {
|
||||
if($location && count($this->widgets)) {
|
||||
$ret = array();
|
||||
foreach($widgets as $w)
|
||||
if($w['location'] == $location)
|
||||
$ret[] = $w;
|
||||
return $ret;
|
||||
}
|
||||
return $this->widgets;
|
||||
}
|
||||
|
||||
function set_pager_total($n) {
|
||||
$this->pager['total'] = intval($n);
|
||||
@ -1142,9 +1157,6 @@ function profile_load(&$a, $nickname, $profile = 0) {
|
||||
require_once($theme_info_file);
|
||||
}
|
||||
|
||||
if(! (x($a->page,'aside')))
|
||||
$a->page['aside'] = '';
|
||||
|
||||
if(local_user() && local_user() == $a->profile['uid']) {
|
||||
$a->page['aside'] .= replace_macros(get_markup_template('profile_edlink.tpl'),array(
|
||||
'$editprofile' => t('Edit profile'),
|
||||
@ -1154,7 +1166,7 @@ function profile_load(&$a, $nickname, $profile = 0) {
|
||||
|
||||
$block = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
|
||||
|
||||
$a->page['aside'] .= profile_sidebar($a->profile, $block);
|
||||
$a->set_widget('profile',profile_sidebar($a->profile, $block));
|
||||
|
||||
/*if(! $block)
|
||||
$a->page['aside'] .= contact_block();*/
|
||||
|
18
index.php
18
index.php
@ -158,6 +158,8 @@ $a->apps = $arr['app_menu'];
|
||||
|
||||
if(strlen($a->module)) {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* We will always have a module name.
|
||||
@ -176,9 +178,18 @@ if(strlen($a->module)) {
|
||||
*/
|
||||
|
||||
if((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) {
|
||||
if((strpos($a->module,'admin') === 0) && (! is_site_admin())) {
|
||||
$a->module_loaded = false;
|
||||
notice( t('Permission denied.') . EOL);
|
||||
goaway(z_root());
|
||||
}
|
||||
else {
|
||||
include_once("mod/{$a->module}.php");
|
||||
$a->module_loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@ -362,6 +373,13 @@ head_add_js('mod_' . $a->module . '.js');
|
||||
'$js_strings' => js_strings()
|
||||
));
|
||||
|
||||
$arr = $a->get_widgets();
|
||||
if(count($arr)) {
|
||||
foreach($arr as $x) {
|
||||
$a->page[$x['location']] .= $x['html'];
|
||||
}
|
||||
}
|
||||
|
||||
$page = $a->page;
|
||||
$profile = $a->profile;
|
||||
|
||||
|
@ -100,7 +100,7 @@ function ping_init(&$a) {
|
||||
$t1 = dba_timer();
|
||||
|
||||
$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`,
|
||||
`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
|
||||
`item`.`contact-id`, `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
|
||||
`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
|
||||
FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
|
||||
WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
|
||||
@ -110,6 +110,9 @@ function ping_init(&$a) {
|
||||
);
|
||||
|
||||
if(count($r)) {
|
||||
|
||||
call_hooks('network_ping', array('items' => $r));
|
||||
|
||||
foreach ($r as $it) {
|
||||
if($it['wall'])
|
||||
$result['home'] ++;
|
||||
|
@ -35,8 +35,8 @@ function profile_aside(&$a) {
|
||||
|
||||
profile_load($a,$which,$profile);
|
||||
|
||||
$a->page['aside'] .= posted_date_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],$a->profile['profile_uid'],true);
|
||||
$a->page['aside'] .= categories_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],$cat);
|
||||
$a->set_widget('archive',posted_date_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],$a->profile['profile_uid'],true));
|
||||
$a->set_widget('categories',categories_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],$cat));
|
||||
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
2012-09-25.88
|
||||
2012-09-27.90
|
||||
|
Reference in New Issue
Block a user