Пример #1
0
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}  &nbsp;&nbsp;&nbsp; {$commDate} &nbsp;&nbsp;&nbsp;   {$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;
}