Skip to content

Commit

Permalink
добавил счетчик количества просмотров проектов
Browse files Browse the repository at this point in the history
  • Loading branch information
FladeX committed Jan 3, 2012
1 parent 62d0388 commit 88931d8
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 60 deletions.
2 changes: 1 addition & 1 deletion apps/frontend/modules/project/templates/showSuccess.php
Expand Up @@ -35,7 +35,7 @@
</tr>
<tr>
<td>Просмотров:</td>
<td class="value">83 / 15 пользователей</td>
<td class="value"><?php echo ($projects->getViewsGuests() + $projects->getViewsUsers()) ?> / <?php echo $projects->getViewsUsers() ?> пользователей</td>
</tr>
<tr>
<td>Претендентов:</td>
Expand Down
14 changes: 8 additions & 6 deletions config/doctrine/schema.yml
Expand Up @@ -71,13 +71,15 @@ bids:
projects:
actAs: { Timestampable: ~ }
columns:
author_id: { type: integer, notnull: true }
title: { type: string(255), notnull: true }
text: { type: string(4000), notnull: false }
price: { type: integer, notnull: false }
status: { type: integer, notnull: true, default: 0 }
author_id: { type: integer, notnull: true }
title: { type: string(255), notnull: true }
text: { type: string(4000), notnull: false }
price: { type: integer, notnull: false }
views_users: { type: integer, notnull: false }
views_guests: { type: integer, notnull: false }
status: { type: integer, notnull: true, default: 0 }
relations:
users: { onDelete: CASCADE, local: author_id, foreign: id, foreignAlias: users }
users: { onDelete: CASCADE, local: author_id, foreign: id, foreignAlias: users }

