public function processPockets($Sender, $Location, $CountHint = null)
{
if (Gdn::controller()->deliveryMethod() != DELIVERY_METHOD_XHTML) {
return;
}
if (Gdn::controller()->data('_NoMessages') && $Location != 'Head') {
return;
}
// Since plugins can't currently maintain their state we have to stash it in the Gdn object.
$this->_loadState();
// Build up the data for filtering.
$Data = array();
$Data['Request'] = Gdn::request();
// Increment the counter.
if ($CountHint != null) {
$Count = $CountHint;
} elseif (array_key_exists($Location, $this->_Counters)) {
$Count = $this->_Counters[$Location] + 1;
$this->_Counters[$Location] = $Count;
} else {
$Count = $this->_Counters[$Location] = 1;
}
$Data['Count'] = $Count;
$Data['PageName'] = Pocket::pageName($Sender);
$LocationOptions = val($Location, $this->Locations, array());
if ($this->TestMode && array_key_exists($Location, $this->Locations) && checkPermission('Plugins.Pockets.Manage') && $Sender->MasterView != 'admin') {
$LocationName = val("Name", $this->Locations, $Location);
echo valr('Wrap.0', $LocationOptions, ''), "<div class=\"TestPocket\"><h3>{$LocationName} ({$Count})</h3></div>", valr('Wrap.1', $LocationOptions, '');
if ($Location == 'Foot' && strcasecmp($Count, 'after') == 0) {
echo $this->testData($Sender);
}
}
// Process all of the pockets.
if (array_key_exists($Location, $this->_Pockets)) {
foreach ($this->_Pockets[$Location] as $Pocket) {
/** @var Pocket $Pocket */
if ($Pocket->canRender($Data)) {
$Wrap = val('Wrap', $LocationOptions, array());
echo val(0, $Wrap, '');
$Pocket->render($Data);
echo val(1, $Wrap, '');
}
}
}
$this->_saveState();
}