/**
  * Gets all the template accessors and caches the result
  * @return array
  */
 public function getTemplateAccessors()
 {
     if ($this->templateAccessors) {
         return $this->templateAccessors;
     }
     $vars = parent::getTemplateAccessors();
     return $this->templateAccessors = array_merge($vars, array('To', 'Cc', 'Bcc', 'From', 'Subject', 'Body', 'BaseURL', 'IsEmail'));
 }
 /**
  * Gets all the core template accessors available to SiteTree templates
  * and caches the result
  * @return array
  */
 public function getTemplateAccessors()
 {
     if ($this->templateAccessors) {
         return $this->templateAccessors;
     }
     $vars = parent::getTemplateAccessors();
     $cc = new ReflectionClass('ContentController');
     $site_tree = new ReflectionClass('SiteTree');
     $hierarchy = new ReflectionClass('Hierarchy');
     $methods = array_merge($site_tree->getMethods(), $cc->getMethods(), $hierarchy->getMethods(), array_keys(singleton('SiteTree')->has_many()), array_keys(singleton('SiteTree')->many_many()), array_keys(singleton('SiteTree')->db()), array_keys(DataObject::config()->fixed_fields));
     foreach ($methods as $m) {
         $name = is_object($m) ? $m->getName() : $m;
         // We only care about methods that follow the UpperCamelCase convention.
         if (preg_match("/[A-Z]/", $name[0])) {
             $vars[] = $name;
         }
     }
     // Just a random exception case
     $vars[] = "Form";
     return $this->templateAccessors = $vars;
 }
 /**
  * Gets a list of the possible booleans in this template, e.g. <% if $SoldOut %>
  * @return array
  */
 public function getPossibleBooleans()
 {
     if ($this->possibleBooleans) {
         return $this->possibleBooleans;
     }
     $booleans = array();
     preg_match_all("/<% (if not|if) [\$]?([A-Za-z0-9._]+)(.*?) %>/", $this->getTopLevelContent(), $matches);
     if ($matches) {
         foreach ($matches[2] as $m) {
             $label = trim($m);
             // We already identified this boolean earlier in the loop
             if (in_array($label, $booleans)) {
                 continue;
             }
             // The condition is based on a core template accessor, e.g. <% if $Menu(2) %>
             if (in_array(strtolower($label), $this->reflector->getTemplateAccessors())) {
                 continue;
             }
             // The condition is based on a core list method, e.g. <% if $Last %>
             if (in_array(strtolower($label), $this->reflector->getListFunctions())) {
                 continue;
             }
             // The condition is based on a block we have already identified, e.g. <% if $Items %>
             if ($this->reflector->getBlockByName($label)) {
                 continue;
             }
             $booleans[] = $label;
         }
     }
     return $this->possibleBooleans = $booleans;
 }