-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
2,145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Book |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.