/** * Построение таблицы файлов в галерее * @param $array входной массив с данными * @param string $url ссылка на текущую страницу * @param array $urlArr ссылка на текущую страницу, разбитую в массив * @return string возвращает html-код */ function makeGalaryFiles($array, $url, $urlArr) { $i = 0; foreach ($array as $index => $value) { if ($index != "listCount" && $index != "listCurrent") { if ($i == 0) { $tr = "<tr>\n"; } if ($i == 3) { $trE = "</tr> \n"; $i = -1; } $imgPath = $value["small_path"]; $imgLink = $value["id"]; $imgString = "\n <IMG SRC=\"{$imgPath}\" \r\n\t \t\tonMouseOver=\"this.style.borderColor='#45688E'\" onMouseOut=\"this.style.borderColor=''\" style=\"max-width:130px; max-height: 90px;\"> \n"; $linkStr = "<a href=\"/" . $url . $imgLink . "/\"> {$imgString}</a> "; $td = $td . $tr . "<td> {$linkStr} </td> \n {$trE}"; $i++; $tr = ""; $trE = ""; } } if ($tr == "") { $tr = "</tr>"; } $lCount = makeNumerator($array["listCount"], $array["listCurrent"], "l"); $tableStr["text"] = $lCount . "<br /> \n <table border=\"0\" cellspacing=\"0\"> \n {$td} \n {$tr} </table> \n <br />" . $lCount; return $tableStr; }
function showComments4OneGalary($module, $visitor, $userID, $listNum, $altname) { $gal = new Galary(); $comm = new Commentor(); $commArr = $comm->readAllComments($userID); if (count($commArr) == 0) { $r["text"] = "Отсутствуют комментарии!"; return $r; } $galIdsArr = $gal->getGalaryIDs($altname); if (count($galIdsArr) == 0) { $r["text"] = "Отсутствуют изображения!"; return $r; } foreach ($commArr as $index => $value) { //$tempArr[] = $commArr[$index][$value["id"]]; //$tempArr[] = foreach ($galIdsArr as $index2 => $value2) { if ($value["pid"] == $value2["id"]) { $tempArr[] = $value; } } } $sortedArr = listing($tempArr, $listNum, 10); //20 - здесь указывается количество элементов на листе foreach ($sortedArr as $index => $value) { if ($index !== "listCount" && $index !== "listCurrent") { $user = new User($value["poster_user"]); $photo = $user->getPhoto(); $userName = $user->name . " " . $user->secondName; $commDate = $value["comment_time"]; $comment = $value["comment"]; $imgProp = $gal->getImgProperties($value["pid"]); $link = "/" . "galary" . "/" . $imgProp["altname"] . "/" . $imgProp["id"] . "/"; if ($visitor == $userID || $visitor == $value["poster_user"]) { $delUser = $value["poster_user"]; $commID = $value["id"]; $delLink = "<a href=\"{$link}?comm={$commID}\">Удалить</a>"; } else { $delLink = ""; } $previewPath = $gal->getPreviewPathById($value["pid"]); $imgCommented = "<a href=\"{$link}\"> <img src=\"{$previewPath}\" style=\"max-width:90px; max-height: 90px;\"> </a>"; $strTable = $strTable . "<table border=\"1\">\n<tr>\n<td>\n \r\n\t\t\t\t<img src=\"{$photo}\" style=\"max-width:90px; max-height: 90px;\" > \r\n\t\t\t\t\n</td>\n\r\n\t\t\t\t<td> {$userName} {$commDate} {$delLink} <br /> {$comment} </td>\r\n\t\t\t\t<td> {$imgCommented} </td></tr>\n</table>\n"; } } $numerator = makeNumerator($sortedArr["listCount"], $sortedArr["listCurrent"], "g"); $res["text"] = $numerator . $strTable . $numerator; return $res; }