/** * 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; }
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; }