initialize() public method

The initialize method is called by the dispatcher after the constructor has completed, objects have been passed along, assets have been retrieved, and before the requested method fires. Use it in any extended controller to do things like loading script and CSS into the head.
public initialize ( )
Esempio n. 1
0
 /**
  * Adds JS, CSS, & modules. Automatically run on every use.
  *
  * @since 2.0.0
  * @access public
  */
 public function initialize()
 {
     $this->ModuleSortContainer = 'Profile';
     $this->Head = new HeadModule($this);
     $this->addJsFile('jquery.js');
     $this->addJsFile('jquery.form.js');
     $this->addJsFile('jquery.popup.js');
     $this->addJsFile('jquery.gardenhandleajaxform.js');
     $this->addJsFile('jquery.autosize.min.js');
     $this->addJsFile('global.js');
     $this->addCssFile('style.css');
     $this->addCssFile('vanillicon.css', 'static');
     $this->addModule('GuestModule');
     parent::initialize();
     Gdn_Theme::section('Profile');
     if ($this->EditMode) {
         $this->CssClass .= 'EditMode';
     }
     /**
      * The default Cache-Control header does not include no-store, which can cause issues with outdated session
      * information (e.g. message button missing). The same check is performed here as in Gdn_Controller before the
      * Cache-Control header is added, but this value includes the no-store specifier.
      */
     if (Gdn::session()->isValid()) {
         $this->setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');
     }
     $this->setData('Breadcrumbs', array());
     $this->CanEditPhotos = Gdn::session()->checkRankedPermission(c('Garden.Profile.EditPhotos', true)) || Gdn::session()->checkPermission('Garden.Users.Edit');
 }
 /**
  * Before every controller method call.
  */
 public function initialize()
 {
     if ($this->deliveryType() == DELIVERY_TYPE_ALL) {
         $this->Head = new HeadModule($this);
     }
     $this->addCssFile('style.css');
     parent::initialize();
 }
 /**
  * Do this before anything else.
  */
 public function initialize()
 {
     parent::initialize();
     if ($this->deliveryType() == DELIVERY_TYPE_ALL) {
         $this->Head = new HeadModule($this);
     }
     $this->addCssFile('style.css');
     $this->addCssFile('addons.css');
     $this->CountCommentsPerPage = c('Vanilla.Comments.PerPage', 30);
 }
 /**
  * Before all method calls.
  */
 public function initialize()
 {
     $this->Head = new HeadModule($this);
     $this->addJsFile('jquery.js');
     $this->addJsFile('jquery.form.js');
     $this->addJsFile('jquery.popup.js');
     $this->addJsFile('jquery.gardenhandleajaxform.js');
     $this->addJsFile('global.js');
     $this->addCssFile('admin.css');
     $this->MasterView = 'admin';
     parent::initialize();
 }
 /**
  * CSS, JS and module includes.
  */
 public function initialize()
 {
     $this->Head = new HeadModule($this);
     $this->addJsFile('jquery.js');
     $this->addJsFile('jquery.form.js');
     $this->addJsFile('jquery.popup.js');
     $this->addJsFile('jquery.gardenhandleajaxform.js');
     $this->addJsFile('global.js');
     $this->addCssFile('style.css');
     $this->addCssFile('vanillicon.css', 'static');
     $this->addModule('GuestModule');
     parent::initialize();
 }
 /**
  * Include JS and CSS used by all methods.
  *
  * Always called by dispatcher before controller's requested method.
  *
  * @since 2.0.0
  * @access public
  */
 public function initialize()
 {
     $this->Head = new HeadModule($this);
     $this->Head->addTag('meta', array('name' => 'robots', 'content' => 'noindex'));
     $this->addJsFile('jquery.js');
     $this->addJsFile('jquery.form.js');
     $this->addJsFile('jquery.popup.js');
     $this->addJsFile('jquery.gardenhandleajaxform.js');
     $this->addJsFile('global.js');
     $this->addCssFile('style.css');
     $this->addCssFile('vanillicon.css', 'static');
     parent::initialize();
     Gdn_Theme::section('Entry');
 }
