Skip to content

Commit

Permalink
Merge branch 'release/2.1.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
maso committed Nov 9, 2017
2 parents 9483739 + 0ad327a commit ca9aa8b
Show file tree
Hide file tree
Showing 32 changed files with 2,145 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Eclipse
.project
.settings
/.buildpath

# Composer
/vendor/
composer.lock
composer-setup.php
composer.phar

# Project
storage/tenant

# KDE
.directory
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: php
php:
- '5.6'
- '7.0'
- '7.1'

mysql:
database: test
username: root
encoding: utf8

before_install:
- sudo apt-get update > /dev/null

install:
- composer install

script:
- cd tests
- php run.php
- php coverage-checker.php clover.xml 70

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Book
43 changes: 43 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name" : "pluf/book",
"description" : "Content management system fo pluf",
"type" : "library",
"license" : "MIT",
"authors" : [{
"name" : "Mostafa Barmshory",
"email" : "mostafa.barmshory@dpq.co.ir",
"homepage" : "http://dpq.co.ir",
"role" : "developer"
}, {
"name" : "Mohammad Hadi Mansouri",
"email" : "mohammad.hadi.mansouri@dpq.co.ir",
"homepage" : "http://dpq.co.ir",
"role" : "developer"
}
],
"minimum-stability" : "stable",
"require" : {
"pluf/core" : "^2.0.2"
},
"require-dev" : {
"pluf/test" : "^2.1.0",
"pluf/user" : "^2.1.0"
},
"include-path" : [
"src/"
],
"homepage" : "https://github.com/pluf/book",
"support" : {
"email" : "info@pluf.ir",
"issues" : "https://github.com/pluf/cms/issues",
"forum" : "https://github.com/pluf/cms",
"wiki" : "https://github.com/pluf/cms/wiki",
"source" : "https://github.com/pluf/cms"
},
"keywords" : [
"pluf",
"php",
"pluf-module",
"book"
]
}
111 changes: 111 additions & 0 deletions src/Book/Book.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

/**
* ساختار داده‌ای یک کتاب ویکی را تعیین می‌کند.
*
* @author maso <mostafa.barmshory@dpq.co.ir>
*
*/
class Book_Book extends Pluf_Model
{

/**
* مدل داده‌ای را بارگذاری می‌کند.
*
* @see Pluf_Model::init()
*/
function init ()
{
$this->_a['table'] = 'book';
$this->_a['cols'] = array(
// شناسه‌ها
'id' => array(
'type' => 'Pluf_DB_Field_Sequence',
'blank' => false,
'editable' => false,
'readable' => true
),
// فیلدها
'state' => array(
'type' => 'Pluf_DB_Field_Integer',
'blank' => false,
'unique' => false
),
'title' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => false,
'size' => 250,
'verbose' => __('title'),
'help_text' => __(
'the title of the page must only contain letters, digits or the dash character. For example: My-new-Wiki-Page.')
),
'language' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => false,
'size' => 50,
'verbose' => __('language'),
'help_text' => __(
'the language of the page must only contain letters. for example: en.')
),
'summary' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => false,
'size' => 250,
'verbose' => __('summary'),
'help_text' => __(
'a one line description of the page content.')
),
'creation_dtime' => array(
'type' => 'Pluf_DB_Field_Datetime',
'blank' => true,
'verbose' => __('creation date')
),
'modif_dtime' => array(
'type' => 'Pluf_DB_Field_Datetime',
'blank' => true,
'verbose' => __('modification date')
),
// رابطه‌ها
'interested' => array(
'type' => 'Pluf_DB_Field_Manytomany',
'model' => 'Pluf_User',
'blank' => true,
'relate_name' => 'interested',
'verbose' => __('interested users'),
'help_text' => __(
'interested users will get an email notification when the wiki page is changed.')
),
'submitter' => array(
'type' => 'Pluf_DB_Field_Foreignkey',
'model' => 'Pluf_User',
'blank' => false,
'verbose' => __('submitter'),
'relate_name' => 'submitted_wikipages'
),
);
}

/**
* پیش ذخیره را انجام می‌دهد
*
* @param $create حالت
* ساخت یا به روز رسانی را تعیین می‌کند
*/
function preSave ($create = false)
{
if ($this->id == '') {
$this->creation_dtime = gmdate('Y-m-d H:i:s');
}
$this->modif_dtime = gmdate('Y-m-d H:i:s');
}

