示例#1
0
 /**
  * @param Book $book
  * @return array
  */
 public static function getBookContentArray($book)
 {
     global $config;
     $i = 0;
     $preferedData = array();
     foreach ($config['cops_prefered_format'] as $format) {
         if ($i == 2) {
             break;
         }
         if ($data = $book->getDataFormat($format)) {
             $i++;
             array_push($preferedData, array("url" => $data->getHtmlLink(), "name" => $format));
         }
     }
     $publisher = $book->getPublisher();
     if (is_null($publisher)) {
         $pn = "";
         $pu = "";
     } else {
         $pn = $publisher->name;
         $link = new LinkNavigation($publisher->getUri());
         $pu = $link->hrefXhtml();
     }
     $serie = $book->getSerie();
     if (is_null($serie)) {
         $sn = "";
         $scn = "";
         $su = "";
     } else {
         $sn = $serie->name;
         $scn = str_format(localize("content.series.data"), $book->seriesIndex, $serie->name);
         $link = new LinkNavigation($serie->getUri());
         $su = $link->hrefXhtml();
     }
     $cc = $book->getCustomColumnValues($config['cops_calibre_custom_column_list'], true);
     return array("id" => $book->id, "hasCover" => $book->hasCover, "preferedData" => $preferedData, "rating" => $book->getRating(), "publisherName" => $pn, "publisherurl" => $pu, "pubDate" => $book->getPubDate(), "languagesName" => $book->getLanguages(), "authorsName" => $book->getAuthorsName(), "tagsName" => $book->getTagsName(), "seriesName" => $sn, "seriesIndex" => $book->seriesIndex, "seriesCompleteName" => $scn, "seriesurl" => $su, "customcolumns_list" => $cc);
 }
 /**
  *
  */
 public function testObjectInstances_Fkeys()
 {
     // Establish a relationship between one employee and account
     // and then change the employee_id and ensure that the account
     // is not pulling the old employee.
     $pub1 = new Publisher();
     $pub1->setName('Publisher 1');
     $pub1->save();
     $pub2 = new Publisher();
     $pub2->setName('Publisher 2');
     $pub2->save();
     $book = new Book();
     $book->setTitle("Book Title");
     $book->setISBN("1234");
     $book->setPublisher($pub1);
     $book->save();
     $this->assertSame($pub1, $book->getPublisher());
     // now change values behind the scenes
     $con = Propel::getConnection(BookstoreEmployeeAccountPeer::DATABASE_NAME);
     $con->exec("UPDATE " . BookPeer::TABLE_NAME . " SET " . " publisher_id = " . $pub2->getId() . " WHERE id = " . $book->getId());
     $book2 = BookPeer::retrieveByPK($book->getId());
     $this->assertSame($book, $book2, "Expected same book object instance");
     $this->assertEquals($pub1->getId(), $book->getPublisherId(), "Expected book to have OLD publisher id before reload()");
     $book->reload();
     $this->assertEquals($pub2->getId(), $book->getPublisherId(), "Expected book to have new publisher id");
     $this->assertSame($pub2, $book->getPublisher(), "Expected book to have new publisher object associated.");
     // Now let's set it back, just to be double sure ...
     $con->exec("UPDATE " . BookPeer::TABLE_NAME . " SET " . " publisher_id = " . $pub1->getId() . " WHERE id = " . $book->getId());
     $book->reload();
     $this->assertEquals($pub1->getId(), $book->getPublisherId(), "Expected book to have old publisher id (again).");
     $this->assertSame($pub1, $book->getPublisher(), "Expected book to have old publisher object associated (again).");
 }
示例#3
0
/**
 * Prints the metadata and prices for an item
 * @param Item|Book $item   an Item (Section mode) or Book (ISBN mode) object
 * @param int $requiredStatus
 */
function printItemRow($item, $status = null)
{
    global $app;
    ?>
    <tr>
        <th>
            <span class="tooltip" style="display: none;">
                <img src="<?php 
    echo $item->getImageUrl();
    ?>
">
                <h1><?php 
    echo $item->getTitle();
    ?>
</h1>
                <h2><?php 
    echo $item->getAuthor();
    ?>
</h2>
                <?php 
    if ($edition = $item->getEdition()) {
        ?>
                    <div class="edition"><strong>Edition:</strong> <?php 
        echo $edition;
        ?>
</div>
                <?php 
    }
    if ($publisher = $item->getPublisher()) {
        ?>
                    <div class="publisher"><strong>Publisher:</strong> <?php 
        echo $publisher;
        ?>
</div>
                <?php 
    }
    if ($isbn = $item->getIsbn()) {
        ?>
                    <div class="isbn"><strong>ISBN:</strong> <span class="isbn"><?php 
        echo $isbn;
        ?>
</span></div>
                <?php 
    }
    ?>
            </span>
            <?php 
    $indented = $item->isPackageComponent() || $status === SectionHasItem::BOOKSTORE_RECOMMENDED;
    $class = $indented ? " packageComponent" : "";
    ?>

            <span class="bookdata <?php 
    echo $class;
    ?>
">
                <span class="title"><?php 
    echo $item->getTitle();
    ?>
</span><br>
                <?php 
    if ($edition || $item->getAuthor()) {
        ?>
                <span class="minimetadata"><?php 
        echo ($edition ? "{$edition}, " : "") . $item->getAuthor();
        ?>
</span>
                <?php 
    }
    ?>
                <?php 
    // e.g. (Recommended)
    if ($stat = Item::getStatusText($status)) {
        ?>
                    <br/><span class="minimetadata"><?php 
        echo $stat;
        ?>
</span>
                <?php 
    }
    // sentence about being a package or component
    if ($description = $item->getDescription($status)) {
        ?>
                    <br/><span class="minimetadata important"><?php 
        echo $description;
        ?>
</span>
                <?php 
    }
    ?>
            </span>
        </th>

    <?php 
    foreach ($item->prices as $v => $p) {
        if ($p === null) {
            if ($v === $GLOBALS['results']->bookstore) {
                ?>
                <td data-price="-1" class="empty" data-unknown="true">unknown</td>
            <?php 
            } else {
                ?>
                <td data-price="-1" class="empty">&mdash;</td>
            <?php 
            }
        } else {
            ?>

            <td data-price="<?php 
            echo money($p->total);
            ?>
"
                <?php 
            if ($p->asteriskPrice) {
                ?>
                    data-used="<?php 
                echo money($p->asteriskPrice);
                ?>
"
                <?php 
            }
            ?>
                data-subtotal="<?php 
            echo money($p->subtotal);
            ?>
"
                data-shipping="<?php 
            echo money($p->shipping + $p->tax);
            ?>
">

                <a href="<?php 
            echo $app->urlFor('redirect', array('url' => '', 'type' => 'single', 'vendor' => $p->vendorName)) . $p->url;
            ?>
"
                   data-confirm="<?php 
            echo $p->getDescription();
            ?>
">

                    <?php 
            if ($p->total == 0) {
                ?>
                        unknown
                    <?php 
            } else {
                ?>
                        $<?php 
                echo money($p->total);
                echo $p->asteriskPrice ? '*' : '';
                ?>
                    <?php 
            }
            ?>

                </a>
            </td>
        <?php 
        }
        ?>
    <?php 
    }
    // end: foreach $item->prices
    ?>
    </tr>
    <?php 
    if ($item->getIsPackage()) {
        $components = Item::getComponents(array($item->getId()));
        foreach ($components as $c) {
            printItemRow($c);
        }
    }
}