-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPosts.php
More file actions
60 lines (52 loc) · 2.58 KB
/
Copy pathPosts.php
File metadata and controls
60 lines (52 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
Модель для БД wp_posts
*/
class Posts extends ActiveRecord
{
/* Соответствующие поля таблицы wp_posts */
public $post_author = 1;
public $post_excerpt = '';
public $post_status = 'publish';
public $comment_status = 'closed';
public $ping_status = 'closed';
public $post_password = '';
public $to_ping = '';
public $pinged = '';
public $post_content_filtered = '';
public $post_parent = 0;
public $guid = '';
public $menu_order = 0;
public $post_type = 'post';
public $post_mime_type = '';
public $comment_count = 0;
/* -------------------------------------- */
public static function tableName(){
return 'book_store_posts';
}
public public function __construct()
{
$model = new Posts();
$model->post_date = date("Y-m-d H:i:s");
$model->post_date_gmt = date("Y-m-d H:i:s",time()-2*60*60);
return $model;
}
public function setData($litresBook)
{
$litresLink = 'http://www.litres.ru/' . ($litresBook->litres_url != '' ? $litresBook->litres_url . '?lfrom=' : 'pages/biblio_book/?art=' . $litresBook->hub_id . '&lfrom=' ) . Const::PARTNER_ID;
$imageName = mb_substr(str_ireplace(array('`','~','!','@','#','№','"',';','$','%','^',':','&','?','*','+','=','\'','|','\\','/',',','.',' '),'-',$litresBook->author_name . '-' . $litresBook->author_sname . '-' . $litresBook->book_title),0,80,'utf-8');
$this->post_name = $this->book_title = $litresBook->author_name . ' ' . $litresBook->author_sname . ' - ' . $litresBook->book_title;
$this->post_content = sprintf(Const::POST_DESCRIPTION,
$imageName,
$this->book_title,
$litresBook->author_name . ' ' . $litresBook->author_sname,
$litresBook->book_title,
$litresBook->genre_names,
$litresBook->annotation !='' ? '<strong>Описание: </strong>' . $litresBook->annotation : '',
$litresLink
);
if (!is_null($litresLink->hub_id)){
$this->post_content .= sprintf(Cont::POST_DOWNLOAD, $litresLink->hub_id);
}
}
}