PagerModule::write PHP Метод

write() публичный статический Метод

public static write ( array $Options = [] )
$Options array
    public static function write($Options = array())
    {
        static $WriteCount = 0;
        if (!self::$_CurrentPager) {
            if (is_a($Options, 'Gdn_Controller')) {
                self::$_CurrentPager = new PagerModule($Options);
                $Options = array();
            } else {
                self::$_CurrentPager = new PagerModule(val('Sender', $Options, Gdn::controller()));
            }
        }
        $Pager = self::$_CurrentPager;
        if ($view = val('View', $Options)) {
            $Pager->setView($view);
        }
        $Pager->Wrapper = val('Wrapper', $Options, $Pager->Wrapper);
        $Pager->MoreCode = val('MoreCode', $Options, $Pager->MoreCode);
        $Pager->LessCode = val('LessCode', $Options, $Pager->LessCode);
        $Pager->ClientID = val('ClientID', $Options, $Pager->ClientID);
        $Pager->CssClass = val('CssClass', $Options, 'Pager');
        $Pager->Limit = val('Limit', $Options, $Pager->Controller()->data('_Limit', $Pager->Limit));
        $Pager->HtmlBefore = val('HtmlBefore', $Options, val('HtmlBefore', $Pager, ''));
        $Pager->CurrentRecords = val('CurrentRecords', $Options, $Pager->Controller()->data('_CurrentRecords', $Pager->CurrentRecords));
        // Try and figure out the offset based on the parameters coming in to the controller.
        if (!$Pager->Offset) {
            $Page = $Pager->Controller()->Request->get('Page', false);
            if (!$Page) {
                $Page = 'p1';
                foreach ($Pager->Controller()->RequestArgs as $Arg) {
                    if (preg_match('`p\\d+`', $Arg)) {
                        $Page = $Arg;
                        break;
                    }
                }
            }
            list($Offset, $Limit) = offsetLimit($Page, $Pager->Limit);
            $TotalRecords = val('RecordCount', $Options, $Pager->Controller()->data('RecordCount', false));
            $Get = $Pager->Controller()->Request->get();
            unset($Get['Page'], $Get['DeliveryType'], $Get['DeliveryMethod']);
            $Url = val('Url', $Options, $Pager->Controller()->SelfUrl . '?Page={Page}&' . http_build_query($Get));
            $Pager->configure($Offset, $Limit, $TotalRecords, $Url);
        } elseif ($Url = val('Url', $Options)) {
            $Pager->Url = $Url;
        }
        if ($view) {
            Gdn::controller()->setData('Pager', $Pager);
            echo $Pager->fetchView($view);
        } else {
            echo $Pager->toString($WriteCount > 0 ? 'more' : 'less');
        }
        $WriteCount++;
        //      list($Offset, $Limit) = offsetLimit(GetValue, 20);
        //		$Pager->configure(
        //			$Offset,
        //			$Limit,
        //			$TotalAddons,
        //			"/settings/addons/$Section?Page={Page}"
        //		);
        //		$Sender->setData('_Pager', $Pager);
    }

Usage Example

Пример #1
0
include_once $this->fetchViewLocation('helper_functions');
$this->fireEvent('BeforeStatusForm');
$Session = Gdn::session();
if ($Session->checkPermission('Garden.Profiles.Edit')) {
    echo '<div class="FormWrapper FormWrapper-Condensed">';
    echo $this->Form->open(array('action' => url('/activity/post/' . $this->data('Filter')), 'class' => 'Activity'));
    echo $this->Form->errors();
    echo $this->Form->textBox('Comment', array('MultiLine' => true, 'Wrap' => TRUE));
    echo '<div class="Buttons">';
    echo $this->Form->button('Share', array('class' => 'Button Primary'));
    echo '</div>';
    echo $this->Form->close();
    echo '</div>';
}
echo '</div>';
echo '<ul class="DataList Activities">';
$Activities = $this->data('Activities', array());
if (count($Activities) > 0) {
    include $this->fetchViewLocation('activities', 'activity', 'dashboard');
} else {
    ?>
<li><div class="Empty"><?php 
    echo t('Not much happening here, yet.');
    ?>
</div></li>
   <?php 
}
echo '</ul>';
if (count($Activities) > 0) {
    PagerModule::write(array('CurrentRecords' => count($Activities)));
}
All Usage Examples Of PagerModule::write