Created
November 8, 2018 18:00
-
-
Save suabo/33c978511fe9dd9edaf11df3cb2194b0 to your computer and use it in GitHub Desktop.
clean article long desc
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
<?php | |
/** | |
* Clean article long descriptions | |
* Author: Marcel Grolms - suabo | |
*/ | |
echo "<html><head><meta charset='utf-8' /></head><body>"; | |
include('bootstrap.php'); | |
$oList = oxNew('oxlist'); | |
$oList->init('oxarticle', 'oxarticles'); | |
$oList->selectString('SELECT oxid FROM oxarticles WHERE 1 = 1;'); | |
foreach($oList as $oArticle) { | |
echo $oArticle->oxarticles__oxid->value . " - ok"; | |
echo "<br />"; | |
$sLongDesc = strip_html_tags($oArticle->getLongDesc()); | |
//echo $sLongDesc; | |
//echo "<br />"; | |
$oArticle->setArticleLongDesc($sLongDesc); | |
$oArticle->save(); | |
} | |
function strip_html_tags($sString) { | |
$sString = preg_replace( | |
array( | |
'@class="[^"]*?"@iu', | |
'@style="[^"]*?"@iu', | |
'@<head[^>]*?>.*?</head>@siu', | |
'@<style[^>]*?>.*?</style>@siu', | |
'@<script[^>]*?.*?</script>@siu', | |
'@<object[^>]*?.*?</object>@siu', | |
'@<embed[^>]*?.*?</embed>@siu', | |
'@<applet[^>]*?.*?</applet>@siu', | |
'@<noframes[^>]*?.*?</noframes>@siu', | |
'@<noscript[^>]*?.*?</noscript>@siu', | |
'@<noembed[^>]*?.*?</noembed>@siu', | |
'@</?((address)|(blockquote)|(center)|(del))@iu', | |
'@</?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu', | |
'@</?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu', | |
'@</?((table)|(th)|(td)|(caption))@iu', | |
'@</?((form)|(button)|(fieldset)|(legend)|(input))@iu', | |
'@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu', | |
'@</?((frameset)|(frame)|(iframe))@iu', | |
'@ @ ', | |
), | |
array( | |
'', | |
'', | |
'', | |
'', | |
'', | |
'', | |
'', | |
'', | |
'', | |
'', | |
'', | |
"\n\$0", | |
"\n\$0", | |
"\n\$0", | |
"\n\$0", | |
"\n\$0", | |
"\n\$0", | |
"\n\$0", | |
"\n\$0", | |
), | |
$sString); | |
$sString = preg_replace('/\s+/', ' ', $sString); | |
$sString = preg_replace('/\s\s+/', ' ', $sString); | |
$sString=preg_replace("~( +)~"," ",$sString); | |
$sString=preg_replace("~( +)~"," ",$sString); | |
return trim(strip_tags($sString, '<p><a><br><h1><h2><h3><h4><h5><h6><b><u><strong>')); | |
} | |
echo "</body></html>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment