本文整理汇总了PHP中Articles::populate方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::populate方法的具体用法?PHP Articles::populate怎么用?PHP Articles::populate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Articles
的用法示例。
在下文中一共展示了Articles::populate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SimplePie
function get_articles()
{
$sm =& $this->_site_manager;
require_once VIVVO_FS_INSTALL_ROOT . '/lib/simplepie/simplepie.php';
$feed_r = new SimplePie();
$feed_r->enable_cache(false);
$feed_r->set_feed_url($this->get_feed());
$feed_r->init();
foreach ($feed_r->get_items() as $item) {
$status = true;
$guid = $item->get_item_tags('', 'guid');
$guid = $guid[0]['data'];
if ($guid != '') {
$sql = 'SELECT count( * ) as count FROM ' . VIVVO_DB_PREFIX . 'Articles WHERE feed_data = \'' . md5($guid) . '\' LIMIT 1';
$feed_data = md5($guid);
} else {
$sql = 'SELECT count( * ) as count FROM ' . VIVVO_DB_PREFIX . 'Articles WHERE feed_data = \'' . md5($item->get_title() . $item->get_permalink()) . '\'LIMIT 1';
$feed_data = md5($item->get_title() . $item->get_permalink());
}
$res =& $sm->_db->query($sql);
$row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
if ($row['count']) {
$status = false;
}
if ($status) {
require_once VIVVO_FS_INSTALL_ROOT . '/lib/vivvo/core/Articles.class.php';
require_once VIVVO_FS_FRAMEWORK . 'vivvo_post.php';
$article = new Articles($sm);
if ($this->get_author() != '') {
$author = $this->get_author();
} elseif ($item->get_author() != '') {
$author = $item->get_author();
} else {
preg_match('/^http:\\/\\/(www\\.)?([^\\/]+)/', $item->get_permalink(), $author);
$author = $author[2];
}
if (VIVVO_PLUGIN_FEED_IMPORTER_FRIENDLY == 1) {
$sefriendly_url = strtolower(preg_replace('/[^a-zA-Z\\d\\-]/i', '_', $item->get_title()));
$keywords = preg_split("/[\\s_]+/", $sefriendly_url, VIVVO_PLUGIN_FEED_IMPORTER_MAX_WORD_NUM + 1, PREG_SPLIT_NO_EMPTY);
$output_string = '';
for ($i = 0; $i < VIVVO_PLUGIN_FEED_IMPORTER_MAX_WORD_NUM; $i++) {
$output_string .= '_' . $keywords[$i];
}
$sefriendly_url = trim($output_string, "_");
//If sefriendly exists
$sql = 'SELECT count( * ) as count FROM ' . VIVVO_DB_PREFIX . 'Articles WHERE sefriendly = \'' . secure_sql($sefriendly_url) . '\' LIMIT 1';
$res =& $sm->_db->query($sql);
$row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
if ($row['count']) {
$sefriendly_url = '';
}
} else {
$sefriendly_url = '';
}
$sql = 'SELECT max( order_num ) as max FROM ' . VIVVO_DB_PREFIX . 'Articles';
$res =& $sm->_db->query($sql);
if ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
$order_num = $row['max'] + 1;
} else {
$order_num = 1;
}
$data = array('category_id' => $this->category_id, 'user_id' => VIVVO_PLUGIN_FEED_IMPORTER_USER_ID, 'author' => $author, 'title' => $item->get_title(), 'created' => $item->get_date('Y-m-d H:i:s'), 'body' => $item->get_description(), 'status' => VIVVO_PLUGIN_FEED_IMPORTER_STATUS, 'sefriendly' => $sefriendly_url, 'link' => $item->get_permalink(), 'order_num' => $order_num, 'feed_data' => $feed_data);
$article->populate($data, true);
$post_master = new vivvo_post_master($sm);
$post_master->set_data_object($article);
if ($post_master->sql_insert()) {
$this->set_count($this->get_count() + 1);
}
}
}
$this->set_favicon($feed_r->get_favicon());
}
示例2: trim
/**
* Add new article
*
* @param array $in_article
* @return boolean true on success or false on fail
*/
function add_article($in_article)
{
if (!$this->check_token()) {
return false;
}
if (!vivvo_hooks_manager::call('article_add', array(&$in_article))) {
return vivvo_hooks_manager::get_status();
}
$sm = vivvo_lite_site::get_instance();
if ($sm->user) {
$editor_restriction = $sm->user->get_privilege_object_ids('EDITOR', 'Categories');
$writer_restriction = $sm->user->get_privilege_object_ids('WRITE', 'Categories');
if (!empty($writer_restriction)) {
$in_article['title'] = trim($in_article['title']);
$article_list = new Articles_list();
$new_order_num = $article_list->get_max('order_num');
if ($new_order_num) {
$in_article['order_num'] = $new_order_num + 1;
} else {
$in_article['order_num'] = 1;
}
if (!strlen(trim($in_article['sefriendly']))) {
$in_article['sefriendly'] = make_sefriendly($in_article['title']);
$source = 'title';
} else {
$in_article['sefriendly'] = make_sefriendly($in_article['sefriendly']);
$source = 'sefriendly';
}
if (!empty($in_article['sefriendly'])) {
$sql = 'SELECT id, sefriendly, status FROM ' . VIVVO_DB_PREFIX . 'articles WHERE `sefriendly` = \'' . secure_sql($in_article['sefriendly']) . '\' GROUP BY `status`; ';
$res = $sm->get_db()->query($sql);
$arrData = array();
if (!PEAR::isError($res)) {
$arrData = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
$res->free();
}
// First check trashed articles, if sefriendly occupied, return error
foreach ($arrData as $key => $value) {
if ($value['status'] == -2) {
$this->set_error_code(2037);
return false;
}
}
// If sefriendly found among Active articles
foreach ($arrData as $key => $value) {
if (is_array($value) && count($value) > 0 && $value['status'] > -2) {
if ($source == 'sefriendly') {
$this->set_error_code(2001);
return false;
} else {
$in_article['sefriendly'] = '';
}
}
}
unset($arrData);
}
if (!$sm->user->can_change_status($in_article['status'])) {
$in_article['status'] = 0;
}
if ($sm->user->is('EDITOR', 'Categories', $in_article['category_id'])) {
if (!isset($in_article['user_id']) or $in_article['user_id'] == '') {
$in_article['user_id'] = $sm->user->get_id();
}
} else {
$in_article['user_id'] = $sm->user->get_id();
$in_article['author'] = $sm->user->get_name();
}
$in_article['user_domain'] = VIVVO_USER_SOURCE;
if (!$sm->user->is_admin()) {
if (!in_array('0', $writer_restriction) && !in_array($in_article['category_id'], $writer_restriction)) {
$this->set_error_code(2036);
return false;
}
}
$body = $in_article['body'];
array_walk($in_article, 'array_htmlspecialchars');
$in_article['body'] = $body;
$in_article['created'] = date('Y-m-d H:i:00', $in_article['created']);
$article = new Articles($sm);
if ($article->populate($in_article, true) === false) {
$this->set_error_info($article->get_error_info());
return false;
}
if ($article->author == '') {
$article->author = $article->get_author_name();
}
$this->_post_master->set_data_object($article);
if ($this->_post_master->sql_insert()) {
$id = $this->_post_master->get_work_id();
$article->set_id($id);
if (!vivvo_hooks_manager::call('article_add_postinsert', array(&$article))) {
return vivvo_hooks_manager::get_status();
}
$um = $sm->get_url_manager();
//.........这里部分代码省略.........