/**
* حالت کار ایجاد شده را به روز می‌کند
*
* @see Pluf_Model::postSave()
*/
function postSave ($create = false)
{
//
}
}
26 changes: 26 additions & 0 deletions src/Book/Exception/BookNotFound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* خطای یافت نشدن یک کتاب
*
* @author maso <mostafa.barmshory@dpq.co.ir>
*
*/
class Book_Exception_BookNotFound extends Pluf_Exception
{

/**
* یک نمونه از این کلاس ایجاد می‌کند.
*
* @param string $message
* @param Pluf_Exception $previous
* @param string $link
* @param string $developerMessage
*/
public function __construct ($message = "requested wiki book not found.", $previous = null, $link = null,
$developerMessage = null)
{
parent::__construct($message, 4302, $previous, 404, $link,
$developerMessage);
}
}
26 changes: 26 additions & 0 deletions src/Book/Exception/PageNotFound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* خطای پیدا نشدن یک صفحه از ویکی
*
* @author maso <mostafa.barmshory@dpq.co.ir>
*
*/
class Book_Exception_PageNotFound extends Pluf_Exception
{

/**
* یک نمونه از این کلاس ایجاد می‌کند.
*
* @param string $message
* @param Pluf_Exception $previous
* @param string $link
* @param string $developerMessage
*/
public function __construct ($message = "requested wiki page not found.", $previous = null, $link = null,
$developerMessage = null)
{
parent::__construct($message, 4301, $previous, 404, $link,
$developerMessage);
}
}
63 changes: 63 additions & 0 deletions src/Book/Form/BookCreate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/**
* ایجاد یک صفحه ویکی جدید
*
* با استفاده از این فرم می‌توان یک صفحه جدید ویکی را ایجاد کرد.
*
* @author maso <mostafa.barmshory@dpq.co.ir>
*
*/
class Book_Form_BookCreate extends Pluf_Form
{

public $user = null;

public function initFields ($extra = array())
{
$this->user = $extra['user'];
$initial = __('empty summary');
$initname = (! empty($extra['name'])) ? $extra['name'] : __('PageName');
$this->fields['title'] = new Pluf_Form_Field_Varchar(
array(
'required' => false,
'label' => __('page title'),
'initial' => $initname,
'widget_attrs' => array(
'maxlength' => 200,
'size' => 67
),
'help_text' => __(
'the page name must contains only letters, digits and the dash (-) character')
));
$this->fields['summary'] = new Pluf_Form_Field_Varchar(
array(
'required' => false,
'label' => __('description'),
'initial' => $initial,
'help_text' => __(
'this one line description is displayed in the list of pages'),
'initial' => '',
'widget_attrs' => array(
'maxlength' => 200,
'size' => 67
)
));
}

function save ($commit = true)
{
if (! $this->isValid()) {
throw new Pluf_Exception(
__('cannot save the book from an invalid form'));
}
// Create the book
$page = new Book_Book();
$page->setFromFormData($this->cleaned_data);
$page->submitter = $this->user;
if ($commit) {
$page->create();
}
return $page;
}
}
62 changes: 62 additions & 0 deletions src/Book/Form/BookUpdate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

/**
* ایجاد یک صفحه ویکی جدید
*
* با استفاده از این فرم می‌توان یک صفحه جدید ویکی را ایجاد کرد.
*
* @author maso <mostafa.barmshory@dpq.co.ir>
*
*/
class Book_Form_BookUpdate extends Pluf_Form
{

public $user = null;

public $book = null;

public function initFields ($extra = array())
{
$this->user = $extra['user'];
$this->book = $extra['book'];
$this->fields['title'] = new Pluf_Form_Field_Varchar(
array(
'required' => false,
'label' => __('page title'),
'initial' => $this->book->title,
'widget_attrs' => array(
'maxlength' => 200,
'size' => 67
),
'help_text' => __(
'the page name must contains only letters, digits and the dash (-) character')
));
$this->fields['summary'] = new Pluf_Form_Field_Varchar(
array(
'required' => false,
'label' => __('description'),
'initial' => $this->book->summary,
'help_text' => __(
'this one line description is displayed in the list of pages'),
'initial' => '',
'widget_attrs' => array(
'maxlength' => 200,
'size' => 67
)
));
}

function update ($commit = true)
{
if (! $this->isValid()) {
throw new Pluf_Exception(
__('cannot save the book from an invalid form'));
}
// Create the book
$this->book->setFromFormData($this->cleaned_data);
if ($commit) {
$this->book->update();
}
return $this->book;
}
}
Loading

0 comments on commit ca9aa8b

Please sign in to comment.