Exemplo n.º 1
0
     */
    public function setPersonalityTraits($traits)
    {
        $this->personalityTraits = $traits;
    }
    /**
     * @return array The photos attached to the listing
     */
    public function getPhotos()
    {
        if (is_null($this->photos)) {
            $this->photos = Photo::$objects->filter(array('petListingId' => $this->id), 100, 1);
        }
        return $this->photos;
    }
    /**
     * @return string The URL to the thumbnail image for the the listing
     */
    public function getThumbnailURL()
    {
        $photos = $this->getPhotos();
        if (empty($photos)) {
            return "img/default-photo-{$this->species}-small.png";
        } else {
            return $photos[0]->getSmallURL();
        }
    }
    public static $objects;
}
PetListing::$objects = new Manager('PetListing');
Exemplo n.º 2
0
require_once __DIR__ . "/../models/Photo.php";
/*
 * This script saves the posted PetListing data to the PetListing Model.
 */
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
    echo "This page must be requested using POST.";
    die;
}
if (!isset($_SESSION['userId'])) {
    echo "You mused be logged in to use this feature.";
    die;
}
if ($_POST['id'] > 0) {
    $listing = PetListing::$objects->get($_POST['id']);
} else {
    $listing = new PetListing();
}
if (formValidation()) {
    $listing->userId = $_SESSION['userId'];
    $listing->name = $_POST['name'];
    $listing->description = $_POST['description'];
    $listing->species = $_POST['species'];
    $listing->sex = $_POST['sex'];
    $listing->zip = $_POST['zip'];
    $listing->age = $_POST['age'];
    $listing->breed = $_POST['breed'];
    $listing->deSexed = $_POST['deSexed'];
    $listing->declawed = $_POST['declawed'];
    $listing->microchipped = $_POST['microchipped'];
    $listing->outdoor = $_POST['outdoor'];
    $listing->hypoallergenic = $_POST['hypoallergenic'];
Exemplo n.º 3
0
    $listURL = 'petlisting-list.php';
} else {
    $listURL = 'petlisting-list.php?filterByApproved=' . $filterByApproved;
}
$petListingId = filter_input(INPUT_GET, 'petListingId', FILTER_VALIDATE_INT, array("options" => array("default" => 0)));
if (isset($_SESSION['listingBeingEdited'])) {
    $listing = $_SESSION['listingBeingEdited'];
    unset($_SESSION['listingBeingEdited']);
} elseif ($petListingId) {
    try {
        $listing = PetListing::$objects->get($petListingId);
    } catch (DoesNotExist $e) {
        $listing = new PetListing();
    }
} else {
    $listing = new PetListing();
}
if ($listing->id) {
    $pageTitle = "Edit Pet Listing";
    $user = $listing->getUser();
} else {
    $pageTitle = "Add Pet Listing";
    $user = new RegisteredUser();
}
if ($listing->approved && $listing->approvedById) {
    $approvedByUser = $listing->getApprovedByUser();
} else {
    $approvedByUser = new RegisteredUser();
}
/**
 * Generate and echo a set of radio buttons with the given name, values, labels,