Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed/enhanced migration script for tag registration statements.
* Added script tp update to expression tag place holder syntax.
- Loading branch information
Christian Achatz
committed
Jun 27, 2014
1 parent
fd8c59c
commit 70f9b98
Showing
4 changed files
with
73 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
// Collect all <*:addtaglib /> tags, remove them from the templates, and suggest index.php | ||
// statements to add for custom tags. | ||
|
||
use APF\core\pagecontroller\TagLib; | ||
use APF\core\pagecontroller\XmlParser; | ||
|
||
include(dirname(__FILE__) . '/migrate_base.php'); | ||
include(dirname(dirname(__FILE__)) . '/core/pagecontroller/XmlParser.php'); | ||
include(dirname(dirname(__FILE__)) . '/core/pagecontroller/TagLib.php'); | ||
include(dirname(dirname(__FILE__)) . '/core/bootstrap.php'); | ||
|
||
\APF\core\exceptionhandler\GlobalExceptionHandler::disable(); | ||
\APF\core\errorhandler\GlobalErrorHandler::disable(); | ||
|
||
$files = find('.', '*.html'); | ||
|
||
$search = '#<([A-Za-z\-_]+):addtaglib([ |\n|\r\n|\r]+)(.*)/>#smU'; | ||
|
||
$class = new ReflectionClass('APF\core\pagecontroller\Document'); | ||
$property = $class->getProperty('knownTags'); | ||
$property->setAccessible(true); | ||
|
||
$registeredTags = $property->getValue(); | ||
|
||
function isRegistered(array $registeredTags, $class, $prefix, $name) { | ||
/* @var $tag TagLib */ | ||
foreach ($registeredTags as $tag) { | ||
if ($tag->getClass() === $class && $tag->getPrefix() === $prefix && $tag->getName() === $name) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
foreach ($files as $file) { | ||
$content = file_get_contents($file); | ||
|
||
preg_match_all($search, $content, $matches, PREG_SET_ORDER); | ||
|
||
foreach ($matches as $match) { | ||
$attributes = XmlParser::getAttributesFromString(trim($match[3])); | ||
|
||
if (isRegistered($registeredTags, $attributes['class'], $attributes['prefix'], $attributes['name'])) { | ||
$content = str_replace($match[0], '', $content); | ||
} | ||
|
||
} | ||
|
||
file_put_contents($file, $content); | ||
} |
15 changes: 15 additions & 0 deletions
15
migration/migrate_update_place_holders_to_expression_notation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
include(dirname(__FILE__) . '/migrate_base.php'); | ||
|
||
$files = find('.', '*.html'); | ||
|
||
// <html:placeholder name="..."/> | ||
$search = '#<html:placeholder([ |\n|\r\n|\r]+)name ?= ?"(.+)"([ |\n|\r\n|\r]*)/>#mU'; | ||
|
||
foreach ($files as $file) { | ||
$content = file_get_contents($file); | ||
|
||
$content = preg_replace($search, '${\\2}', $content); | ||
|
||
file_put_contents($file, $content); | ||
} |
This file was deleted.
Oops, something went wrong.