Пример #1
0
function editAlbumForm($altname, $userID, $linkArr, $mode, $postArray, $filesArray, $getsArray)
{
    $g = new Galary();
    $ret2 = "";
    if (count($postArray) != 0 && $mode == 1) {
        $g->updateGalaryProperties($altname, $postArray["name"], $postArray["comment"], $postArray["blackestlist"], $postArray["whitestlist"]);
    }
    if (count($filesArray) != 0 && $mode == 2) {
        $fss = new FS();
        $uploadDir = "/photos/{$userID}/galary";
        $uFile = $fss->upload2($uploadDir, $filesArray);
        $g->addPhoto($userID, $altname, $uploadDir . "/" . $uFile["lastName"]);
        $ret2 = "Фотография добавлена";
    }
    $editGalUrl = $linkArr[0] . $linkArr[1] . "/" . $linkArr[2] . "/" . $linkArr[3] . "/" . $linkArr[4] . "/1/";
    $editGalAddPhoto = $linkArr[0] . $linkArr[1] . "/" . $linkArr[2] . "/" . $linkArr[3] . "/" . $linkArr[4] . "/2/";
    $editGalSort = $linkArr[0] . $linkArr[1] . "/" . $linkArr[2] . "/" . $linkArr[3] . "/" . $linkArr[4] . "/3/";
    $editGalDel = $linkArr[0] . $linkArr[1] . "/" . $linkArr[2] . "/" . $linkArr[3] . "/" . $linkArr[4] . "/4/";
    $albumsURL = $linkArr[0] . $linkArr[1] . "/" . $linkArr[2] . "/";
    $albumsLink = "<a href=\"{$albumsURL}{$altname}/\"> Просмотр альбома</a>";
    $editUrlLink = "<a href=\"{$editGalUrl}\"> Редактировать альбом</a>";
    $addPhotoLink = "<a href=\"{$editGalAddPhoto}\"> Добавить фото</a>";
    $sortlLink = "<a href=\"{$editGalSort}\"> Редактировать фотографии</a>";
    $delLink = "<a href=\"{$editGalDel}\"> Удалить альбом</a>";
    $linkBlock = "<div>{$albumsLink}</div>\r\n    \t<div>{$editUrlLink}</div>\r\n    \t<div>{$addPhotoLink}</div>\r\n    \t<div>{$sortlLink}</div>\r\n    \t<div>{$delLink}</div>";
    $formDel = "{$linkBlock}";
    $tempArr = $g->getGalaryPropertise($altname);
    $galName = $tempArr["name"];
    $galComm = $tempArr["comment"];
    $galBlacketstList = $tempArr["sequrity"] != "" ? $tempArr["sequrity"] : "";
    //если чо потом вставить чо-нить
    $galWhitestList = $tempArr["trusted"] != "" ? $tempArr["trusted"] : "";
    $formEdit = "{$linkBlock}\r\n    \t<br />\r\n <form action=\"{$editGalUrl}\" method=\"post\">\r\nназвание <input name=\"name\" value=\"{$galName}\"><br />\r\nкомментарий <textarea cols=\"23\" rows=\"5\" name=\"comment\">{$galComm}</textarea><br />\r\nЧерный список: <input name=\"blackestlist\" value=\"{$galBlacketstList}\"><br />\r\nБелый список: <input name=\"whitestlist\" value=\"{$galWhitestList}\"><br />\r\n<input value=\"Сохранить\" type=\"submit\"><br />\r\n</form>";
    $formAdd = "{$linkBlock} \r\n    \t<br />\r\n    \t<form action=\"{$editGalAddPhoto}\" method=\"post\" enctype=\"multipart/form-data\">\r\n<input type=\"file\" name=\"uploadFile\">\r\n<input type=\"submit\" value=\"Send\">\r\n</form>";
    $temp1 = $g->showGalary($userID, $altname, "all", $userID);
    //var_dump($temp1);
    foreach ($temp1 as $index => $value) {
        if ($index != "listCount" && $index != "listCurrent") {
            $small_path = $value["small_path"];
            $comment = $value["comment"];
            $photoId = $value["id"];
            $link2element = $linkArr[0] . $linkArr[1] . "/" . $linkArr[2] . "/{$altname}/{$photoId}/";
            $properties = "<input type=\"checkbox\" name = \"cover\" value=\"set\">Обложка альбома";
            $table = $table . "<table border=\"1\"> <tr> <td><a href=\"{$link2element}\"> \r\n    \t\t\t<img src=\"{$small_path}\"  style=\"max-width:130px; max-height: 90px;\"> </a></td> \r\n\t    \t\t<td><textarea cols=\"40\" rows=\"5\" name=\"comment\">{$comment}</textarea></td> \r\n\t    \t\t<td> {$properties} </td> </tr> </table>";
        }
    }
    $formSort = "{$linkBlock}\r\n    \t<br />{$table}";
    switch ($mode) {
        case 1:
            $ret = $formEdit;
            break;
        case 2:
            $ret = $formAdd;
            $ret2 != "" ? $ret = $ret . $ret2 : ($ret = $ret);
            break;
        case 3:
            $ret = $formSort;
            break;
        case 4:
            //$ret = $formDel;
            $ret = $g->deleteGalary($altname, $userID);
            $ret ? $ret = header("Location: {$albumsURL}") : ($ret = "Ошибочка вышла :( <br /> <a href=\"{$albumsURL}\"> Назад</a>");
            break;
        default:
            break;
    }
    return $ret;
}
Пример #2
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 . "&nbsp;" . $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;
}