function &art_getWriterNameFromIds($writer_ids, $linked = false) { if (!is_array($writer_ids)) { $writer_ids = array($writer_ids); } $userid = array_map("intval", array_filter($writer_ids)); $myts =& MyTextSanitizer::getInstance(); $users = array(); if (count($userid) > 0) { $sql = 'SELECT writer_id, writer_name FROM ' . art_DB_prefix("writer") . ' WHERE writer_id IN(' . implode(",", array_unique($userid)) . ')'; if (!($result = $GLOBALS['xoopsDB']->query($sql))) { //xoops_error("writer query error: " . $sql); return $users; } mod_loadFunctions("url", $GLOBALS["artdirname"]); while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) { $uid = $row["writer_id"]; $users[$uid] = $myts->htmlSpecialChars($row["writer_name"]); if ($linked) { $users[$uid] = '<a href="' . art_buildUrl(XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.writer.php", array("writer" => $uid)) . '">' . $users[$uid] . '</a>'; } } } return $users; }
function Xfile($id = null) { //$this->ArtObject(); //$this->db =& Database::getInstance(); $this->table = art_DB_prefix("file"); $this->initVar("file_id", XOBJ_DTYPE_INT, null); $this->initVar("art_id", XOBJ_DTYPE_INT, 0, true); //$this->initVar("file_uid", XOBJ_DTYPE_INT, 0); $this->initVar("file_name", XOBJ_DTYPE_TXTBOX, "", true); }
/** * A very rough function to reconcile article tags * * Far to complete, like removing tags that have been removed from an article */ function art_updateTag($mid = 0) { if (!@(include_once XOOPS_ROOT_PATH . "/modules/tag/include/functions.php")) { return false; } if (!($tag_handler =& tag_getTagHandler())) { return false; } $table_article = art_DB_prefix("article"); $sql = " SELECT art_id, art_keywords" . " FROM " . art_DB_prefix("article") . " WHERE art_time_publish >0" . " AND art_keywords <> '' "; if (($result = $GLOBALS['xoopsDB']->query($sql)) == false) { //xoops_error($GLOBALS['xoopsDB']->error()); } $mid = empty($mid) ? $GLOBALS["xoopsModule"]->getVar("mid") : $mid; while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) { if (empty($myrow["art_keywords"])) { continue; } $tag_handler->updateByItem($myrow["art_keywords"], $myrow["art_id"], $mid); } return true; }
if ($start >= ($count = $article_handler->getCount())) { break; } $limit = empty($_GET['limit']) ? 100 : intval($_GET['limit']); $criteria = new Criteria("1", 1); $criteria->setStart($start); $criteria->setLimit($limit); $articles_obj = $article_handler->getAll($criteria); $rates = array(); $tbs = array(); $sql = " SELECT art_id, COUNT(*) AS art_rates, SUM(rate_rating) AS art_rating " . " FROM " . art_DB_prefix("rate") . " WHERE art_id IN(" . implode(",", array_keys($articles_obj)) . ")" . " GROUP BY art_id"; $result = $xoopsDB->query($sql); while ($myrow = $xoopsDB->fetchArray($result)) { $rates[$myrow["art_id"]] = array("art_rates" => $myrow["art_rates"], "art_rating" => $myrow["art_rating"]); } $sql = " SELECT art_id, COUNT(*) AS art_trackbacks " . " FROM " . art_DB_prefix("trackback") . " WHERE art_id IN (" . implode(", ", array_keys($articles_obj)) . ")" . " AND tb_status > 0" . " GROUP BY art_id"; $result = $xoopsDB->query($sql); while ($myrow = $xoopsDB->fetchArray($result)) { $tbs[$myrow["art_id"]] = $myrow["art_trackbacks"]; } foreach (array_keys($articles_obj) as $key) { $article_handler->updateCategories($articles_obj[$key]); $article_handler->updateTopics($articles_obj[$key]); $article_handler->updateKeywords($articles_obj[$key]); $pages_all = $articles_obj[$key]->getPages(false, true); if (serialize($pages_all) != serialize($articles_obj[$key]->getPages())) { $articles_obj[$key]->setVar("art_pages", $pages_all, true); } if (intval(@$rates[$key]["art_rates"]) != $articles_obj[$key]->getVar("art_rates")) { $articles_obj[$key]->setVar("art_rates", intval(@$rates[$key]["art_rates"]), true); }
<?php /** * Article management * * Import data from smartsection * * @copyright The XOOPS project http://www.xoops.org/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license * @author Taiwen Jiang (phppp or D.J.) <*****@*****.**> * @since 1.00 * @version $Id$ * @package module::article */ $sql = "\tINSERT INTO " . $GLOBALS['xoopsDB']->prefix("smartsection_categories") . "\t\t(categoryid,\tname,\t\t\tparentid,\tdescription)" . "\tSELECT " . "\t\tcat_id,\t\t\tcat_title,\t\tcat_pid,\tcat_description" . " \tFROM " . art_DB_prefix("category") . "\t\tORDER BY cat_id ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building CATEGORY table: " . ($count = $xoopsDB->getAffectedRows())); $sql = "\tINSERT INTO " . $GLOBALS['xoopsDB']->prefix("smartsection_items") . "\t\t(itemid,\t\ttitle,\t\tcategoryid,\t\tuid,\tmeta_keywords, \tsummary,\t\tdatesub,\t\t\t\tcounter,\t\tcomments,\t\tstatus," . "\t\tbody, \t\t\tdohtml,\t\tdosmiley,\t\tdobr,\tdoimage,\tdoxcode)" . "\tSELECT " . "\t\ta.art_id, \ta.art_title, \ta.cat_id,\t\ta.uid,\ta.art_keywords,\ta.art_summary,\ta.art_time_submit,\t\ta.art_counter,\ta.art_comments,\t2," . "\t\tt.text_body,\tt.dohtml,\tt.dosmiley,\t\tt.dobr,\tt.doimage,\tt.doxcode" . " \tFROM " . art_DB_prefix("article") . " AS a, " . art_DB_prefix("text") . " AS t" . "\tWHERE a.art_id = t.art_id" . "\t\tORDER BY art_id ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building ARTICLE table: " . ($count = $xoopsDB->getAffectedRows()));
<?php /** * Article management * * Import data from sections 1.00 * Limit: section images will not be converted * * @copyright The XOOPS project http://www.xoops.org/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license * @author Taiwen Jiang (phppp or D.J.) <*****@*****.**> * @since 1.00 * @version $Id$ * @package module::article */ $sql = "\tINSERT INTO " . art_DB_prefix("category") . "\t\t(cat_id,\tcat_title)" . "\tSELECT " . "\t\tsecid,\tsecname" . " \tFROM " . $GLOBALS['xoopsDB']->prefix("sections") . "\t\tORDER BY secid ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building CATEGORY table: " . ($count = $xoopsDB->getAffectedRows())); $uid = $xoopsUser->getVar("uid"); $time = time(); $sql = "\tINSERT INTO " . art_DB_prefix("article") . "\t\t(art_id, \tart_title, \tcat_id,\t\tuid,\tart_time_create,\tart_time_submit,\tart_time_publish, \tart_counter)" . "\tSELECT " . "\t\tartid,\t\ttitle,\t\tsecid,\t\t{$uid},\t{$time},\t\t\t{$time},\t\t\t{$time},\t\t\tcounter" . " \tFROM " . $GLOBALS['xoopsDB']->prefix("seccont") . "\t\tORDER BY artid ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building ARTICLE table: " . ($count = $xoopsDB->getAffectedRows())); $sql = "\tINSERT INTO " . art_DB_prefix("artcat") . "\t\t(art_id, \tcat_id,\t\tuid,\tac_register,\tac_publish)" . "\tSELECT " . "\t\tartid,\t\tsecid,\t\t{$uid},\t{$time},\t\t{$time}" . " \tFROM " . $GLOBALS['xoopsDB']->prefix("seccont") . "\t\tORDER BY artid ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building ARTICLE-CATEGORY table: " . ($count = $xoopsDB->getAffectedRows())); $sql = "\tINSERT INTO " . art_DB_prefix("text") . "\t\t(text_id,\tart_id, \ttext_body, \tdohtml,\t\tdosmiley,\tdobr,\tdoimage,\tdoxcode)" . "\tSELECT " . "\t\tartid,\t\tartid,\t\tcontent,\t1,\t\t\t1,\t\t\t1,\t\t1,\t\t\t1" . " \tFROM " . $GLOBALS['xoopsDB']->prefix("seccont") . "\t\tORDER BY artid ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building TEXT table: " . ($count = $xoopsDB->getAffectedRows()));
<?php /** * Article management * * Import data from xfsection 1.12 * Limit: files will not be converted * * @copyright The XOOPS project http://www.xoops.org/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license * @author Taiwen Jiang (phppp or D.J.) <*****@*****.**> * @since 1.00 * @version $Id$ * @package module::article */ $sql = "\tINSERT INTO " . art_DB_prefix("category") . "\t\t(cat_id,\tcat_title,\t\tcat_pid,\tcat_description)" . "\tSELECT " . "\t\tid,\t\t\ttitle,\t\t\tpid,\t\tdescription" . " \tFROM " . $GLOBALS['xoopsDB']->prefix("xfs_category") . "\t\tORDER BY id ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building CATEGORY table: " . ($count = $xoopsDB->getAffectedRows())); $sql = "\tINSERT INTO " . art_DB_prefix("article") . "\t\t(art_id, \tart_title, \tcat_id,\t\tuid,\tart_summary,\tart_time_create,\tart_time_submit,\tart_time_publish, \tart_counter,\tart_rating,\t\t\t\tart_rates)" . "\tSELECT " . "\t\tarticleid,\ttitle,\t\tcategoryid,\tuid,\tsummary,\t\tcreated,\t\t\tcreated,\t\t\tcreated,\t\t\tcounter,\t\tFLOOR(rating * votes),\tvotes" . " \tFROM " . $GLOBALS['xoopsDB']->prefix("xfs_article") . "\t\tORDER BY articleid ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building ARTICLE table: " . ($count = $xoopsDB->getAffectedRows())); $sql = "\tINSERT INTO " . art_DB_prefix("artcat") . "\t\t(art_id, \tcat_id,\t\tuid,\tac_register,\tac_publish)" . "\tSELECT " . "\t\tarticleid,\tcategoryid,\tuid,\tcreated,\t\tcreated" . " \tFROM " . $GLOBALS['xoopsDB']->prefix("xfs_article") . "\t\tORDER BY articleid ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building ARTICLE-CATEGORY table: " . ($count = $xoopsDB->getAffectedRows())); $sql = "\tINSERT INTO " . art_DB_prefix("text") . "\t\t(text_id,\tart_id, \ttext_body, \tdohtml,\t\t\t\tdosmiley,\t\t\tdobr,\tdoimage,\tdoxcode)" . "\tSELECT " . "\t\tarticleid,\tarticleid,\tmaintext,\t(2-nohtml) DIV 2,\t(2-nosmiley) DIV 2,\t1,\t\t1,\t\t\t1" . " \tFROM " . $GLOBALS['xoopsDB']->prefix("xfs_article") . "\t\tORDER BY articleid ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building TEXT table: " . ($count = $xoopsDB->getAffectedRows())); $sql = "\tINSERT INTO " . art_DB_prefix("rate") . "\t\t(rate_id,\tart_id, \tuid, \t\trate_rating,\trate_time)" . "\tSELECT " . "\t\tratingid,\tlid,\t\tratinguser,\trating,\t\t\tratingtimestamp" . " \tFROM " . $GLOBALS['xoopsDB']->prefix("xfs_votedata") . "\t\tORDER BY ratingid ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building RATE table: " . ($count = $xoopsDB->getAffectedRows()));
function b_marquee_article($limit, $dateformat, $itemsize) { global $xoopsDB; include_once XOOPS_ROOT_PATH . '/modules/marquee/include/functions.php'; require_once XOOPS_ROOT_PATH . "/modules/article/include/functions.php"; $block = array(); $myts =& MyTextSanitizer::getInstance(); static $access_cats; $artConfig = art_load_config(); art_define_url_delimiter(); $select = "art_id"; $disp_tag = ""; $from = ""; $where = ""; $order = "art_time_publish DESC"; $select .= ", cat_id, art_title, uid, art_time_publish"; if (!isset($access_cats)) { $permission_handler =& xoops_getmodulehandler("permission", "article"); $access_cats =& $permission_handler->getCategories("access"); } $allowed_cats = $access_cats; $query = "SELECT {$select} FROM " . art_DB_prefix("article") . $from; $query .= " WHERE cat_id IN (" . implode(",", $allowed_cats) . ") AND art_time_publish >0 " . $where; $query .= " ORDER BY " . $order; $query .= " LIMIT 0, " . $limit; if (!($result = $xoopsDB->query($query))) { return false; } $rows = array(); $author = array(); while ($row = $xoopsDB->fetchArray($result)) { $rows[] = $row; $author[$row["uid"]] = 1; } if (count($rows) < 1) { return false; } $author_name = XoopsUser::getUnameFromId(array_keys($author)); $arts = array(); $uids = array(); $cids = array(); $article_handler =& xoops_getmodulehandler("article", "article"); foreach ($rows as $row) { $article =& $article_handler->create(false); $article->assignVars($row); $_art = array(); foreach ($row as $tag => $val) { $_art[$tag] = @$article->getVar($tag); } $_art["author"] = $author_name[$row["uid"]]; $_art["date"] = $article->getTime($dateformat); $titlelength = $itemsize + 3; $_art["title"] = xoops_substr($_art["art_title"], 0, $titlelength); $_art["category"] = ''; $delimiter = "/"; $_art["link"] = "<a href=\"" . XOOPS_URL . "modules/article/view.article.php{$delimiter}" . $_art["art_id"] . "/c" . $_art["cat_id"] . "\"><strong>" . $_art["art_title"] . "</strong></a>"; $arts[] = $_art; unset($article, $_art); $cids[$row["cat_id"]] = 1; } $block = $arts; return $block; }
<?php /** * Article management * * Import data from smartsection * * @copyright The XOOPS project http://www.xoops.org/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license * @author Taiwen Jiang (phppp or D.J.) <*****@*****.**> * @since 1.00 * @version $Id$ * @package module::article */ $sql = "\tINSERT INTO " . art_DB_prefix("category") . "\t\t(cat_id,\tcat_title,\t\tcat_pid,\tcat_description)" . "\tSELECT " . "\t\tcategoryid,\tname,\t\t\tparentid,\tdescription" . " \tFROM " . $GLOBALS['xoopsDB']->prefix("smartsection_categories") . "\t\tORDER BY categoryid ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building CATEGORY table: " . ($count = $xoopsDB->getAffectedRows())); $sql = "\tINSERT INTO " . art_DB_prefix("article") . "\t\t(art_id, \tart_title, \tcat_id,\t\tuid,\tart_keywords,\tart_summary,\tart_time_create,\tart_time_submit,\tart_time_publish, \tart_counter,\tart_comments)" . "\tSELECT " . "\t\titemid,\t\ttitle,\t\tcategoryid,\tuid,\tmeta_keywords, \tsummary,\t\tdatesub,\t\t\tdatesub,\t\t\tdatesub,\t\t\tcounter,\t\tcomments" . " \tFROM " . $GLOBALS['xoopsDB']->prefix("smartsection_items") . "\t\tORDER BY itemid ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building ARTICLE table: " . ($count = $xoopsDB->getAffectedRows())); $sql = "\tINSERT INTO " . art_DB_prefix("artcat") . "\t\t(art_id, \tcat_id,\t\tuid,\tac_register,\tac_publish)" . "\tSELECT " . "\t\titemid,\tcategoryid,\tuid,\tdatesub,\t\tdatesub" . " \tFROM " . $GLOBALS['xoopsDB']->prefix("smartsection_items") . "\t\tORDER BY itemid ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building ARTICLE-CATEGORY table: " . ($count = $xoopsDB->getAffectedRows())); $sql = "\tINSERT INTO " . art_DB_prefix("text") . "\t\t(text_id,\tart_id, \ttext_body, \tdohtml,\t\tdosmiley,\tdobr,\tdoimage,\tdoxcode)" . "\tSELECT " . "\t\titemid,\t\titemid,\t\tbody,\t\tdohtml,\t\tdosmiley,\tdobr,\tdoimage,\tdoxcode" . " \tFROM " . $GLOBALS['xoopsDB']->prefix("smartsection_items") . "\t\tORDER BY itemid ASC"; $result = $xoopsDB->queryF($sql); xoops_result("succeed with building TEXT table: " . ($count = $xoopsDB->getAffectedRows()));
$cat_criteria = " IN (" . implode(",", $cats) . ") "; // Get annual list if (empty($month)) { $sql = " SELECT " . " MONTH( FROM_UNIXTIME(ac.ac_publish - {$timeoffset}) ) AS mon, " . " COUNT(DISTINCT a.art_id) AS count " . " FROM " . art_DB_prefix("article") . " AS a " . " LEFT JOIN " . art_DB_prefix("artcat") . " AS ac ON ac.art_id = a.art_id " . " WHERE " . " YEAR( FROM_UNIXTIME(ac.ac_publish - {$timeoffset}) ) = {$year} " . " AND ac.cat_id {$cat_criteria} " . " GROUP BY mon"; $result = $xoopsDB->query($sql); $months = array(); while ($myrow = $xoopsDB->fetchArray($result)) { $months[] = array("title" => art_constant("MD_MONTH_" . intval($myrow["mon"])) . " (" . intval($myrow["count"]) . ")", "url" => XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.archive.php" . URL_DELIMITER . $year . "/" . $myrow["mon"]); } $timenav["prev"] = array("url" => XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.archive.php" . URL_DELIMITER . ($year - 1), "title" => sprintf(art_constant("MD_TIME_Y"), $year - 1)); if ($year < date("Y")) { $timenav["next"] = array("url" => XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.archive.php" . URL_DELIMITER . ($year + 1), "title" => sprintf(art_constant("MD_TIME_Y"), $year + 1)); } // Get monthly list } elseif (empty($day)) { $sql = " SELECT " . " DAY( FROM_UNIXTIME(ac.ac_publish - {$timeoffset})) AS day, " . " COUNT(DISTINCT a.art_id) AS count " . " FROM " . art_DB_prefix("article") . " AS a " . " LEFT JOIN " . art_DB_prefix("artcat") . " AS ac ON ac.art_id = a.art_id " . " WHERE YEAR( FROM_UNIXTIME(ac.ac_publish - {$timeoffset}) ) = {$year} " . " AND MONTH( FROM_UNIXTIME(ac.ac_publish - {$timeoffset}) ) = {$month} " . " AND ac.cat_id {$cat_criteria} " . " GROUP BY day"; $result = $xoopsDB->query($sql); $days = array(); while ($myrow = $xoopsDB->fetchArray($result)) { $days[$myrow["day"]]["count"] = $myrow["count"]; } for ($i = 1; $i <= 31; $i++) { if (!isset($days[$i])) { continue; } $days[$i] = array("title" => $days[$i]["count"], "url" => XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.archive.php" . URL_DELIMITER . $year . "/" . $month . "/" . $i); } $calendar = art_getCalendar($year, $month, $days); $month_next = $month + 1; $month_prev = $month - 1; $year_prev = $year_next = $year;
} foreach (array("cat_description", "cat_template", "cat_entry", "cat_sponsor") as $tag) { if (@$_POST[$tag] != $category->getVar($tag)) { $category->setVar($tag, $_POST[$tag]); } } if (art_isAdministrator()) { foreach (array("cat_title", "cat_order") as $tag) { if ($_POST[$tag] != $category->getVar($tag)) { $category->setVar($tag, $_POST[$tag]); } } $cat_pid = @$_POST["cat_pid"]; if ($cat_pid != $category->getVar("cat_pid") && $cat_pid != $category->getVar("cat_id")) { require_once XOOPS_ROOT_PATH . "/class/xoopstree.php"; $mytree = new XoopsTree(art_DB_prefix("category"), "cat_id", "cat_pid"); $idarray = $mytree->getAllChildId($category->getVar("cat_id")); if (!in_array($cat_pid, $idarray)) { $category->setVar("cat_pid", $cat_pid); } } $category->setVar("cat_moderator", empty($_POST["cat_moderator"]) ? array() : $_POST["cat_moderator"]); } $error_upload = ""; $cat_image = ""; if (!empty($_FILES['userfile']['name'])) { $uploader = new art_uploader(XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['path_image']); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if (!$uploader->upload()) { $error_upload = $uploader->getErrors(); } elseif (file_exists($uploader->getSavedDestination())) {