Browse Source

appearantly this the standardized version to call a view

master
Lennart Weller 7 years ago
parent
commit
84235d1a16
3 changed files with 42 additions and 8 deletions
  1. +27
    -0
      modules/class.shoutboxmodule.php
  2. +13
    -6
      settings/class.hooks.php
  3. +2
    -2
      views/shoutbox.php

+ 27
- 0
modules/class.shoutboxmodule.php View File

@ -0,0 +1,27 @@
<?php if(!defined('APPLICATION')) exit();
class ShoutboxModule extends Gdn_Module {
public function __construct($Sender = '') {
parent::__construct($Sender);
}
public function AssetTarget() {
return 'Content';
}
public function ToString() {
$Session = Gdn::Session();
if(!$Session->CheckPermission('Shoutbox.View')) {
return "";
}
$String = '';
ob_start();
require_once(PATH_APPLICATIONS.DS.'shoutbox'.DS.'views'.DS.'shoutbox.php');
$String = ob_get_contents();
@ob_end_clean();
return $String;
}
}

+ 13
- 6
settings/class.hooks.php View File

@ -30,12 +30,19 @@ class ShoutboxHooks implements Gdn_IPlugin {
public function Base_Render_Before(&$Sender) {
$Session = Gdn::Session();
$Controller = $Sender->ControllerName;
$ShowOnController = array(
'discussionscontroller',
// 'categoriescontroller',
// 'profilecontroller',
// 'activitycontroller'
);
if($Session->IsValid() && InArrayI($Controller, $ShowOnController))
{
require_once(PATH_APPLICATIONS.DS.'shoutbox'.DS.'modules'.DS.'class.shoutboxmodule.php');
$ShoutboxModule = new ShoutboxModule($Sender);
$Sender->AddModule($ShoutboxModule);
}
}
public function DiscussionsController_Render_After(&$Sender) {
$Session = Gdn::Session();
//$Sender->Head->AddJsFile('shoutbox.js');
include_once(PATH_APPLICATIONS.DS.'shoutbox'.DS.'views'.DS.'shoutbox.php');
}
}

+ 2
- 2
views/shoutbox.php View File

@ -11,8 +11,8 @@
</div>
<script type="text/javascript">
$('#shoutbox').prependTo('#Content');
$('#shoutbox').insertAfter('.Info');
//$('#shoutbox').prependTo('#Content');
//$('#shoutbox').insertAfter('.Info');
$('#shoutbox-send').click(function() {
gdn.informMessage(gdn.url('profile/vanilla')); //TODO remember these two
});


Loading…
Cancel
Save