本文整理汇总了PHP中CForumNew::Concat方法的典型用法代码示例。如果您正苦于以下问题:PHP CForumNew::Concat方法的具体用法?PHP CForumNew::Concat怎么用?PHP CForumNew::Concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForumNew
的用法示例。
在下文中一共展示了CForumNew::Concat方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OnReindex
function OnReindex($NS = array(), $oCallback = NULL, $callback_method = "")
{
global $DB;
$arResultAll = array();
$arParams = array("PERMISSION" => array(), "SITE" => array(), "DEFAULT_URL" => array());
$search_message_count = intVal(COption::GetOptionInt("forum", "search_message_count", 0));
$strNSJoin = "";
$strFilter = "";
if ($NS["MODULE"] == "forum" && intVal($NS["ID"]) > 0 && intVal($NS["CNT"]) > 0) {
$strFilter = " AND (FM.ID>" . intVal($NS["ID"]) . ") ";
} elseif ($NS["MODULE"] == "forum" && intVal($NS["ID"]) > 0) {
// out of date
$strFilter = " AND (FM.ID>=" . intVal($NS["ID"]) . ") ";
}
if ($NS["SITE_ID"] != "") {
$strNSJoin .= " INNER JOIN b_forum2site FS ON (FS.FORUM_ID=F.ID) ";
$strFilter .= " AND FS.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "' ";
}
$strSql = "SELECT STRAIGHT_JOIN FT.ID as TID, FM.ID as MID, FM.ID as ID, FT.FORUM_ID, FT.TITLE, " . CForumNew::Concat("-", array("FT.ID", "FT.TITLE_SEO")) . ",\n\t\t\t\tFT.DESCRIPTION, FT.TAGS, FT.HTML as FT_HTML,\n\t\t\t\tFM.PARAM1, FM.PARAM2, FM.POST_MESSAGE, FM.POST_MESSAGE_FILTER, FM.POST_MESSAGE_HTML, FM.AUTHOR_NAME, FM.AUTHOR_ID, FM.NEW_TOPIC,\n\t\t\t\t" . $DB->DateToCharFunction("FM.POST_DATE") . " as POST_DATE, " . $DB->DateToCharFunction("FM.EDIT_DATE") . " as EDIT_DATE, FT.SOCNET_GROUP_ID, FT.OWNER_ID\n\t\t\tFROM b_forum_message FM use index (PRIMARY), b_forum_topic FT, b_forum F\n\t\t\t" . $strNSJoin . "\n\t\t\tWHERE (FM.TOPIC_ID = FT.ID) AND (F.ID = FT.FORUM_ID) AND (F.INDEXATION = 'Y') AND (FM.APPROVED = 'Y')\n\t\t\t" . $strFilter . "\n\t\t\tORDER BY FM.ID";
if ($search_message_count > 0) {
$strSql .= " LIMIT 0, " . $search_message_count;
}
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($db_res && COption::GetOptionString("forum", "FILTER", "Y") == "Y") {
$db_res = new _CMessageDBResult($db_res);
}
$rownum = 0;
while ($res = $db_res->Fetch()) {
$rownum++;
if (empty($arParams["PERMISSION"][$res["FORUM_ID"]])) {
$arGroups = CForumNew::GetAccessPermissions($res["FORUM_ID"]);
$arParams["PERMISSION"][$res["FORUM_ID"]] = array();
for ($i = 0; $i < count($arGroups); $i++) {
if ($arGroups[$i][1] >= "E") {
$arParams["PERMISSION"][$res["FORUM_ID"]][] = $arGroups[$i][0];
if ($arGroups[$i][0] == 2) {
break;
}
}
}
}
if (empty($arParams["SITE"][$res["FORUM_ID"]])) {
$arParams["SITE"][$res["FORUM_ID"]] = CForumNew::GetSites($res["FORUM_ID"]);
}
$arResult = array("ID" => $res["MID"], "LID" => array(), "LAST_MODIFIED" => !empty($res["EDIT_DATE"]) ? $res["EDIT_DATE"] : $res["POST_DATE"], "PARAM1" => $res["FORUM_ID"], "PARAM2" => $res["TID"], "USER_ID" => $res["AUTHOR_ID"], "ENTITY_TYPE_ID" => $res["NEW_TOPIC"] == "Y" ? "FORUM_TOPIC" : "FORUM_POST", "ENTITY_ID" => $res["NEW_TOPIC"] == "Y" ? $res["TID"] : $res["MID"], "PERMISSIONS" => $arParams["PERMISSION"][$res["FORUM_ID"]], "TITLE" => $res["TITLE"] . ($res["NEW_TOPIC"] == "Y" && !empty($res["DESCRIPTION"]) ? ", " . $res["DESCRIPTION"] : ""), "TAGS" => $res["NEW_TOPIC"] == "Y" ? $res["TAGS"] : "", "BODY" => GetMessage("AVTOR_PREF") . " " . $res["AUTHOR_NAME"] . ". " . textParser::killAllTags(COption::GetOptionString("forum", "FILTER", "Y") != "Y" ? $res["POST_MESSAGE"] : $res["POST_MESSAGE_FILTER"]), "URL" => "", "INDEX_TITLE" => $res["NEW_TOPIC"] == "Y");
foreach ($arParams["SITE"][$res["FORUM_ID"]] as $key => $val) {
$arResult["LID"][$key] = CForumNew::PreparePath2Message($val, array("FORUM_ID" => $res["FORUM_ID"], "TOPIC_ID" => $res["TID"], "MESSAGE_ID" => $res["MID"], "SOCNET_GROUP_ID" => $res["SOCNET_GROUP_ID"], "OWNER_ID" => $res["OWNER_ID"], "PARAM1" => $res["PARAM1"], "PARAM2" => $res["PARAM2"]));
if (empty($arResult["URL"]) && !empty($arResult["LID"][$key])) {
$arResult["URL"] = $arResult["LID"][$key];
}
}
if (empty($arResult["URL"])) {
if (empty($arParams["DEFAULT_URL"][$res["FORUM_ID"]])) {
$arParams["DEFAULT_URL"][$res["FORUM_ID"]] = "/";
foreach ($arParams["SITE"][$res["FORUM_ID"]] as $key => $val) {
$db_lang = CLang::GetByID($key);
if ($db_lang && ($ar_lang = $db_lang->Fetch())) {
$arParams["DEFAULT_URL"][$res["FORUM_ID"]] = $ar_lang["DIR"];
break;
}
}
$arParams["DEFAULT_URL"][$res["FORUM_ID"]] .= COption::GetOptionString("forum", "REL_FPATH", "") . "forum/read.php?FID=#FID#&TID=#TID#&MID=#MID##message#MID#";
}
$arResult["URL"] = CForumNew::PreparePath2Message($arParams["DEFAULT_URL"][$res["FORUM_ID"]], array("FORUM_ID" => $res["FORUM_ID"], "TOPIC_ID" => $res["TID"], "MESSAGE_ID" => $res["MID"], "SOCNET_GROUP_ID" => $res["SOCNET_GROUP_ID"], "OWNER_ID" => $res["OWNER_ID"], "PARAM1" => $res["PARAM1"], "PARAM2" => $res["PARAM2"]));
}
if ($oCallback) {
$resCall = call_user_func(array($oCallback, $callback_method), $arResult);
if (!$resCall) {
return $arResult["ID"];
}
} else {
$arResultAll[] = $arResult;
}
}
if ($oCallback && $search_message_count > 0 && $rownum >= $search_message_count - 1) {
return $arResult["ID"];
}
if ($oCallback) {
return false;
}
return $arResultAll;
}
示例2: GetListEx
//.........这里部分代码省略.........
(FUT.LAST_VISIT IS NULL AND FM.POST_DATE ".$strOperation." ".$DB->CharToDateFunction($DB->ForSql($val), "FULL").")
";
}
break;
case "USER_GROUP":
if (!empty($val))
{
if (!is_array($val))
$val = explode(",", $val);
if (!in_array(2, $val))
$val[] = 2;
$val = implode(",", $val);
$arSqlFrom["FP"] = "LEFT JOIN b_forum_perms FP ON (FP.FORUM_ID=FM.FORUM_ID)";
$arSqlSearch[] = "FP.GROUP_ID IN (".$DB->ForSql($val).") AND ((FP.PERMISSION IN ('E','I','M') AND FM.APPROVED='Y') OR (FP.PERMISSION IN ('Q','U','Y')))";
$UseGroup = true;
}
break;
case "TOPIC_SOCNET_GROUP_ID":
$arSqlFrom["FT"] = "
LEFT JOIN b_forum_topic FT ON (FT.ID = FM.TOPIC_ID)";
$arSqlSearch[] = "FT.SOCNET_GROUP_ID = ".IntVal($val);
$arSqlSelect[] = "FT.SOCNET_GROUP_ID as TOPIC_SOCNET_GROUP_ID";
break;
case "TOPIC_OWNER_ID":
$arSqlFrom["FT"] = "
LEFT JOIN b_forum_topic FT ON (FT.ID = FM.TOPIC_ID)";
$arSqlSearch[] = "FT.OWNER_ID = ".IntVal($val);
$arSqlSelect[] = "FT.OWNER_ID as TOPIC_OWNER_ID";
break;
case "TOPIC":
$arSqlFrom["FT"] = "
LEFT JOIN b_forum_topic FT ON (FT.ID = FM.TOPIC_ID)";
$arSqlSelect[] = "FT.TITLE";
$arSqlSelect[] = CForumNew::Concat("-", array("FT.ID", "FT.TITLE_SEO"))." as TITLE_SEO";
$arSqlSelect[] = "FT.DESCRIPTION AS TOPIC_DESCRIPTION";
$arSqlSelect[] = $DB->DateToCharFunction("FT.START_DATE", "FULL")." as START_DATE";
$arSqlSelect[] = "FT.USER_START_NAME";
$arSqlSelect[] = "FT.USER_START_ID";
$arSqlSelect[] = "FT.XML_ID AS TOPIC_XML_ID";
$arSqlSelect[] = "FT.SOCNET_GROUP_ID AS TOPIC_SOCNET_GROUP_ID";
$arSqlSelect[] = "FT.OWNER_ID AS TOPIC_OWNER_ID";
break;
case "TOPIC_MESSAGE_ID":
if (is_array($val))
{
$val_int = array();
foreach ($val as $v)
$val_int[] = intval($v);
$val = implode(", ", $val_int);
}
else
{
$val = intval($val);
}
if (!empty($val))
{
$arSqlFrom["FT"] = "
LEFT JOIN b_forum_topic FT ON (FT.ID = FM.TOPIC_ID)";
$arSqlSearch[] = "FT.ID IN (SELECT DISTINCT TOPIC_ID FROM b_forum_message WHERE ID IN (".$val."))";
}
break;
case "TOPIC_TITLE":
case "TITLE":
$arSqlFrom["FT"] = "
LEFT JOIN b_forum_topic FT ON (FT.ID = FM.TOPIC_ID)";
$key = "TITLE";
示例3: GetListEx
public static function GetListEx($arOrder = array("ID" => "ASC"), $arFilter = array())
{
global $DB;
$arSqlSearch = array();
$arSqlFrom = array();
$arSqlGroup = array();
$arSqlSelect = array();
$arSqlOrder = array();
$strSqlSelect = "";
$strSqlSearch = "";
$strSqlFrom = "";
$strSqlGroup = "";
$strSqlOrder = "";
$arSqlSelectConst = array("FS.ID" => "FS.ID", "FS.USER_ID" => "FS.USER_ID", "FS.FORUM_ID" => "FS.FORUM_ID", "FS.TOPIC_ID" => "FS.TOPIC_ID", "TITLE_SEO" => CForumNew::Concat("-", array("FS.TOPIC_ID", "FT.TITLE_SEO")), "FS.LAST_SEND" => "FS.LAST_SEND", "FS.NEW_TOPIC_ONLY" => "FS.NEW_TOPIC_ONLY", "FS.SITE_ID" => "FS.SITE_ID", "START_DATE" => $DB->DateToCharFunction("FS.START_DATE", "FULL"), "U.EMAIL" => "U.EMAIL", "U.LOGIN" => "U.LOGIN", "U.NAME" => "U.NAME", "U.LAST_NAME" => "U.LAST_NAME", "FT.TITLE" => "FT.TITLE", "FORUM_NAME" => "F.NAME");
$arFilter = is_array($arFilter) ? $arFilter : array();
foreach ($arFilter as $key => $val) {
$key_res = CForumNew::GetFilterOperation($key);
$key = strtoupper($key_res["FIELD"]);
$strNegative = $key_res["NEGATIVE"];
$strOperation = $key_res["OPERATION"];
switch ($key) {
case "ID":
case "USER_ID":
case "FORUM_ID":
case "TOPIC_ID":
case "LAST_SEND":
if (intVal($val) <= 0) {
$arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FS." . $key . " IS NULL OR FS." . $key . "<=0)";
} else {
$arSqlSearch[] = ($strNegative == "Y" ? " FS." . $key . " IS NULL OR NOT " : "") . "(FS." . $key . " " . $strOperation . " " . intVal($val) . " )";
}
break;
case "TOPIC_ID_OR_NULL":
$arSqlSearch[] = "(FS.TOPIC_ID = " . intVal($val) . " OR FS.TOPIC_ID = 0 OR FS.TOPIC_ID IS NULL)";
break;
case "NEW_TOPIC_ONLY":
if (strLen($val) <= 0) {
$arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FS." . $key . " IS NULL)";
} else {
$arSqlSearch[] = ($strNegative == "Y" ? " FS." . $key . " IS NULL OR NOT " : "") . "(FS." . $key . " " . $strOperation . " '" . $DB->ForSql($val) . "' )";
}
break;
case "START_DATE":
if (strLen($val) <= 0) {
$arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FS." . $key . " IS NULL)";
} else {
$arSqlSearch[] = ($strNegative == "Y" ? " FS." . $key . " IS NULL OR NOT " : "") . "(FS." . $key . " " . $strOperation . " " . $DB->CharToDateFunction($DB->ForSql($val), "SHORT") . ")";
}
break;
case "LAST_SEND_OR_NULL":
$arSqlSearch[] = "(FS.LAST_SEND IS NULL OR FS.LAST_SEND = 0 OR FS.LAST_SEND < " . intVal($val) . ")";
break;
case "ACTIVE":
if (strLen($val) <= 0) {
$arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(U." . $key . " IS NULL)";
} else {
$arSqlSearch[] = ($strNegative == "Y" ? " U." . $key . " IS NULL OR NOT " : "") . "(U." . $key . " " . $strOperation . " '" . $DB->ForSql($val) . "' )";
}
break;
case "FORUM":
case "TOPIC":
$key = $key == "FORUM" ? "F.NAME" : "FT.TITLE";
$arSqlSearch[] = GetFilterQuery($key, $val);
break;
case "SOCNET_GROUP_ID":
if ($val > 0) {
$arSqlSearch[] = "FS.SOCNET_GROUP_ID=" . intval($val);
} else {
$arSqlSearch[] = "FS.SOCNET_GROUP_ID IS NULL";
}
break;
case "PERMISSION":
if ($arFilter["SOCNET_GROUP_ID"] > 0) {
$arSqlSearch[] = "EXISTS(SELECT 'x'\n\t\t\t\t\t\t\tFROM b_sonet_features SF\n\t\t\t\t\t\t\t\tINNER JOIN b_sonet_features2perms SFP ON SFP.FEATURE_ID = SF.ID AND SFP.OPERATION_ID = 'view'\n\t\t\t\t\t\t\tWHERE SF.ENTITY_TYPE = 'G'\n\t\t\t\t\t\t\t\tAND SF.ENTITY_ID = FS.SOCNET_GROUP_ID\n\t\t\t\t\t\t\t\tAND SF.FEATURE = 'forum'\n\t\t\t\t\t\t\t\tAND SFP.ROLE = 'N' OR EXISTS(SELECT 'x' FROM b_sonet_user2group UG WHERE UG.USER_ID = FS.USER_ID AND " . $DB->IsNull("SFP.ROLE", "'K'") . " >= UG.ROLE AND UG.GROUP_ID = FS.SOCNET_GROUP_ID)\n\t\t\t\t\t\t) ";
} elseif (strLen($val) > 0) {
$arSqlSearch[] = "(\n\t\t\t\t\t\t\t(FP.PERMISSION >= '" . $DB->ForSql($val) . "') OR\n\t\t\t\t\t\t\t(FP1.PERMISSION >= '" . $DB->ForSql($val) . "') OR\n\t\t\t\t\t\t\t((FP.ID IS NULL) AND (UG.GROUP_ID = 1)))";
$arSqlSelect[] = "FU.SUBSC_GROUP_MESSAGE, FU.SUBSC_GET_MY_MESSAGE";
$arSqlFrom[] = "\n\t\t\t\t\t\t\tLEFT JOIN b_forum_user FU ON (U.ID = FU.USER_ID)\n\t\t\t\t\t\t\tLEFT JOIN b_user_group UG ON (U.ID = UG.USER_ID)\n\t\t\t\t\t\t\tLEFT JOIN b_forum_perms FP ON (FP.FORUM_ID = FS.FORUM_ID AND FP.GROUP_ID=UG.GROUP_ID)\n\t\t\t\t\t\t\tLEFT JOIN b_forum_perms FP1 ON (FP1.FORUM_ID = FS.FORUM_ID AND FP1.GROUP_ID=2)";
$arSqlGroup = array_values($arSqlSelectConst);
$arSqlGroup[] = "FU.SUBSC_GROUP_MESSAGE, FU.SUBSC_GET_MY_MESSAGE";
}
break;
}
}
if (count($arSqlSelect) > 0) {
$strSqlSelect .= ", " . implode(", ", $arSqlSelect);
}
if (count($arSqlSearch) > 0) {
$strSqlSearch .= " AND (" . implode(")\n\t\t\tAND\n\t\t\t(", $arSqlSearch) . ") ";
}
if (count($arSqlFrom) > 0) {
$strSqlFrom .= " " . implode(" ", $arSqlFrom) . " ";
}
if (count($arSqlGroup) > 0) {
$strSqlGroup .= " GROUP BY " . implode(", ", $arSqlGroup) . " ";
}
foreach ($arOrder as $by => $order) {
$by = strtoupper($by);
$order = strtoupper($order);
if ($order != "ASC") {
//.........这里部分代码省略.........
示例4: GetListEx
//.........这里部分代码省略.........
$arSqlFrom["FP"] = "LEFT JOIN b_forum_perms FP ON (FP.FORUM_ID=FT.FORUM_ID)";
$arSqlSearch[] = "FP.GROUP_ID IN (" . $DB->ForSql($USER->GetGroups()) . ") AND (FP.PERMISSION IN ('Q','U','Y'))";
$UseGroup = true;
break;
}
}
if (count($arSqlSearch) > 0) {
$strSqlSearch = " AND (" . implode(") AND (", $arSqlSearch) . ")";
}
if (count($arSqlSelect) > 0) {
$res = array();
foreach ($arSqlSelect as $key => $val) {
if (substr($key, 0, 1) == "!") {
$key = substr($key, 1);
}
if ($key != $val) {
$res[] = $val . " AS " . $key;
} else {
$res[] = $val;
}
}
$strSqlSelect = ", " . implode(", ", $res);
}
if (count($arSqlFrom) > 0) {
$strSqlFrom = implode("\n", $arSqlFrom);
}
if ($UseGroup) {
foreach ($arSqlSelect as $key => $val) {
if (substr($key, 0, 1) != "!") {
$arSqlGroup[$key] = $val;
}
}
if (!empty($arSqlGroup)) {
$strSqlGroup = ", " . implode(", ", $arSqlGroup);
}
}
foreach ($arOrder as $by => $order) {
$by = strtoupper($by);
$order = strtoupper($order);
if ($order != "ASC") {
$order = "DESC";
}
if (in_array($by, array("ID", "FORUM_ID", "TOPIC_ID", "TITLE", "TAGS", "DESCRIPTION", "ICON_ID", "STATE", "APPROVED", "SORT", "VIEWS", "USER_START_ID", "USER_START_NAME", "START_DATE", "POSTS", "LAST_POSTER_ID", "LAST_POSTER_NAME", "LAST_POST_DATE", "LAST_MESSAGE_ID", "POSTS_UNAPPROVED", "ABS_LAST_POSTER_ID", "ABS_LAST_POSTER_NAME", "ABS_LAST_POST_DATE", "ABS_LAST_MESSAGE_ID", "SOCNET_GROUP_ID", "OWNER_ID", "HTML", "XML_ID"))) {
$arSqlOrder[] = "FT." . $by . " " . $order;
} elseif ($by == "FORUM_NAME") {
$arSqlOrder[] = "F.NAME " . $order;
} else {
$arSqlOrder[] = "FT.SORT " . $order;
$by = "SORT";
}
}
$arSqlOrder = array_unique($arSqlOrder);
DelDuplicateSort($arSqlOrder);
if (count($arSqlOrder) > 0) {
$strSqlOrder = " ORDER BY " . implode(", ", $arSqlOrder);
}
if ($bCount || is_set($arAddParams, "bDescPageNumbering") && intVal($arAddParams["nTopCount"]) <= 0) {
$strSql = "SELECT COUNT(FT.ID) as CNT FROM b_forum_topic FT ";
$arCountSqlFrom = $arSqlFrom;
if (isset($arSqlFrom['FUT']) && strpos($strSqlSearch, "FUT.") === false) {
unset($arCountSqlFrom['FUT']);
}
$strSqlCountFrom = implode("\n", $arCountSqlFrom);
$strSql .= $strSqlCountFrom . " WHERE 1 = 1 " . $strSqlSearch;
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$iCnt = 0;
if ($ar_res = $db_res->Fetch()) {
$iCnt = intVal($ar_res["CNT"]);
}
if ($bCount) {
return $iCnt;
}
}
$arSQL = array("select" => "", "join" => "");
if (!empty($arAddParams["sNameTemplate"])) {
$arSQL = array_merge_recursive(CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U_START.", "sForumUserTablePrefix" => "FU_START.", "sFieldName" => "USER_START_NAME_FRMT", "sUserIDFieldName" => "FT.USER_START_ID"))), CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U_LAST.", "sForumUserTablePrefix" => "FU_LAST.", "sFieldName" => "LAST_POSTER_NAME_FRMT", "sUserIDFieldName" => "FT.LAST_POSTER_ID"))), CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U_ABS_LAST.", "sForumUserTablePrefix" => "FU_ABS_LAST.", "sFieldName" => "ABS_LAST_POSTER_NAME_FRMT", "sUserIDFieldName" => "FT.ABS_LAST_POSTER_ID"))));
$arSQL["select"] = ",\n\t" . implode(",\n\t", $arSQL["select"]);
$arSQL["join"] = "\n" . implode("\n", $arSQL["join"]);
}
if ($UseGroup) {
$strSql = " SELECT F_T.*, FT.FORUM_ID, FT.TOPIC_ID, FT.TITLE, FT.TAGS, FT.DESCRIPTION, FT.ICON_ID, \n" . "\tFT.STATE, FT.APPROVED, FT.SORT, FT.VIEWS, FT.USER_START_ID, FT.USER_START_NAME, \n" . "\t" . CForumNew::Concat("-", array("FT.ID", "FT.TITLE_SEO")) . " as TITLE_SEO, \n" . "\t" . $DB->DateToCharFunction("FT.START_DATE", "FULL") . " as START_DATE, \n" . "\tFT.POSTS, FT.LAST_POSTER_ID, FT.LAST_POSTER_NAME, \n" . "\t" . $DB->DateToCharFunction("FT.LAST_POST_DATE", "FULL") . " as LAST_POST_DATE, \n" . "\tFT.LAST_POST_DATE AS LAST_POST_DATE_ORIGINAL, FT.LAST_MESSAGE_ID, \n" . "\tFT.POSTS_UNAPPROVED, FT.ABS_LAST_POSTER_ID, FT.ABS_LAST_POSTER_NAME, \n" . "\t" . $DB->DateToCharFunction("FT.ABS_LAST_POST_DATE", "FULL") . " as ABS_LAST_POST_DATE, \n" . "\tFT.ABS_LAST_POST_DATE AS ABS_LAST_POST_DATE_ORIGINAL, FT.ABS_LAST_MESSAGE_ID, \n" . "\tFT.SOCNET_GROUP_ID, FT.OWNER_ID, FT.HTML, FT.XML_ID, \n" . "\tF.NAME as FORUM_NAME, \n" . "\tFS.IMAGE, '' as IMAGE_DESCR " . $arSQL["select"] . " \n" . " FROM \n" . "\t( \n" . "\t\tSELECT FT.ID" . $strSqlSelect . " \n" . "\t\tFROM b_forum_topic FT \n" . "\t\t\tLEFT JOIN b_forum F ON (FT.FORUM_ID = F.ID) \n" . "\t\t\t" . $strSqlFrom . " \n" . "\t\tWHERE 1 = 1 " . $strSqlSearch . " \n" . "\t\tGROUP BY FT.ID" . $strSqlGroup . " \n" . "\t) F_T \n" . " INNER JOIN b_forum_topic FT ON (F_T.ID = FT.ID) \n" . " LEFT JOIN b_forum F ON (FT.FORUM_ID = F.ID) \n" . " LEFT JOIN b_forum_smile FS ON (FT.ICON_ID = FS.ID) " . $arSQL["join"] . " \n" . $strSqlOrder;
} else {
$strSql = " SELECT FT.ID, FT.FORUM_ID, FT.TOPIC_ID, FT.TITLE, FT.TAGS, FT.DESCRIPTION, FT.ICON_ID, \n" . "\tFT.STATE, FT.APPROVED, FT.SORT, FT.VIEWS, FT.USER_START_ID, FT.USER_START_NAME, \n" . "\t" . CForumNew::Concat("-", array("FT.ID", "FT.TITLE_SEO")) . " as TITLE_SEO, \n" . "\t" . $DB->DateToCharFunction("FT.START_DATE", "FULL") . " as START_DATE, \n" . "\tFT.POSTS, FT.LAST_POSTER_ID, FT.LAST_POSTER_NAME, \n" . "\t" . $DB->DateToCharFunction("FT.LAST_POST_DATE", "FULL") . " as LAST_POST_DATE, \n" . "\tFT.LAST_POST_DATE AS LAST_POST_DATE_ORIGINAL, FT.LAST_MESSAGE_ID, \n" . "\tFT.POSTS_UNAPPROVED, FT.ABS_LAST_POSTER_ID, FT.ABS_LAST_POSTER_NAME, \n" . "\t" . $DB->DateToCharFunction("FT.ABS_LAST_POST_DATE", "FULL") . " as ABS_LAST_POST_DATE, \n" . "\tFT.ABS_LAST_POST_DATE AS ABS_LAST_POST_DATE_ORIGINAL, FT.ABS_LAST_MESSAGE_ID, \n" . "\tFT.SOCNET_GROUP_ID, FT.OWNER_ID, FT.HTML, FT.XML_ID, \n" . "\tF.NAME as FORUM_NAME, \n" . "\tFS.IMAGE, '' as IMAGE_DESCR" . $strSqlSelect . $arSQL["select"] . " \n" . " FROM b_forum_topic FT \n" . "\tLEFT JOIN b_forum F ON (FT.FORUM_ID = F.ID) \n" . "\tLEFT JOIN b_forum_smile FS ON (FT.ICON_ID = FS.ID) \n" . "\t" . $strSqlFrom . $arSQL["join"] . " \n" . " WHERE 1 = 1 " . $strSqlSearch . " \n" . $strSqlOrder;
}
$iNum = intVal($iNum);
if ($iNum > 0 || intVal($arAddParams["nTopCount"]) > 0) {
$iNum = $iNum > 0 ? $iNum : intVal($arAddParams["nTopCount"]);
$strSql .= "\nLIMIT 0," . $iNum;
}
if (!$iNum && is_set($arAddParams, "bDescPageNumbering") && intVal($arAddParams["nTopCount"]) <= 0) {
$db_res = new CDBResult();
$db_res->NavQuery($strSql, $iCnt, $arAddParams);
} else {
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
if (is_set($arAddParams, 'NoFilter') && $arAddParams['NoFilter'] == true) {
return $db_res;
}
return new _CTopicDBResult($db_res, $arAddParams);
}
示例5: GetListEx
//.........这里部分代码省略.........
$strSqlSelect = ", " . implode(", ", $arSqlSelect);
}
if (count($arSqlFrom) > 0) {
$strSqlFrom = " " . implode(" ", $arSqlFrom);
}
if (count($arSqlGroup) > 0) {
$strSqlGroup = "," . implode(",", $arSqlGroup);
}
foreach ($arOrder as $by => $order) {
$by = strtoupper($by);
$order = strtoupper($order);
if ($order != "ASC") {
$order = "DESC" . ($DB->type == "ORACLE" ? " NULLS LAST" : "");
} else {
$order = "ASC" . ($DB->type == "ORACLE" ? " NULLS FIRST" : "");
}
if ($by == "ID") {
$arSqlOrder["F_FORUM.ID"] = " F_FORUM.ID " . $order . " ";
} elseif ($by == "NAME") {
$arSqlOrder["F.NAME"] = " F.NAME " . $order . " ";
} elseif ($by == "ACTIVE") {
$arSqlOrder["F.ACTIVE"] = " F.ACTIVE " . $order . " ";
} elseif ($by == "MODERATION") {
$arSqlOrder["F.MODERATION"] = " F.MODERATION " . $order . " ";
} elseif ($by == "FORUM_GROUP_ID") {
$arSqlOrder["F.FORUM_GROUP_ID"] = " F.FORUM_GROUP_ID " . $order . " ";
} elseif ($by == "FORUM_GROUP_SORT") {
$arSqlOrder["FG.SORT"] = " FG.SORT " . $order . " ";
} elseif ($by == "FORUM_GROUP_LEFT_MARGIN") {
$arSqlOrder["FG.LEFT_MARGIN"] = " FG.LEFT_MARGIN " . $order . " ";
} elseif ($by == "TOPICS") {
$arSqlOrder["F.TOPICS"] = " F.TOPICS " . $order . " ";
} elseif ($by == "POSTS") {
$arSqlOrder["F.POSTS"] = " F.POSTS " . $order . " ";
} elseif ($by == "POSTS_UNAPPROVED") {
$arSqlOrder["F.POSTS_UNAPPROVED"] = " F.POSTS_UNAPPROVED " . $order . " ";
} elseif ($by == "LAST_POST_DATE") {
$arSqlOrder["F.LAST_POST_DATE"] = " F.LAST_POST_DATE " . $order . " ";
} elseif ($by == "ABS_LAST_POST_DATE") {
$arSqlOrder["F.ABS_LAST_POST_DATE"] = " F.ABS_LAST_POST_DATE " . $order . " ";
} else {
$arSqlOrder["F.SORT"] = " F.SORT " . $order . " ";
$by = "SORT";
}
}
if (count($arSqlOrder) > 0) {
$strSqlOrder = " ORDER BY " . implode(", ", $arSqlOrder);
}
if ($bCount || is_set($arAddParams, "bDescPageNumbering") && intVal($arAddParams["nTopCount"]) <= 0) {
$arCountSqlFrom = $arSqlFrom;
if (isset($arSqlFrom['RENEW']) && strpos($strSqlSearch, "RENEW.") === false) {
unset($arCountSqlFrom['RENEW']);
}
$strSqlCountFrom = implode(" ", $arCountSqlFrom);
$strSql = "SELECT COUNT(FORUMCOUNT.ID) as CNT FROM (" . "SELECT F.ID " . " FROM b_forum F " . $strSqlCountFrom . " " . " WHERE (1=1 " . $strSqlSearch . ") " . $strSqlSearchOR . " GROUP BY F.ID" . ") FORUMCOUNT";
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$iCnt = 0;
if ($ar_res = $db_res->Fetch()) {
$iCnt = intVal($ar_res["CNT"]);
}
if ($bCount) {
return $iCnt;
}
}
if (!$iNum && is_set($arAddParams, "bDescPageNumbering") && intVal($arAddParams["nTopCount"]) <= 0 && isset($arAddParams['nav_result'])) {
if (!$arAddParams['nav_result']) {
$strSubSql = "SELECT F_FORUM.* " . "FROM " . "(SELECT F.ID, FG.SORT " . $strSqlSelect . " " . "FROM b_forum F " . $strSqlFrom . " " . "LEFT JOIN b_forum_group FG ON F.FORUM_GROUP_ID = FG.ID " . "WHERE (1=1 " . $strSqlSearch . ") " . $strSqlSearchOR . " " . "GROUP BY F.ID, FG.SORT" . $strSqlGroup . ") F_FORUM " . "INNER JOIN b_forum F ON (F_FORUM.ID = F.ID) " . str_replace("FG.SORT", "F_FORUM.SORT", $strSqlOrder);
$db_res = new CDBResult();
$db_res->NavQuery($strSubSql, $iCnt, $arAddParams);
return $db_res;
} else {
$db_res = $arAddParams['nav_result'];
}
$arForumID = array();
while ($ar_res = $db_res->Fetch()) {
$arForumID[] = $ar_res['ID'];
}
$sForumID = implode(', ', $arForumID);
$strSqlSearch = "(" . ($sForumID != "" ? "F.ID IN (" . $sForumID . ") " : "1=1 ") . $strSqlSearch . ")";
} else {
$strSqlSearch = "(1=1 " . $strSqlSearch . ")";
}
$arSQL = array("select" => "", "join" => "");
if (!empty($arAddParams["sNameTemplate"])) {
$arSQL = array_merge_recursive(CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U_LAST.", "sForumUserTablePrefix" => "FU_LAST.", "sFieldName" => "LAST_POSTER_NAME_FRMT", "sUserIDFieldName" => "F.LAST_POSTER_ID"))), CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U_ABS_LAST.", "sForumUserTablePrefix" => "FU_ABS_LAST.", "sFieldName" => "ABS_LAST_POSTER_NAME_FRMT", "sUserIDFieldName" => "F.ABS_LAST_POSTER_ID"))));
$arSQL["select"] = ",\n\t" . implode(",\n\t", $arSQL["select"]);
$arSQL["join"] = "\n" . implode("\n", $arSQL["join"]);
}
$strSql = "SELECT F_FORUM.*, F.FORUM_GROUP_ID, F.NAME, F.DESCRIPTION, F.SORT, F.ACTIVE,\n\t\t\t\tF.ALLOW_HTML, F.ALLOW_ANCHOR, F.ALLOW_BIU, F.ALLOW_IMG, F.ALLOW_VIDEO,\n\t\t\t\tF.ALLOW_LIST, F.ALLOW_QUOTE, F.ALLOW_CODE, F.ALLOW_FONT, F.ALLOW_SMILES,\n\t\t\t\tF.ALLOW_ALIGN, F.ALLOW_UPLOAD, F.ALLOW_UPLOAD_EXT, F.ALLOW_MOVE_TOPIC,\n\t\t\t\tF.ALLOW_NL2BR, F.ALLOW_TABLE, F.ALLOW_TOPIC_TITLED, F.ALLOW_SIGNATURE,\n\t\t\t\t" . (strpos($strSqlSelect, "PATH2FORUM_MESSAGE") === false ? "'' as PATH2FORUM_MESSAGE," : "") . "\n\t\t\t\tF.ASK_GUEST_EMAIL, F.USE_CAPTCHA, F.MODERATION, F.INDEXATION, F.DEDUPLICATION,\n\t\t\t\tF.ORDER_BY, F.ORDER_DIRECTION,\n\t\t\t\t'' as LID, '' as DIR,\n\t\t\t\tF.TOPICS, F.XML_ID,\n\t\t\t\tF.POSTS, F.LAST_POSTER_ID, F.LAST_POSTER_NAME,\n\t\t\t\t" . $DB->DateToCharFunction("F.LAST_POST_DATE", "FULL") . " as LAST_POST_DATE,\n\t\t\t\tF.LAST_MESSAGE_ID, FM.TOPIC_ID as TID, F.LAST_MESSAGE_ID as MID,\n\t\t\t\tF.POSTS_UNAPPROVED, F.ABS_LAST_POSTER_ID, F.ABS_LAST_POSTER_NAME,\n\t\t\t\t" . $DB->DateToCharFunction("F.ABS_LAST_POST_DATE", "FULL") . " as ABS_LAST_POST_DATE,\n\t\t\t\tF.ABS_LAST_MESSAGE_ID, FM_ABS.TOPIC_ID as ABS_TID,\n\t\t\t\tF.EVENT1, F.EVENT2, F.EVENT3,\n\t\t\t\tFT.TITLE, FT.SOCNET_GROUP_ID, FT.OWNER_ID,\n\t\t\t\t" . CForumNew::Concat("-", array("FT.ID", "FT.TITLE_SEO")) . " AS TITLE_SEO,\n\t\t\t\tFT.HTML AS TOPIC_HTML, FM.PARAM1, FM.PARAM2,\n\t\t\t\tFT_ABS.TITLE as ABS_TITLE, FT_ABS.SOCNET_GROUP_ID as ABS_SOCNET_GROUP_ID, FT_ABS.OWNER_ID as ABS_OWNER_ID,\n\t\t\t\t" . CForumNew::Concat("-", array("FT_ABS.ID", "FT_ABS.TITLE_SEO")) . " AS ABS_TITLE_SEO,\n\t\t\t\tFT_ABS.HTML AS ABS_TOPIC_HTML, FM_ABS.PARAM1 as ABS_PARAM1, FM_ABS.PARAM2 as ABS_PARAM2,\n\t\t\t\tF.HTML" . $arSQL["select"] . "\n\t\t\tFROM\n\t\t\t(\n\t\t\t\tSELECT F.ID " . $strSqlSelect . "\n\t\t\t\tFROM b_forum F\n\t\t\t\t\t" . $strSqlFrom . "\n\t\t\t\tWHERE " . $strSqlSearch . "\n\t\t\t\t\t" . $strSqlSearchOR . "\n\t\t\t\tGROUP BY F.ID" . $strSqlGroup . "\n\t\t\t) F_FORUM\n\t\t\tINNER JOIN b_forum F ON (F_FORUM.ID = F.ID)" . $arSQL["join"] . "\n\t\t\tLEFT JOIN b_forum_group FG ON F.FORUM_GROUP_ID = FG.ID\n\t\t\tLEFT JOIN b_forum_message FM ON F.LAST_MESSAGE_ID = FM.ID\n\t\t\tLEFT JOIN b_forum_topic FT ON FM.TOPIC_ID = FT.ID\n\t\t\tLEFT JOIN b_forum_message FM_ABS ON F.ABS_LAST_MESSAGE_ID = FM_ABS.ID\n\t\t\tLEFT JOIN b_forum_topic FT_ABS ON FM_ABS.TOPIC_ID = FT_ABS.ID\n\t\t\t" . $strSqlOrder;
$iNum = intVal($iNum);
if ($iNum > 0 || intVal($arAddParams["nTopCount"]) > 0) {
$iNum = $iNum > 0 ? $iNum : intVal($arAddParams["nTopCount"]);
$strSql .= " LIMIT 0," . $iNum;
}
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if (is_set($arAddParams, 'NoFilter') && $arAddParams['NoFilter'] == true) {
return $db_res;
}
return new _CForumDBResult($db_res, $arAddParams);
}
示例6: GetSelectFields
function GetSelectFields($arAddParams = array(), $fields = array())
{
global $DB;
$arAddParams = is_array($arAddParams) ? $arAddParams : array();
$arAddParams["sPrefix"] = $DB->ForSql(empty($arAddParams["sPrefix"]) ? "FT." : $arAddParams["sPrefix"]);
$arAddParams["sTablePrefix"] = $DB->ForSql(empty($arAddParams["sTablePrefix"]) ? "FT." : $arAddParams["sTablePrefix"]);
$arAddParams["sReturnResult"] = $arAddParams["sReturnResult"] == "string" ? "string" : "array";
$fields = is_array($fields) ? $fields : array();
$fields = array_merge(array("ID" => "ID", "TITLE" => "TITLE", "TITLE_SEO_REAL" => $arAddParams["sTablePrefix"] . "TITLE_SEO", "TITLE_SEO" => CForumNew::Concat("-", array($arAddParams["sTablePrefix"] . "ID", $arAddParams["sTablePrefix"] . "TITLE_SEO")), "TAGS" => "TAGS", "DESCRIPTION" => "DESCRIPTION", "VIEWS" => "VIEWS", "LAST_POSTER_ID" => "LAST_POSTER_ID", "START_DATE" => $DB->DateToCharFunction($arAddParams["sTablePrefix"] . "START_DATE", "FULL"), "USER_START_NAME" => "USER_START_NAME", "USER_START_ID" => "USER_START_ID", "POSTS" => "POSTS", "LAST_POSTER_NAME" => "LAST_POSTER_NAME", "LAST_POST_DATE" => $DB->DateToCharFunction($arAddParams["sTablePrefix"] . "LAST_POST_DATE", "FULL"), "LAST_MESSAGE_ID" => "LAST_MESSAGE_ID", "APPROVED" => "APPROVED", "STATE" => "STATE", "FORUM_ID" => "FORUM_ID", "TOPIC_ID" => "TOPIC_ID", "ICON" => "ICON", "SORT" => "SORT", "SOCNET_GROUP_ID" => "SOCNET_GROUP_ID", "OWNER_ID" => "OWNER_ID", "XML_ID" => "XML_ID"), $fields);
foreach ($fields as $key => $val) {
if ($key == $val) {
$res[$arAddParams["sPrefix"] . $key] = $arAddParams["sTablePrefix"] . $val;
} else {
$res[($arAddParams["sPrefix"] == $arAddParams["sTablePrefix"] ? "" : $arAddParams["sPrefix"]) . $key] = $val;
}
}
if ($arAddParams["sReturnResult"] == "string") {
$arRes = array();
foreach ($res as $key => $val) {
$arRes[] = $val . ($key != $val ? " AS " . $key : "");
}
$res = implode(", ", $arRes);
}
return $res;
}