Esempio n. 1
0
 /**
  * Index action
  */
 public function indexAction()
 {
     $this->view->set('title', 'Welcome');
     $this->view->sectionAppend('content', \SampleApp\Blocks\Welcome::forge());
     \Magelight\Core\Blocks\Document::getInstance()->addMeta(['name' => 'description', 'content' => '123']);
     $this->renderView();
 }
Esempio n. 2
0
 /**
  * Forgery constructor (adds masked input JS to document head)
  */
 public function __forge()
 {
     \Magelight\Core\Blocks\Document::getInstance()->addJs('Magelight/Webform/static/js/jquery.maskedinput.js', 'Magelight/Core/static/js/jquery.js');
     $this->addClass('masked-input');
     $this->setAttribute('type', 'text');
     $this->addClass('form-control');
 }
Esempio n. 3
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();
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function beforeExecute()
 {
     $this->breadcrumbsBlock = \Magelight\Core\Blocks\Breadcrumbs::forge();
     $this->breadcrumbsBlock->addBreadcrumb(__('Admin panel'), 'admin/index');
     if (!\Magelight\Admin\Helpers\Admin::getInstance()->isCurrentUserAdmin()) {
         $this->redirect($this->url('no_rights'));
         $this->app->shutdown();
         die;
     }
     $this->view = \Magelight\Core\Blocks\Document::getInstance()->loadLayout('global/layouts/admin');
     $this->view->setGlobal('user_id', $this->session()->get('user_id'));
     $this->view()->sectionAppend('breadcrumbs', $this->breadcrumbsBlock);
     $this->view()->sectionAppend('dashboard-content', '');
     return parent::beforeExecute();
 }
Esempio n. 5
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();
 }
Esempio n. 6
0
 /**
  * Validate form on frontend flag
  *
  * @param array $ruleset - set of rules to be passed to front validator
  * @return Form
  */
 public function validateOnFront($ruleset = [])
 {
     \Magelight\Core\Blocks\Document::getInstance()->addJs('Magelight/Webform/static/js/jquery-validation.js');
     \Magelight\Core\Blocks\Document::getInstance()->addJs('Magelight/Webform/static/js/ajax-form.js');
     $this->setAttribute('data-front-validate', 'true');
     $this->setAttribute('data-validator-rules', $this->validator->getValidationRulesJson($this->getAttribute('name')), $this::QUOTATION_SINGLE);
     $this->setAttribute('data-validator-messages', $this->validator->getValidationMessagesJson($this->getAttribute('name')), $this::QUOTATION_SINGLE);
     return $this;
 }
Esempio n. 7
0
 /**
  * Forgery constructor
  */
 public function __forge()
 {
     $this->setAttribute('data-async', 'true');
     $this->setAttribute('data-async-target', '');
     \Magelight\Core\Blocks\Document::getInstance()->addJs('Magelight/Webform/static/js/ajax-form.js');
 }
Esempio n. 8
0
 /**
  * Forgery constructor
  *
  * @param \Magelight\Db\Collection $collection - collection to build pager for
  */
 public function __forge(\Magelight\Db\Collection $collection = null)
 {
     parent::__forge($collection);
     \Magelight\Core\Blocks\Document::getInstance()->addJs('Magelight/Core/static/js/ajax-pager.js');
     $this->addClass('ajax-pager');
 }
Esempio n. 9
0
 /**
  * Before execute handler
  *
  * @return \Magelight\Controller|void
  */
 public function beforeExecute()
 {
     $this->view = \Magelight\Core\Blocks\Document::getInstance();
     $this->view->sectionAppend('body', \Magelight\Core\Blocks\Body::forge());
     return $this;
 }