Ejemplo n.º 1
0
 /**
  * duplicates an article
  * @param string $newtitle the title for the new article
  */
 function copy($newtitle)
 {
     $newID = $newtitle;
     $id = parent::copy(array('titlelink' => $newID));
     if (!$id) {
         $newID = $newtitle . ':' . seoFriendly(date('Y-m-d_H-i-s'));
         $id = parent::copy(array('titlelink' => $newID));
     }
     if ($id) {
         $newobj = new ZenpageNews($newID);
         $newobj->setTitle($newtitle);
         $newobj->setTags($this->getTags());
         $newobj->save();
         $categories = array();
         foreach ($this->getCategories() as $cat) {
             $categories[] = $cat['cat_id'];
         }
         $result = query_full_array("SELECT * FROM " . prefix('news_categories') . " ORDER BY titlelink");
         foreach ($result as $cat) {
             if (in_array($cat['id'], $categories)) {
                 query("INSERT INTO " . prefix('news2cat') . " (cat_id, news_id) VALUES ('" . $cat['id'] . "', '" . $id . "')");
             }
         }
         return $newobj;
     }
     return false;
 }
Ejemplo n.º 2
0
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();
}
Ejemplo n.º 3
0
                $report = 'images';
                break;
            case 'categories':
                $report = 'categories';
                foreach ($_POST as $key => $titlelink) {
                    $obj = new ZenpageCategory($titlelink);
                    $obj->setShow(1);
                    $obj->save();
                }
                break;
            case 'news':
                $report = 'news';
                foreach ($_POST as $key => $titlelink) {
                    $obj = new ZenpageNews($titlelink);
                    $obj->setShow(1);
                    $obj->save();
                }
                break;
            case 'pages':
                foreach ($_POST as $key => $titlelink) {
                    $obj = new ZenpagePage($titlelink);
                    $obj->setShow(1);
                    $obj->save();
                }
                $report = 'pages';
                break;
        }
    }
}
if ($report) {
    header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/publishContent/publishContent.php?report=' . $report);
Ejemplo n.º 4
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);
}
/**
 * Processes the check box bulk actions
 *
 */
function processZenpageBulkActions($type, &$reports)
{
    global $_zp_zenpage;
    if (isset($_POST['ids'])) {
        //echo "action for checked items:". $_POST['checkallaction'];
        $action = sanitize($_POST['checkallaction']);
        $links = $_POST['ids'];
        $total = count($links);
        $message = NULL;
        $sql = '';
        if ($action != 'noaction') {
            if ($total > 0) {
                if ($action == 'addtags' || $action == 'alltags') {
                    foreach ($_POST as $key => $value) {
                        $key = postIndexDecode($key);
                        if (substr($key, 0, 10) == 'mass_tags_') {
                            if ($value) {
                                $tags[] = substr($key, 10);
                            }
                        }
                    }
                    $tags = sanitize($tags, 3);
                }
                $n = 0;
                switch ($action) {
                    case 'deleteall':
                        $message = gettext('Selected items deleted');
                        break;
                    case 'showall':
                        $message = gettext('Selected items published');
                        break;
                    case 'hideall':
                        $message = gettext('Selected items unpublished');
                        break;
                    case 'commentson':
                        $message = gettext('Comments enabled for selected items');
                        break;
                    case 'commentsoff':
                        $message = gettext('Comments disabled for selected items');
                        break;
                    case 'resethitcounter':
                        $message = gettext('Hitcounter for selected items');
                        break;
                    case 'addtags':
                        $message = gettext('Tags added to selected items');
                        break;
                    case 'cleartags':
                        $message = gettext('Tags cleared from selected items');
                        break;
                    case 'alltags':
                        $message = gettext('Tags added to articles of selected items');
                        break;
                    case 'clearalltags':
                        $message = gettext('Tags cleared from articles of selected items');
                        break;
                }
                foreach ($links as $titlelink) {
                    $class = 'Zenpage' . $type;
                    $obj = new $class($titlelink);
                    switch ($action) {
                        case 'deleteall':
                            $obj->remove();
                            break;
                        case 'addtags':
                            $mytags = array_unique(array_merge($tags, $obj->getTags()));
                            $obj->setTags($mytags);
                            break;
                        case 'cleartags':
                            $obj->setTags(array());
                            break;
                        case 'alltags':
                            $allarticles = $obj->getArticles('', 'all', true);
                            foreach ($allarticles as $article) {
                                $newsobj = new ZenpageNews($article['titlelink']);
                                $mytags = array_unique(array_merge($tags, $newsobj->getTags()));
                                $newsobj->setTags($mytags);
                                $newsobj->save();
                            }
                            break;
                        case 'clearalltags':
                            $allarticles = $obj->getArticles('', 'all', true);
                            foreach ($allarticles as $article) {
                                $newsobj = new ZenpageNews($article['titlelink']);
                                $newsobj->setTags(array());
                                $newsobj->save();
                            }
                            break;
                        case 'showall':
                            $obj->set('show', 1);
                            break;
                        case 'hideall':
                            $obj->set('show', 0);
                            break;
                        case 'commentson':
                            $obj->set('commentson', 1);
                            break;
                        case 'commentsoff':
                            $obj->set('commentson', 0);
                            break;
                        case 'resethitcounter':
                            $obj->set('hitcounter', 0);
                            break;
                    }
                    $obj->save();
                }
                if (!is_null($message)) {
                    $reports[] = "<p class='messagebox fade-message'>" . $message . "</p>";
                }
            }
        }
    }
}
/**
 * Processes the check box bulk actions
 *
 */
