本文整理汇总了PHP中News::get_id方法的典型用法代码示例。如果您正苦于以下问题:PHP News::get_id方法的具体用法?PHP News::get_id怎么用?PHP News::get_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类News
的用法示例。
在下文中一共展示了News::get_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build_table
private function build_table()
{
$table_model = new SQLHTMLTableModel(NewsSetup::$news_table, 'table', array(new HTMLTableColumn(LangLoader::get_message('form.name', 'common'), 'name'), new HTMLTableColumn(LangLoader::get_message('category', 'categories-common'), 'id_category'), new HTMLTableColumn(LangLoader::get_message('author', 'common'), 'display_name'), new HTMLTableColumn(LangLoader::get_message('form.date.creation', 'common'), 'creation_date'), new HTMLTableColumn(LangLoader::get_message('status', 'common'), 'approbation_type'), new HTMLTableColumn('')), new HTMLTableSortingRule('creation_date', HTMLTableSortingRule::DESC));
$table = new HTMLTable($table_model);
$table_model->set_caption($this->lang['news.management']);
$results = array();
$result = $table_model->get_sql_results('news LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = news.author_user_id');
foreach ($result as $row) {
$news = new News();
$news->set_properties($row);
$category = $news->get_category();
$user = $news->get_author_user();
$edit_link = new LinkHTMLElement(NewsUrlBuilder::edit_news($news->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
$delete_link = new LinkHTMLElement(NewsUrlBuilder::delete_news($news->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete');
$user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
$author = $user->get_id() !== User::VISITOR_LEVEL ? new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level())) : $user->get_display_name();
$results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(NewsUrlBuilder::display_news($category->get_id(), $category->get_rewrited_name(), $news->get_id(), $news->get_rewrited_name()), $news->get_name()), 'left'), new HTMLTableRowCell(new LinkHTMLElement(NewsUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()), $category->get_name())), new HTMLTableRowCell($author), new HTMLTableRowCell($news->get_creation_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($news->get_status()), new HTMLTableRowCell($edit_link->display() . $delete_link->display())));
}
$table->set_rows($table_model->get_number_of_matching_rows(), $results);
$this->view->put('table', $table->display());
}
示例2: contribution_actions
private function contribution_actions(News $news, $id_news)
{
if ($news->get_id() === null) {
if ($this->is_contributor_member()) {
$contribution = new Contribution();
$contribution->set_id_in_module($id_news);
$contribution->set_description(stripslashes($this->form->get_value('contribution_description')));
$contribution->set_entitled($news->get_name());
$contribution->set_fixing_url(NewsUrlBuilder::edit_news($id_news)->relative());
$contribution->set_poster_id(AppContext::get_current_user()->get_id());
$contribution->set_module('news');
$contribution->set_auth(Authorizations::capture_and_shift_bit_auth(NewsService::get_categories_manager()->get_heritated_authorizations($news->get_id_cat(), Category::MODERATION_AUTHORIZATIONS, Authorizations::AUTH_CHILD_PRIORITY), Category::MODERATION_AUTHORIZATIONS, Contribution::CONTRIBUTION_AUTH_BIT));
ContributionService::save_contribution($contribution);
}
} else {
$corresponding_contributions = ContributionService::find_by_criteria('news', $id_news);
if (count($corresponding_contributions) > 0) {
$news_contribution = $corresponding_contributions[0];
$news_contribution->set_status(Event::EVENT_STATUS_PROCESSED);
ContributionService::save_contribution($news_contribution);
}
}
$news->set_id($id_news);
}
示例3: update
public static function update(News $news)
{
self::$db_querier->update(NewsSetup::$news_table, $news->get_properties(), 'WHERE id=:id', array('id' => $news->get_id()));
}
示例4: build_suggested_news
private function build_suggested_news(News $news)
{
$now = new Date();
$result = PersistenceContext::get_querier()->select('
SELECT id, name, id_category, rewrited_name,
(2 * FT_SEARCH_RELEVANCE(name, :search_content) + FT_SEARCH_RELEVANCE(contents, :search_content) / 3) AS relevance
FROM ' . NewsSetup::$news_table . '
WHERE (FT_SEARCH(name, :search_content) OR FT_SEARCH(contents, :search_content)) AND id <> :excluded_id
AND (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0)))
ORDER BY relevance DESC LIMIT 0, 10', array('excluded_id' => $news->get_id(), 'search_content' => $news->get_name() . ',' . $news->get_contents(), 'timestamp_now' => $now->get_timestamp()));
$this->tpl->put('C_SUGGESTED_NEWS', $result->get_rows_count() > 0 && NewsConfig::load()->get_news_suggestions_enabled());
while ($row = $result->fetch()) {
$this->tpl->assign_block_vars('suggested', array('NAME' => $row['name'], 'URL' => NewsUrlBuilder::display_news($row['id_category'], NewsService::get_categories_manager()->get_categories_cache()->get_category($row['id_category'])->get_rewrited_name(), $row['id'], $row['rewrited_name'])->rel()));
}
$result->dispose();
}