예제 #1
0
파일: _form.php 프로젝트: elbrusto/YiiShop
<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'book-type-form', 'enableAjaxValidation' => false));
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php 
echo $form->errorSummary($model);
?>

    <div class="row">
        <?php 
echo $form->labelEx($model, 'parent_id');
?>
        <?php 
echo $form->dropDownList($model, 'parent_id', BookType::model()->getAllTypes());
?>
        <?php 
echo $form->error($model, 'parent_id');
?>
    </div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'title');
?>
		<?php 
echo $form->textField($model, 'title', array('size' => 60, 'maxlength' => 255));
?>
		<?php 
echo $form->error($model, 'title');
예제 #2
0
파일: _form.php 프로젝트: elbrusto/YiiShop
echo $form->labelEx($model, 'author');
?>
		<?php 
echo $form->textField($model, 'author', array('size' => 60, 'maxlength' => 255));
?>
		<?php 
echo $form->error($model, 'author');
?>
	</div>

    <div class="row">
        <?php 
echo $form->labelEx($model, 'book_type');
?>
        <?php 
echo $form->dropDownList($model, 'book_type', BookType::model()->getAllTypes());
?>
        <?php 
echo $form->error($model, 'book_type');
?>
    </div>

    <div class="row">
        <?php 
echo $form->labelEx($model, 'release_date');
?>
        <?php 
$this->widget('zii.widgets.jui.CJuiDatePicker', array('name' => 'release_date', 'model' => $model, 'attribute' => 'release_date', 'language' => 'ru', 'options' => array('showAnim' => 'fold'), 'htmlOptions' => array('style' => 'height:20px;')));
?>
        <?php 
echo $form->error($model, 'release_date');
예제 #3
0
    public function _testOneBook()
    {
        $bookXml = <<<XML
<?xml version="1.0"?>
<book itemId="0815">
    <name>Book #1 Name</name>
    <ISBN>123456789</ISBN>
    <price>\$ 1.23</price>
    <authors>
        <authorName>Adam</authorName>
        <authorName>Bob</authorName>
        <authorName>Eve</authorName>
    </authors>
    <description>Book #1 Description</description>
    <promotion>
        <Discount>7%</Discount>
    </promotion>
    <publicationDate>2010-12-29</publicationDate>
    <bookCategory>fiction</bookCategory>
</book>
XML;
        $filepath = dirname(__FILE__) . '/../_files/Books/';
        $binding = new PiBX_Runtime_Binding($filepath . '/binding.xml');
        $unmarshaller = new PiBX_Runtime_Unmarshaller($binding);
        $book = new BookType();
        $book->setName('Book #1 Name');
        $book->setIsbn(123456789);
        $book->setPrice('$ 1.23');
        $book->setAuthorNames(array('Adam', 'Bob', 'Eve'));
        $book->setDescription('Book #1 Description');
        $book->setPromotionDiscount('7%');
        $book->setPublicationdate('2010-12-29');
        $book->setBookcategory('fiction');
        $book->setItemId('0815');
        $object = $unmarshaller->unmarshal($bookXml);
        $this->assertEquals($book, $object);
    }
예제 #4
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = BookType::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
예제 #5
0
파일: admin.php 프로젝트: elbrusto/YiiShop
<?php

$this->breadcrumbs = array('Books' => array('index'), 'Manage');
$this->menu = array(array('label' => 'List Book', 'url' => array('index')), array('label' => 'Create Book', 'url' => array('create')));
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('book-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<h1>Книги</h1>

<?php 
echo CHtml::link('Advanced Search', '#', array('class' => 'search-button'));
?>
<div class="search-form" style="display:none">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'book-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('class' => 'EImageColumn', 'imagePathExpression' => 'Yii::app()->baseUrl."/images/books/".$data->id.$data->image', 'emptyText' => '—', 'imageOptions' => array('height' => 100)), 'title', 'author', array('name' => 'book_type', 'filter' => BookType::model()->getAllTypes(), 'value' => function ($data) {
    return $data->category->title;
}), 'release_date', array('class' => 'CButtonColumn'))));
예제 #6
0
    public function testTwoBooks()
    {
        $expectedXml = <<<XML
<?xml version="1.0"?>
<Collection>
  <books>
    <book itemId="0001">
      <name>Book #1 Name</name>
      <ISBN>123456789</ISBN>
      <price>\$ 1.23</price>
      <authors>
        <authorName>Adam</authorName>
        <authorName>Bob</authorName>
        <authorName>Eve</authorName>
      </authors>
      <description>Book #1 Description</description>
      <promotion>
        <Discount>7%</Discount>
      </promotion>
      <publicationDate>2010-12-29</publicationDate>
      <bookCategory>fiction</bookCategory>
    </book>
    <book itemId="0002">
      <name>Book #2 Name</name>
      <ISBN>987654321</ISBN>
      <price>\$ 4.56</price>
      <authors>
        <authorName>Mark</authorName>
        <authorName>Kate</authorName>
      </authors>
      <description>Book #2 Description</description>
      <promotion>
        <None>Regular price</None>
      </promotion>
      <publicationDate>2010-06-01</publicationDate>
      <bookCategory>novel</bookCategory>
    </book>
  </books>
</Collection>
XML;
        $filepath = dirname(__FILE__) . '/../_files/Books/';
        $binding = new PiBX_Runtime_Binding($filepath . '/binding.xml');
        $marshaller = new PiBX_Runtime_Marshaller($binding);
        $c = new Collection();
        $book1 = new BookType();
        $book1->setName('Book #1 Name');
        $book1->setIsbn(123456789);
        $book1->setPrice('$ 1.23');
        $book1->setAuthorNames(array('Adam', 'Bob', 'Eve'));
        $book1->setDescription('Book #1 Description');
        $book1->setPromotionDiscount('7%');
        $book1->setPublicationdate('2010-12-29');
        $book1->setBookcategory('fiction');
        $book1->setItemId('0001');
        $book2 = new BookType();
        $book2->setName('Book #2 Name');
        $book2->setIsbn(987654321);
        $book2->setPrice('$ 4.56');
        $book2->setAuthorNames(array('Mark', 'Kate'));
        $book2->setDescription('Book #2 Description');
        $book2->setPromotionNone('Regular price');
        $book2->setPublicationdate('2010-06-01');
        $book2->setBookcategory('novel');
        $book2->setItemId('0002');
        $list = array($book1, $book2);
        $c->setBooks($list);
        $xml = $marshaller->marshal($c);
        $this->assertEquals($expectedXml, $xml);
        $dom = new DOMDocument();
        $dom->loadXML($xml);
        $this->assertTrue($dom->schemaValidate($filepath . '/books.xsd'));
    }