/** * 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; }