/** * Replaces <!-- CONTAINER [...] --> in template */ private function replace_containers() { $number_of_commands = substr_count($this->string, "<!--"); $start_position = 0; for ($i = 1; $i <= $number_of_commands; $i++) { $start_position = strpos($this->string, "<!--", $start_position); $end_position = strpos($this->string, "-->", $start_position + 1); $command = substr($this->string, $start_position + 5, $end_position - $start_position - 6); $command_array = explode(" ", $command, 3); $command_length = $end_position - $start_position; if (trim(strtolower($command_array[0])) == "container") { if (trim(strtolower($command_array[1])) == "begin") { $container_begin = str_replace("(", "", $command_array[2]); $container_begin = str_replace("\"", "", $container_begin); $container_begin = str_replace(")", "", $container_begin); $container_begin_array = explode(",", $container_begin); if ($container_begin_array[2]) { $container_begin_string = Common_IO::container_begin($container_begin_array[0], $container_begin_array[1], $container_begin_array[2]); } elseif ($container_begin_array[1]) { $container_begin_string = Common_IO::container_begin($container_begin_array[0], $container_begin_array[1]); } else { $container_begin_string = Common_IO::container_begin($container_begin_array[0]); } $this->string = substr_replace($this->string, $container_begin_string, $start_position, $end_position - $start_position + 3); $container_begin_string_length = strlen($container_begin_string); $pointer_correction = $container_begin_string_length - $command_length; $end_position = $end_position + $pointer_correction; } elseif (trim(strtolower($command_array[1])) == "end") { $container_end = str_replace("(", "", $command_array[2]); $container_end = str_replace("\"", "", $container_end); $container_end = str_replace(")", "", $container_end); $container_end_string = Common_IO::container_end(); $container_end_string_length = strlen($container_end_string); $this->string = substr_replace($this->string, $container_end_string, $start_position, $end_position - $start_position + 3); $pointer_correction = $container_end_string_length - $command_length; $end_position = $end_position + $pointer_correction; } } $start_position = $end_position + 1; } }