value ); // store any unmatched tags $tagStack = array(); $pIndex = 0; // find the first paragraph tag for( $i = 0; $i < count( $parts ); $i++ ) if( strpos( $parts[$i], '' ) { $summary .= $parts[$pIndex]; break; } elseif( preg_match( '/<\/(\w+)>/', $parts[$pIndex], $endTag ) && $endTag[1] == substr( $tagStack[count($tagStack) - 1], 1, strlen( $endTag[1] ) ) ) { array_pop( $tagStack ); $words++; $summary .= $parts[$pIndex++]; } elseif( preg_match( '/^<\w+/', $parts[$pIndex] ) ) { array_push( $tagStack, $parts[$pIndex] ); $words++; $summary .= $parts[$pIndex++]; } else $summary .= $parts[$pIndex++] . ' '; } // Tags that shouldn't be closed $noClose = array("br", "img"); // make sure that the summary is well formed XHTML by closing tags while( $openTag = array_pop( $tagStack ) ) { preg_match( '/^<(\w+)\s+/', $openTag, $tagName ); if(sizeof($tagName) > 0) { if(!in_array($tagName[1], $noClose)) { $summary .= ""; } } } return $summary; } public function scaffoldFormField($title = null) { return new HtmlEditorField($this->name, $title); } public function scaffoldSearchField($title = null) { return new TextField($this->name, $title); } } ?>