Esempio n. 7
0
 /**
  * Add JS, CSS, modules. Automatically run on every use.
  *
  * @since 2.0.0
  * @access public
  */
 public function initialize()
 {
     $this->Head = new HeadModule($this);
     $this->addJsFile('jquery.js');
     $this->addJsFile('jquery.form.js');
     $this->addJsFile('jquery.popup.js');
     $this->addJsFile('jquery.gardenhandleajaxform.js');
     $this->addJsFile('jquery.expander.js');
     $this->addJsFile('global.js');
     $this->addCssFile('style.css');
     $this->addCssFile('vanillicon.css', 'static');
     $this->addCssFile('menu.css');
     $this->addModule('GuestModule');
     parent::initialize();
     $this->setData('Breadcrumbs', array(array('Name' => t('Search'), 'Url' => '/search')));
 }
 /**
  * Include JS, CSS, and modules used by all methods.
  *
  * Always called by dispatcher before controller's requested method.
  *
  * @since 2.0.0
  * @access public
  */
 public function initialize()
 {
     $this->Head = new HeadModule($this);
     $this->addJsFile('jquery.js');
     $this->addJsFile('jquery.form.js');
     $this->addJsFile('jquery.popup.js');
     $this->addJsFile('jquery.gardenhandleajaxform.js');
     $this->addJsFile('global.js');
     $this->addCssFile('style.css');
     $this->addCssFile('vanillicon.css', 'static');
     // Add Modules
     $this->addModule('GuestModule');
     $this->addModule('SignedInModule');
     parent::initialize();
     Gdn_Theme::section('ActivityList');
     $this->setData('Breadcrumbs', array(array('Name' => t('Activity'), 'Url' => '/activity')));
 }
 /**
  * Include JS, CSS, and modules used by all methods.
  *
  * Always called by dispatcher before controller's requested method.
  *
  * @since 2.0.0
  * @access public
  */
 public function initialize()
 {
     // Set up head
     $this->Head = new HeadModule($this);
     $this->addJsFile('jquery.js');
     $this->addJsFile('jquery.form.js');
     $this->addJsFile('jquery.popup.js');
     $this->addJsFile('jquery.gardenhandleajaxform.js');
     $this->addJsFile('jquery.atwho.js');
     $this->addJsFile('global.js');
     $this->addCssFile('style.css');
     $this->addCssFile('vanillicon.css', 'static');
     // Add modules
     //      $this->addModule('MeModule');
     $this->addModule('GuestModule');
     $this->addModule('SignedInModule');
     parent::initialize();
 }
 /**
  * Adds JS, CSS, & modules. Automatically run on every use.
  *
  * @since 2.0.0
  * @access public
  */
 public function initialize()
 {
     $this->ModuleSortContainer = 'Profile';
     $this->Head = new HeadModule($this);
     $this->addJsFile('jquery.js');
     $this->addJsFile('jquery.form.js');
     $this->addJsFile('jquery.popup.js');
     $this->addJsFile('jquery.gardenhandleajaxform.js');
     $this->addJsFile('jquery.autosize.min.js');
     $this->addJsFile('global.js');
     $this->addCssFile('style.css');
     $this->addCssFile('vanillicon.css', 'static');
     $this->addModule('GuestModule');
     parent::initialize();
     Gdn_Theme::section('Profile');
     if ($this->EditMode) {
         $this->CssClass .= 'EditMode';
     }
     $this->setData('Breadcrumbs', array());
     $this->CanEditPhotos = c('Garden.Profile.EditPhotos') || Gdn::session()->checkPermission('Garden.Users.Edit');
 }
 /**
  * Include JS, CSS, and modules used by all methods.
  *
  * Always called by dispatcher before controller's requested method.
  *
  * @since 2.0.0
  * @access public
  */
 public function initialize()
 {
     // You've got to be signed in to send private messages.
     if (!Gdn::session()->isValid()) {
         redirect('/entry/signin?Target=' . urlencode($this->SelfUrl));
     }
     if ($this->deliveryType() == DELIVERY_TYPE_ALL) {
         $this->Head = new HeadModule($this);
         $this->addJsFile('jquery.js');
         $this->addJsFile('jquery.form.js');
         $this->addJsFile('jquery.popup.js');
         $this->addJsFile('jquery.gardenhandleajaxform.js');
         $this->addJsFile('jquery.autosize.min.js');
         $this->addJsFile('jquery.tokeninput.js');
         $this->addJsFile('global.js');
         $this->addJsFile('conversations.js');
     }
     $this->addCssFile('style.css');
     $this->addCssFile('vanillicon.css', 'static');
     parent::initialize();
 }
 /**
  * Include JS, CSS, and modules used by all methods.
  *
  * Always called by dispatcher before controller's requested method.
  *
  * @since 2.0.0
  * @access public
  */
 public function initialize()
 {
     $this->Head = new HeadModule($this);
     $this->addJsFile('jquery.js');
     $this->addJsFile('jquery.form.js');
     $this->addJsFile('jquery.popup.js');
     $this->addJsFile('jquery.gardenhandleajaxform.js');
     $this->addJsFile('magnific-popup.min.js');
     $this->addJsFile('jquery.autosize.min.js');
     $this->addJsFile('global.js');
     if (in_array($this->ControllerName, array('profilecontroller', 'activitycontroller'))) {
         $this->addCssFile('style.css');
         $this->addCssFile('vanillicon.css', 'static');
     } else {
         if (!c('Garden.Cdns.Disable', false)) {
             $this->addCssFile('https://fonts.googleapis.com/css?family=Rokkitt');
         }
         $this->addCssFile('admin.css');
         $this->addCssFile('magnific-popup.css');
     }
     $this->MasterView = 'admin';
     parent::initialize();
 }
 /**
  * Switch MasterView. Include JS, CSS used by all methods.
  *
  * Always called by dispatcher before controller's requested method.
  *
  * @since 2.0.0
  * @access public
  */
 public function initialize()
 {
     // Set up head
     $this->Head = new HeadModule($this);
     $this->addJsFile('jquery.js');
     $this->addJsFile('jquery.livequery.js');
     $this->addJsFile('jquery.form.js');
     $this->addJsFile('jquery.popup.js');
     $this->addJsFile('jquery.gardenhandleajaxform.js');
     $this->addJsFile('jquery.atwho.js');
     $this->addJsFile('jquery.autosize.min.js');
     $this->addJsFile('global.js');
     if (in_array($this->ControllerName, array('profilecontroller', 'activitycontroller'))) {
         $this->addCssFile('style.css');
         $this->addCssFile('vanillicon.css', 'static');
     } else {
         $this->addCssFile('admin.css');
     }
     // Change master template
     $this->MasterView = 'admin';
     parent::initialize();
     Gdn_Theme::section('Dashboard');
 }