static function str2metadesc($txt) { $txt = str::condenseHtmlChars($txt, ' '); $txt = str::condenseTags($txt, ' '); $txt = str_replace(array('"', ' .'), array("'", '.'), $txt); $txt = trim(str::condenseWhitespace($txt)); if (strlen($txt) > 320) { $txt = substr($txt, 0, 317) . '...'; } return $txt; }
private static function getAttribute($needle, $haystack) { $ret = ''; $needle .= '='; $haystack = str::condenseWhitespace($haystack); $pos = strpos($haystack, $needle); if ($pos !== false) { // get boundary text $pos += strlen($needle); $ret = substr($haystack, $pos); // strip double quotes if ($ret[0] == '"') { $ret = substr($ret, 1); if (($pos = strpos($ret, '"')) !== false) { $ret = substr($ret, 0, $pos); } } else { if (($pos = strpos($ret, ';')) !== false) { $ret = substr($ret, 0, $pos); } if (($pos = strpos($ret, ' ')) !== false) { $ret = substr($ret, 0, $pos); } } } return $ret; }