Ejemplo n.º 1
0
/**
 * Формирование массива доступных комментариев
 * @param $module - имя модуля
 * @param $visitor - id посетителя
 * @param $user - id пользователя
 * @param $listnum - номер страницы
 * @return строка хтмл комментариев.
 */
function showAllComments($module, $visitor, $userID, $listNum)
{
    $comm = new Commentor();
    $gal = new Galary();
    $ret = $comm->readAllComments($userID);
    foreach ($ret as $index => $value) {
        if ($gal->getPrivateState($visitor, $value["pid"])) {
            $tempA = $ret;
        }
    }
    $tempArr = listing($tempA, $listNum, 20);
    //20 - здесь указывается количество элементов на листе
    foreach ($tempArr 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["user"] . "/" . $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($tempArr["listCount"], $tempArr["listCurrent"], "i");
    $res["text"] = $numerator . $strTable . $numerator;
    return $res;
}