
Новичок
Профиль
Группа: Участник
Сообщений: 20
Регистрация: 19.10.2006
Репутация: нет Всего: нет
|
ну обошлись с чужои помощью ...если кому интересно : | Код | <? function TempParsing ($content) { $templatecontents = array(); // TEMPLATES CUSTOM TAGS: $customtags = array( 'TITLE' => array("<TITLE>", "</TITLE>" ), 'COLOR' => array("<!--- <8> --->", "<!--- </8> --->" ), 'IMAGE' => array("<!--- <A> --->", "<!--- </A> --->" ), 'TEXT' => array("<!--- <T> --->", "<!--- </T> --->" ), 'MENU' => array("<!--- <3> --->", "<!--- </3> --->" ), 'VOTE' => array("<!--- <VOTE> --->", "<!--- </VOTE> --->" ), 'BOOK' => array("<!--- <BOOK> --->", "<!--- </BOOK> --->" ), 'TELL' => array("<!--- <TELL> --->", "<!--- </TELL> --->" ), 'CHAT' => array("<!--- <CHAT> --->", "<!--- </CHAT> --->" ), 'WEATHER' => array("<!--- <WEATHER> --->", "<!--- </WEATHER> --->"), 'PROFILE' => array("<!--- <PROFILE> --->", "<!--- </PROFILE> --->"), 'CALENDAR' => array("<!--- <C> --->", "<!--- </C> --->" ), 'COUNTER' => array("<!--- <COUNTER> --->", "<!--- </COUNTER> --->"), 'MEDIACONTENT' => array("<!--- <I> --->", "<!--- </I> --->" ), 'WEBLOGCONTENT' => array("<!--- <B> --->", "<!--- </B> --->" ), 'WEBLOGLINK' => array("<!--- <L> --->", "<!--- </L> --->" ), 'BUTTON' => array("<!--- <BUTTON> --->", "<!--- </BUTTON> --->"), 'FORM' => array("<!--- <FORM> --->", "<!--- </FORM> --->" ) );
$patterntempl = "/(\<\!--- \<.+\> ---\>.*\<\!--- \<\/.+\> ---\>)/isU"; $patternblock = "/(\<\!--- \<.+\> ---\>)(.*)(\<\!--- \<\/.+\> ---\>)/isU"; $blocks = preg_split($patterntempl, $content, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); $order = 1; foreach ($blocks as $block) { $parts = preg_split($patternblock, trim($block), -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); if (count($parts)==0) continue; else if (count($parts)==3) { if (strcmp($parts[0], $customtags['TITLE'][0])==0) { $contenttype = 'TITLE';} else if (strcmp($parts[0], $customtags['COLOR'][0])==0) {$contenttype = 'COLOR';} else if (strcmp($parts[0], $customtags['IMAGE'][0])==0) { $contenttype = 'IMAGE';} else if (strcmp($parts[0], $customtags['TEXT'][0])==0) { $contenttype = 'TEXT';} else if (strcmp($parts[0], $customtags['MENU'][0])==0) { $contenttype = 'MENU';} else if (strcmp($parts[0], $customtags['VOTE'][0])==0) {$contenttype = 'VOTE';} else if (strcmp($parts[0], $customtags['BOOK'][0])==0) { $contenttype = 'BOOK';} else if (strcmp($parts[0], $customtags['TELL'][0])==0) { $contenttype = 'TELL';} else if (strcmp($parts[0], $customtags['CHAT'][0])==0) {$contenttype = 'CHAT';} else if (strcmp($parts[0], $customtags['WEATHER'][0])==0) {$contenttype = 'WEATHER';} else if (strcmp($parts[0], $customtags['PROFILE'][0])==0) {$contenttype = 'PROFILE';} else if (strcmp($parts[0], $customtags['CALENDAR'][0])==0) { $contenttype = 'CALENDAR';} else if (strcmp($parts[0], $customtags['COUNTER'][0])==0) { $contenttype = 'COUNTER';} else if (strcmp($parts[0], $customtags['MEDIACONTENT'][0])==0) {$contenttype = 'MEDIACONTENT';} else if (strcmp($parts[0], $customtags['WEBLOGCONTENT'][0])==0) {$contenttype = 'WEBLOGCONTENT';} else if (strcmp($parts[0], $customtags['WEBLOGLINK'][0])==0) {$contenttype = 'WEBLOGLINK';} else if (strcmp($parts[0], $customtags['FORM'][0])==0) {$contenttype = 'FORM';} else if (strcmp($parts[0], $customtags['BUTTON'][0])==0) {$contenttype = 'BUTTON';}
$tagcontent = trim($parts[1]); } else { $contenttype = "NOT CHANGE"; $tagcontent = trim($parts[0]); }
$tmp[0] = $order++; $tmp[1] = $contenttype; $tmp[2] = $tagcontent; $templatecontents[] = $tmp; } return $templatecontents; } ?>
|
|