Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function initBlock()
 {
     $currentUserId = \Magelight\Http\Session::getInstance()->get('user_id', false);
     if ($currentUserId && ($userData = \Magelight\Auth\Models\User::find($currentUserId)->asArray())) {
         $this->set('user_id', $currentUserId);
         $this->set('user_data', $userData);
     }
     return parent::initBlock();
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function initBlock()
 {
     $this->sectionAppend('top', Top::forge());
     $document = \Magelight\Core\Blocks\Document::getInstance();
     $document->addMeta(['http-equiv' => "content-type", 'content' => "text/html; charset=utf-8"]);
     $document->addMeta(['name' => 'keywords', 'content' => 'welcome app, magelight']);
     $document->addCss('Magelight/Core/static/css/bootstrap.min.css');
     $document->addCss('Magelight/Core/static/css/core.css');
     $document->addJs('Magelight/Core/static/js/jquery.js');
     $document->addJs('Magelight/Core/static/js/bootstrap.min.js');
     return parent::initBlock();
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function initBlock()
 {
     $currentUserId = \Magelight\Http\Session::getInstance()->get('user_id');
     if (!empty($currentUserId)) {
         if ($user = \Magelight\Auth\Models\User::find($currentUserId)) {
             $userData = $user->asArray();
             $this->setGlobal('user_data', $userData);
         }
     }
     $document = \Magelight\Core\Blocks\Document::getInstance();
     $document->addMeta(['http-equiv' => "content-type", 'content' => "text/html; charset=utf-8"]);
     $document->addCss('Magelight/Core/static/css/bootstrap.css');
     $document->addCss('Magelight/Core/static/css/hint.css');
     $document->addJs('Magelight/Core/static/js/jquery.js');
     $document->addJs('Magelight/Core/static/js/bootstrap.min.js');
     return parent::initBlock();
 }
Exemplo n.º 4
0
 /**
  * Initialize block
  *
  * @return \Magelight\Block|void
  */
 protected function initBlock()
 {
     $pages = [];
     $pagesCount = ceil($this->total / $this->perPage);
     if ($this->showFirstLast) {
         $pages[] = ['page' => 0, 'caption' => $this->first_caption, 'url' => $this->getPageUrl(0), 'active' => false, 'disabled' => $this->currentPage <= 0];
     }
     if ($this->prev_caption) {
         $pages[] = ['page' => $this->currentPage, 'caption' => $this->prev_caption, 'url' => $this->getPageUrl($this->currentPage - 1), 'active' => false, 'disabled' => $this->currentPage <= 0];
     }
     $start = $this->currentPage - $this->siblingsCount > 0 ? $this->currentPage - $this->siblingsCount : 0;
     $finish = $this->currentPage + $this->siblingsCount + 1 < $pagesCount ? $this->currentPage + $this->siblingsCount + 1 : $pagesCount;
     for ($i = $start; $i < $finish; $i++) {
         $pages[] = ['page' => $i, 'caption' => $i + 1, 'url' => $this->getPageUrl($i), 'active' => $i == (int) $this->currentPage, 'disabled' => false];
     }
     if ($this->next_caption) {
         $pages[] = ['page' => $this->currentPage, 'caption' => $this->next_caption, 'url' => $this->getPageUrl($this->currentPage + 1), 'active' => false, 'disabled' => $this->currentPage >= $pagesCount - 1];
     }
     if ($this->showFirstLast) {
         $pages[] = ['page' => $pagesCount - 1, 'caption' => $this->last_caption, 'url' => $this->getPageUrl($pagesCount - 1), 'active' => false, 'disabled' => $this->currentPage >= $pagesCount - 1];
     }
     $this->set('pages', $pages);
     unset($pages);
     return parent::initBlock();
 }