function processZenpageBulkActions($type)
{
    global $_zp_zenpage;
    $action = false;
    if (isset($_POST['ids'])) {
        //echo "action for checked items:". $_POST['checkallaction'];
        $action = sanitize($_POST['checkallaction']);
        $links = sanitize($_POST['ids']);
        $total = count($links);
        $message = NULL;
        $sql = '';
        if ($action != 'noaction') {
            if ($total > 0) {
                if ($action == 'addtags' || $action == 'alltags') {
                    $tags = bulkTags();
                }
                if ($action == 'addcats') {
                    foreach ($_POST as $key => $value) {
                        $key = postIndexDecode($key);
                        if (substr($key, 0, 3) == 'cat') {
                            if ($value) {
                                $cats[] = substr($key, 3);
                            }
                        }
                    }
                    $cats = sanitize($cats, 3);
                }
                $n = 0;
                foreach ($links as $titlelink) {
                    $class = 'Zenpage' . $type;
                    $obj = new $class($titlelink);
                    switch ($action) {
                        case 'deleteall':
                            $obj->remove();
                            SearchEngine::clearSearchCache();
                            break;
                        case 'addtags':
                            $mytags = array_unique(array_merge($tags, $obj->getTags()));
                            $obj->setTags($mytags);
                            break;
                        case 'cleartags':
                            $obj->setTags(array());
                            break;
                        case 'alltags':
                            $allarticles = $obj->getArticles('', 'all', true);
                            foreach ($allarticles as $article) {
                                $newsobj = new ZenpageNews($article['titlelink']);
                                $mytags = array_unique(array_merge($tags, $newsobj->getTags()));
                                $newsobj->setTags($mytags);
                                $newsobj->save();
                            }
                            break;
                        case 'clearalltags':
                            $allarticles = $obj->getArticles('', 'all', true);
                            foreach ($allarticles as $article) {
                                $newsobj = new ZenpageNews($article['titlelink']);
                                $newsobj->setTags(array());
                                $newsobj->save();
                            }
                            break;
                        case 'addcats':
                            $catarray = array();
                            $allcats = $obj->getCategories();
                            foreach ($cats as $cat) {
                                $catitem = $_zp_zenpage->getCategory($cat);
                                $catarray[] = $catitem['titlelink'];
                                //to use the setCategories method we need an array with just the titlelinks!
                            }
                            $allcatsarray = array();
                            foreach ($allcats as $allcat) {
                                $allcatsarray[] = $allcat['titlelink'];
                                //same here!
                            }
                            $mycats = array_unique(array_merge($catarray, $allcatsarray));
                            $obj->setCategories($mycats);
                            break;
                        case 'clearcats':
                            $obj->setCategories(array());
                            break;
                        case 'showall':
                            $obj->set('show', 1);
                            break;
                        case 'hideall':
                            $obj->set('show', 0);
                            break;
                        case 'commentson':
                            $obj->set('commentson', 1);
                            break;
                        case 'commentsoff':
                            $obj->set('commentson', 0);
                            break;
                        case 'resethitcounter':
                            $obj->set('hitcounter', 0);
                            break;
                    }
                    $obj->save();
                }
            }
        }
    }
    return $action;
}
 /**
  *
  * 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));
 }