users:
actAs: { Timestampable: ~ }
Expand Down
4 changes: 4 additions & 0 deletions data/fixtures/projects.yml
Expand Up @@ -4,9 +4,13 @@ projects:
title: Автофорум
text: Posting for auto-forum. I need topics about sport-cars like Porshe, Ferrari, Lamborgini, etc.
price: 42
views_users: 20
views_guests: 529
status: 1
second_project:
author_id: 1
title: Спамспам Спам
text: This is spam. Don't approve this project
views_users: 3
views_guests: 0
status: 0
2 changes: 1 addition & 1 deletion data/sql/schema.sql
Expand Up @@ -2,7 +2,7 @@ CREATE TABLE badges (id BIGINT AUTO_INCREMENT, user_id BIGINT NOT NULL, badges_i
CREATE TABLE bids (id BIGINT AUTO_INCREMENT, user_id BIGINT NOT NULL, project_id BIGINT NOT NULL, text TEXT, status BIGINT DEFAULT 0 NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX project_id_idx (project_id), INDEX user_id_idx (user_id), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE login_history (id BIGINT AUTO_INCREMENT, user_id BIGINT NOT NULL, user_ip VARCHAR(255) NOT NULL, status BIGINT DEFAULT 0 NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX user_id_idx (user_id), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE payments (id BIGINT AUTO_INCREMENT, sum FLOAT(18, 2) NOT NULL, user_id BIGINT NOT NULL, type VARCHAR(255) NOT NULL, status BIGINT DEFAULT 0 NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX user_id_idx (user_id), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE projects (id BIGINT AUTO_INCREMENT, author_id BIGINT NOT NULL, title VARCHAR(255) NOT NULL, text TEXT, price BIGINT, status BIGINT DEFAULT 0 NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX author_id_idx (author_id), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE projects (id BIGINT AUTO_INCREMENT, author_id BIGINT NOT NULL, title VARCHAR(255) NOT NULL, text TEXT, price BIGINT, views_users BIGINT, views_guests BIGINT, status BIGINT DEFAULT 0 NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX author_id_idx (author_id), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE reports (id BIGINT AUTO_INCREMENT, user_id BIGINT NOT NULL, project_id BIGINT NOT NULL, posting_name VARCHAR(255) NOT NULL, posting_password VARCHAR(255) NOT NULL, posting_messages BIGINT NOT NULL, posting_date DATETIME NOT NULL, status BIGINT DEFAULT 0 NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX project_id_idx (project_id), INDEX user_id_idx (user_id), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE reviews (id BIGINT AUTO_INCREMENT, author_id BIGINT NOT NULL, recepient_id BIGINT NOT NULL, text TEXT NOT NULL, type TINYINT(1) DEFAULT '1' NOT NULL, status BIGINT DEFAULT 0 NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX recepient_id_idx (recepient_id), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE search_history (id BIGINT AUTO_INCREMENT, query VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) ENGINE = INNODB;
Expand Down
50 changes: 28 additions & 22 deletions lib/filter/doctrine/base/BaseprojectsFormFilter.class.php
Expand Up @@ -13,23 +13,27 @@ abstract class BaseprojectsFormFilter extends BaseFormFilterDoctrine
public function setup()
{
$this->setWidgets(array(
'author_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('users'), 'add_empty' => true)),
'title' => new sfWidgetFormFilterInput(array('with_empty' => false)),
'text' => new sfWidgetFormFilterInput(),
'price' => new sfWidgetFormFilterInput(),
'status' => new sfWidgetFormFilterInput(array('with_empty' => false)),
'created_at' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
'updated_at' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
'author_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('users'), 'add_empty' => true)),
'title' => new sfWidgetFormFilterInput(array('with_empty' => false)),
'text' => new sfWidgetFormFilterInput(),
'price' => new sfWidgetFormFilterInput(),
'views_users' => new sfWidgetFormFilterInput(),
'views_guests' => new sfWidgetFormFilterInput(),
'status' => new sfWidgetFormFilterInput(array('with_empty' => false)),
'created_at' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
'updated_at' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
));

$this->setValidators(array(
'author_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('users'), 'column' => 'id')),
'title' => new sfValidatorPass(array('required' => false)),
'text' => new sfValidatorPass(array('required' => false)),
'price' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
'status' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
'created_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
'updated_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
'author_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('users'), 'column' => 'id')),
'title' => new sfValidatorPass(array('required' => false)),
'text' => new sfValidatorPass(array('required' => false)),
'price' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
'views_users' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
'views_guests' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
'status' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
'created_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
'updated_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
));

$this->widgetSchema->setNameFormat('projects_filters[%s]');
Expand All @@ -49,14 +53,16 @@ public function getModelName()
public function getFields()
{
return array(
'id' => 'Number',
'author_id' => 'ForeignKey',
'title' => 'Text',
'text' => 'Text',
'price' => 'Number',
'status' => 'Number',
'created_at' => 'Date',
'updated_at' => 'Date',
'id' => 'Number',
'author_id' => 'ForeignKey',
'title' => 'Text',
'text' => 'Text',
'price' => 'Number',
'views_users' => 'Number',
'views_guests' => 'Number',
'status' => 'Number',
'created_at' => 'Date',
'updated_at' => 'Date',
);
}
}
36 changes: 20 additions & 16 deletions lib/form/doctrine/base/BaseprojectsForm.class.php
Expand Up @@ -15,25 +15,29 @@ abstract class BaseprojectsForm extends BaseFormDoctrine
public function setup()
{
$this->setWidgets(array(
'id' => new sfWidgetFormInputHidden(),
'author_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('users'), 'add_empty' => false)),
'title' => new sfWidgetFormInputText(),
'text' => new sfWidgetFormTextarea(),
'price' => new sfWidgetFormInputText(),
'status' => new sfWidgetFormInputText(),
'created_at' => new sfWidgetFormDateTime(),
'updated_at' => new sfWidgetFormDateTime(),
'id' => new sfWidgetFormInputHidden(),
'author_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('users'), 'add_empty' => false)),
'title' => new sfWidgetFormInputText(),
'text' => new sfWidgetFormTextarea(),
'price' => new sfWidgetFormInputText(),
'views_users' => new sfWidgetFormInputText(),
'views_guests' => new sfWidgetFormInputText(),
'status' => new sfWidgetFormInputText(),
'created_at' => new sfWidgetFormDateTime(),
'updated_at' => new sfWidgetFormDateTime(),
));

$this->setValidators(array(
'id' => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
'author_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('users'))),
'title' => new sfValidatorString(array('max_length' => 255)),
'text' => new sfValidatorString(array('max_length' => 4000, 'required' => false)),
'price' => new sfValidatorInteger(array('required' => false)),
'status' => new sfValidatorInteger(array('required' => false)),
'created_at' => new sfValidatorDateTime(),
'updated_at' => new sfValidatorDateTime(),
'id' => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
'author_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('users'))),
'title' => new sfValidatorString(array('max_length' => 255)),
'text' => new sfValidatorString(array('max_length' => 4000, 'required' => false)),
'price' => new sfValidatorInteger(array('required' => false)),
'views_users' => new sfValidatorInteger(array('required' => false)),
'views_guests' => new sfValidatorInteger(array('required' => false)),
'status' => new sfValidatorInteger(array('required' => false)),
'created_at' => new sfValidatorDateTime(),
'updated_at' => new sfValidatorDateTime(),
));

$this->widgetSchema->setNameFormat('projects[%s]');
Expand Down
42 changes: 28 additions & 14 deletions lib/model/doctrine/base/Baseprojects.class.php
Expand Up @@ -9,24 +9,30 @@
* @property string $title
* @property string $text
* @property integer $price
* @property integer $views_users
* @property integer $views_guests
* @property integer $status
* @property users $users
* @property Doctrine_Collection $projects
*
* @method integer getAuthorId() Returns the current record's "author_id" value
* @method string getTitle() Returns the current record's "title" value
* @method string getText() Returns the current record's "text" value
* @method integer getPrice() Returns the current record's "price" value
* @method integer getStatus() Returns the current record's "status" value
* @method users getUsers() Returns the current record's "users" value
* @method Doctrine_Collection getProjects() Returns the current record's "projects" collection
* @method projects setAuthorId() Sets the current record's "author_id" value
* @method projects setTitle() Sets the current record's "title" value
* @method projects setText() Sets the current record's "text" value
* @method projects setPrice() Sets the current record's "price" value
* @method projects setStatus() Sets the current record's "status" value
* @method projects setUsers() Sets the current record's "users" value
* @method projects setProjects() Sets the current record's "projects" collection
* @method integer getAuthorId() Returns the current record's "author_id" value
* @method string getTitle() Returns the current record's "title" value
* @method string getText() Returns the current record's "text" value
* @method integer getPrice() Returns the current record's "price" value
* @method integer getViewsUsers() Returns the current record's "views_users" value
* @method integer getViewsGuests() Returns the current record's "views_guests" value
* @method integer getStatus() Returns the current record's "status" value
* @method users getUsers() Returns the current record's "users" value
* @method Doctrine_Collection getProjects() Returns the current record's "projects" collection
* @method projects setAuthorId() Sets the current record's "author_id" value
* @method projects setTitle() Sets the current record's "title" value
* @method projects setText() Sets the current record's "text" value
* @method projects setPrice() Sets the current record's "price" value
* @method projects setViewsUsers() Sets the current record's "views_users" value
* @method projects setViewsGuests() Sets the current record's "views_guests" value
* @method projects setStatus() Sets the current record's "status" value
* @method projects setUsers() Sets the current record's "users" value
* @method projects setProjects() Sets the current record's "projects" collection
*
* @package posting
* @subpackage model
Expand Down Expand Up @@ -56,6 +62,14 @@ public function setTableDefinition()
'type' => 'integer',
'notnull' => false,
));
$this->hasColumn('views_users', 'integer', null, array(
'type' => 'integer',
'notnull' => false,
));
$this->hasColumn('views_guests', 'integer', null, array(
'type' => 'integer',
'notnull' => false,
));
$this->hasColumn('status', 'integer', null, array(
'type' => 'integer',
'notnull' => true,
Expand Down

0 comments on commit 88931d8

Please sign in to comment.