protected function parse_conditional($type, $opening_tag, $condition_contents, $exact_match, $template_contents, $content_vars, $index_in_group = false) { $Tag = new PerchXMLTag($opening_tag); //PerchUtil::debug($Tag); //PerchUtil::debug(PerchUtil::html($condition_contents)); $type = false; if ($Tag->logged_in() || $Tag->logged_out()) { $type = 'auth'; } elseif ($Tag->has_tag()) { $type = 'tag'; } else { $type = 'data'; } //PerchUtil::debug('Condition: '.$type, 'error'); $Session = $this->Session; $positive = $condition_contents; $negative = ''; // else condition if (strpos($condition_contents, 'perch:else:member') > 0) { $parts = preg_split('/<perch:else:member\\s*\\/>/', $condition_contents); if (is_array($parts) && count($parts) > 1) { $positive = $parts[0]; $negative = $parts[1]; } } switch ($type) { case 'auth': if ($Session->logged_in && $Tag->logged_in() || !$Session->logged_in && $Tag->logged_out()) { $template_contents = str_replace($exact_match, $positive, $template_contents); } else { $template_contents = str_replace($exact_match, $negative, $template_contents); } break; case 'tag': if ($Session->has_tag($Tag->has_tag())) { $template_contents = str_replace($exact_match, $positive, $template_contents); } else { $template_contents = str_replace($exact_match, $negative, $template_contents); } break; default: if (strpos($condition_contents, 'perch:else:member') > 0) { $condition_contents = preg_replace('/<perch:else:member\\s*\\/>/', '', $condition_contents); } $template_contents = str_replace($exact_match, $condition_contents, $template_contents); break; } return $template_contents; }