function makeArticle($class, $text)
{
    global $unique;
    $unique++;
    $i = strpos($text, '</a>');
    $j = strpos($text, '</h4>');
    $h4 = substr($text, $i + 4, $j - $i - 4);
    $text = substr($text, $j + 5);
    $text = str_replace('<hr />', '', $text);
    $text = str_replace('<hr/>', '', $text);
    $ts_news = new ZenpageNews(seoFriendly($class . '_' . trim(truncate_string(strip_tags($h4), 30, '')) . '_' . $unique), true);
    $ts_news->setShow(0);
    $ts_news->setDateTime(date('Y-m-d H:i:s'));
    $ts_news->setAuthor('TSGenerator');
    $ts_news->setTitle($h4);
    $ts_news->setContent($text);
    $ts_news->setCategories(array());
    $ts_news->setCategories(array('troubleshooting', 'troubleshooting-' . $class));
    $ts_news->save();
}
Beispiel #2
0
function processPlugins()
{
    global $_zp_current_admin_obj;
    $curdir = getcwd();
    $basepath = SERVERPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . '/';
    chdir($basepath);
    $filelist = safe_glob('*.php');
    foreach ($filelist as $file) {
        $titlelink = stripSuffix(filesystemToInternal($file));
        $author = stripSuffix(basename(__FILE__));
        $sql = 'SELECT `id` FROM ' . prefix('news') . ' WHERE `titlelink`=' . db_quote($titlelink);
        $result = query_single_row($sql);
        if (empty($result)) {
            $plugin_news = new ZenpageNews($titlelink);
            $fp = fopen($basepath . $file, 'r');
            $empty = true;
            $desc = '<p>';
            $tags = array($titlelink);
            $incomment = false;
            while ($line = fgets($fp)) {
                if (strpos($line, '/*') !== false) {
                    $incomment = true;
                }
                if ($incomment) {
                    if (strpos($line, '*/') !== false) {
                        break;
                    }
                    $i = strpos($line, '*');
                    $line = trim(trim(substr($line, $i + 1), '*'));
                    if (empty($line)) {
                        if (!$empty) {
                            $desc .= '<p>';
                        }
                        $empty = true;
                    } else {
                        if (strpos($line, '@') === 0) {
                            $line = trim($line, '@');
                            $i = strpos($line, ' ');
                            $mod = substr($line, 0, $i);
                            $line = trim(substr($line, $i + 1));
                            switch ($mod) {
                                case 'author':
                                    $desc .= 'Author: ' . html_encode($line) . ' ';
                                    $empty = false;
                                    preg_match_all('|\\((.+?)\\)|', $line, $matches);
                                    $tags = array_merge($tags, $matches[1]);
                                    $author = array_shift($matches[1]);
                                    break;
                                case 'package':
                                case 'subpackage':
                                    $tags[] = $line;
                                    break;
                                case 'tags':
                                    $pluginTags = explode(',', $line);
                                    foreach ($pluginTags as $tag) {
                                        $tags[] = trim(unQuote($tag));
                                    }
                                    break;
                            }
                        } else {
                            $desc .= html_encode($line) . ' ';
                            $empty = false;
                        }
                    }
                }
            }
            $desc .= '</p>';
            fclose($fp);
            $plugin_news->setShow(0);
            $plugin_news->setDateTime(date('Y-m-d H:i:s'), filemtime($file));
            $plugin_news->setAuthor($author);
            $plugin_news->setTitle($titlelink);
            $plugin_news->setContent($desc);
            $plugin_news->setTags($tags);
            $plugin_news->setCategories(array('officially-supported', 'extensions'));
            $plugin_news->setCustomData("http://www.zenphoto.org/documentation/plugins/_" . PLUGIN_FOLDER . "---" . $titlelink . ".html");
            $plugin_news->save();
        }
    }
    chdir($curdir);
}
 /**
  *
  * Formats the message and calls sendTweet() on an object
  * @param object $obj
  */
 private static function publishArticle($obj, $override = NULL)
 {
     global $_zp_zenpage;
     $galleryitem_text = array();
     switch ($type = $obj->table) {
         case 'albums':
             if (getOption('multi_lingual')) {
                 $option_text = unserialize(getOption('galleryArticles_album_text'));
                 foreach ($option_text as $key => $val) {
                     $galleryitem_text[$key] = sprintf($option_text[$key], $obj->getTitle($key));
                 }
                 $text = serialize($galleryitem_text);
             } else {
                 $text = sprintf(get_language_string(getOption('galleryArticles_album_text')), $obj->getTitle());
             }
             $title = $folder = $obj->name;
             $img = $obj->getAlbumThumbImage();
             $class = 'galleryarticles-newalbum';
             break;
         case 'images':
             if (getOption('multi_lingual')) {
                 $option_text = unserialize(getOption('galleryArticles_image_text'));
                 foreach ($option_text as $key => $val) {
                     $galleryitem_text[$key] = sprintf($option_text[$key], $obj->getTitle($key), $obj->album->getTitle($key));
                 }
                 $text = serialize($galleryitem_text);
             } else {
                 $text = sprintf(get_language_string(getOption('galleryArticles_image_text')), $obj->getTitle(), $obj->album->getTitle());
             }
             $folder = $obj->imagefolder;
             $title = $folder . '-' . $obj->filename;
             $img = $obj;
             $class = 'galleryarticles-newimage';
             break;
     }
     $article = new ZenpageNews(seoFriendly('galleryArticles-' . $title));
     $article->setTitle($text);
     $imglink = $img->getCustomImage(getOption('galleryArticles_size'), NULL, NULL, NULL, NULL, NULL, NULL, -1);
     if (getOption('multi_lingual')) {
         $desc = '';
         foreach ($option_text as $key => $val) {
             $desc[$key] = '<p><a class="' . $class . '" href="' . $obj->getLink() . '"><img src="' . $imglink . '"></a></p><p>' . $obj->getDesc($key) . '</p>';
         }
         $desc = serialize($desc);
     } else {
         $desc = '<p><a class="' . $class . '" href="' . $obj->getLink() . '"><img src="' . $imglink . '"></a></p><p>' . $obj->getDesc() . '</p>';
     }
     $article->setContent($desc);
     $article->setShow(true);
     $date = $obj->getPublishDate();
     if (!$date) {
         $date = date('Y-m-d H:i:s');
     }
     $article->setDateTime($date);
     $article->setAuthor('galleryArticles');
     $article->save();
     if ($override) {
         $cat = $override;
     } else {
         $cat = getOption('galleryArticles_category');
         if (getOption('galleryArticles_albumCategory')) {
             $catlist = $_zp_zenpage->getAllCategories();
             foreach ($catlist as $category) {
                 if ($category['titlelink'] == $folder) {
                     $cat = $category['titlelink'];
                     break;
                 }
             }
         }
     }
     $article->setCategories(array($cat));
 }