Ejemplo n.º 1
0
 /**
  * Generate title from text of post
  *
  * @param $description string   text of post
  * @return string   generated title
  */
 protected function getTitle($description)
 {
     $description = preg_replace('/#[\\w_]+/u', '', $description);
     // remove hash tags
     $description = preg_replace('/(^(<br\\/?>\\s*?)+|(<br\\/?>\\s*?)+$|(<br\\/?>\\s*?)+(?=<br\\/?>))/u', '', $description);
     // remove superfluous <br>
     $description = preg_replace('/<(?!br|br\\/)[^>]+>/u', '', $description);
     // remove all tags exclude <br> (but leave all other tags starting with 'br'...)
     if (empty($description)) {
         return self::EMPTY_TITLE;
     }
     $splitDescription = explode("<br", $description);
     $currentTitleLength = 0;
     for ($part = 0; $part < count($splitDescription) and $currentTitleLength < self::MAX_TITLE_LENGTH and (mb_strlen($splitDescription[$part]) >= self::MIN_PARAGRAPH_LENGTH_FOR_TITLE or $currentTitleLength + self::MIN_PARAGRAPH_LENGTH_FOR_TITLE < self::MAX_TITLE_LENGTH); $currentTitleLength += mb_strlen($splitDescription[$part++])) {
         $splitDescription[$part] = str_replace(array("<br", "/>", ">"), '', $splitDescription[$part]);
         // $splitDescription[$part] = preg_replace('/(<[^>]*>)/u', '', $splitDescription[$part]);
     }
     $fullTitle = implode(' ', array_slice($splitDescription, 0, $part));
     if (mb_strlen($fullTitle) > self::MAX_TITLE_LENGTH) {
         $fullTitle = Vk2rss::utf8_strrev(explode(' ', Vk2rss::utf8_strrev(mb_substr($fullTitle, 0, self::MAX_TITLE_LENGTH)), 2)[1]) . "...";
     }
     return $fullTitle;
 }
Ejemplo n.º 2
0
<?php

require 'Vk2rss.php';
header("Content-type: text/xml; charset=utf-8");
$vk2rss = new Vk2rss();
$vk2rss->domain = isset($_GET['domain']) ? $_GET['domain'] : NULL;
$vk2rss->owner_id = isset($_GET['owner_id']) ? $_GET['owner_id'] : NULL;
$vk2rss->count = !empty($_GET['count']) ? $_GET['count'] : 20;
$vk2rss->include = !empty($_GET['include']) ? $_GET['include'] : NULL;
$vk2rss->exclude = !empty($_GET['exclude']) ? $_GET['exclude'] : NULL;
$vk2rss->generateRSS();