Exemple #1
0
 /**
  * Before Render method
  *
  * sets a few variables needed for all views
  */
 public function beforeRender()
 {
     // trying to find a bot that is spamming analytics (but it seems to kill real error log reporting - fyi)
     // CakeLog::write('error', $_SERVER['REMOTE_ADDR']);
     // CakeLog::write('error', $_SERVER['HTTP_USER_AGENT']);
     // CakeLog::write('error', $_SERVER['REQUEST_URI']);
     // CakeLog::write('error', $_SERVER['REQUEST_URI']);
     // CakeLog::write('error', '...
     // ...
     // ...
     // ...
     // ');
     //CakeLog::write('error', print_r($_SERVER, true));
     parent::beforeRender();
     $this->set('referer', $this->referer());
     // used for back button links, could be useful for breadcrumbs possibly
     $this->set('_serialize', array_keys($this->viewVars));
     $this->set('_view', $this->view);
     // do a final permission check on the user field
     $modelName = Inflector::singularize($this->name);
     if (!empty($this->{$modelName})) {
         $this->set('_layout', $this->{$modelName}->theme);
         // set in the themeable behavior
         $this->Acl->check(array('permission' => true), $this->{$modelName}->permissionData);
     }
     // order is important for these automatic view vars
     $this->set('page_title_for_layout', $this->_pageTitleForLayout());
     $alias = ZuhaSet::find_key($this->viewVars, 'Alias');
     $alias = end($alias);
     $this->set('title_for_layout', !empty($alias['title']) ? $alias['title'] : $this->_titleForLayout());
     $this->set('keywords_for_layout', !empty($alias['keywords']) ? $alias['keywords'] : null);
     $this->set('description_for_layout', !empty($alias['description']) ? $alias['description'] : $this->_descriptionForLayout());
 }
Exemple #2
0
 /**
  * Before Render method
  *
  * sets a few variables needed for all views
  */
 public function beforeRender()
 {
     parent::beforeRender();
     $this->set('referer', $this->referer());
     // used for back button links, could be useful for breadcrumbs possibly
     $this->set('_serialize', array_keys($this->viewVars));
     $this->set('_view', $this->view);
     // do a final permission check on the user field
     $modelName = Inflector::singularize($this->name);
     if (!empty($this->{$modelName})) {
         $this->set('_layout', $this->{$modelName}->theme);
         // set in the themeable behavior
         $this->Acl->check(array('permission' => true), $this->{$modelName}->permissionData);
     }
     // order is important for these automatic view vars
     $this->set('page_title_for_layout', $this->_pageTitleForLayout());
     // Brought the below line back 9/13/2015 despite the comment below it.
     // If / when this error comes up again, we need a solution that works, because Alias SEO is not working
     // DO NOT just comment this line out again, find a way to get the Alias array values instead.
     $alias = ZuhaSet::find_key($this->viewVars, 'Alias');
     // can't use find_key because recursive iterator wasn't playing nice with some viewVars (eg. object type datetime)
     $alias = $this->viewVars[Inflector::singularize(Inflector::variable($this->request->controller))]['Alias'];
     // blog_posts controller becomes blogPost['Alias]
     $this->set('title_for_layout', !empty($alias['title']) ? $alias['title'] : $this->_titleForLayout());
     $this->set('keywords_for_layout', !empty($alias['keywords']) ? $alias['keywords'] : null);
     $this->set('description_for_layout', !empty($alias['description']) ? $alias['description'] : $this->_descriptionForLayout());
 }