本文整理汇总了PHP中Url::rel方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::rel方法的具体用法?PHP Url::rel怎么用?PHP Url::rel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Url
的用法示例。
在下文中一共展示了Url::rel方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_url
/**
* @desc Defines the URL to the media file
* @param mixed $url a string url or an Url object
*/
public function set_url($url)
{
if (!$url instanceof Url) {
$url = new Url($url);
}
$this->url = $url->rel();
}
示例2: build_view
private function build_view(HTTPRequestCustom $request)
{
$config = FaqConfig::load();
$authorized_categories = FaqService::get_authorized_categories($this->get_category()->get_id());
$subcategories_page = AppContext::get_request()->get_getint('subcategories_page', 1);
$subcategories_number = count(FaqService::get_categories_manager()->get_categories_cache()->get_childrens($this->get_category()->get_id()));
$pagination = $this->get_subcategories_pagination($subcategories_number, $config->get_categories_number_per_page(), $subcategories_page);
//Children categories
$result = PersistenceContext::get_querier()->select('SELECT @id_cat:= faq_cats.id, faq_cats.*,
(SELECT COUNT(*) FROM ' . FaqSetup::$faq_table . '
WHERE id_category IN (
@id_cat,
(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . FaqSetup::$faq_cats_table . ' WHERE id_parent = @id_cat),
(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . FaqSetup::$faq_cats_table . ' parents
INNER JOIN ' . FaqSetup::$faq_cats_table . ' childs ON parents.id = childs.id_parent
WHERE parents.id_parent = @id_cat)
)
AND approved = 1
) AS questions_number
FROM ' . FaqSetup::$faq_cats_table . ' faq_cats
WHERE id_parent = :id_category
AND id IN :authorized_categories
ORDER BY id_parent, c_order
LIMIT :number_items_per_page OFFSET :display_from', array('id_category' => $this->category->get_id(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
$nbr_cat_displayed = 0;
while ($row = $result->fetch()) {
$category_image = new Url($row['image']);
$this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'C_MORE_THAN_ONE_QUESTION' => $row['questions_number'] > 1, 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'QUESTIONS_NUMBER' => $row['questions_number'], 'U_CATEGORY' => FaqUrlBuilder::display_category($row['id'], $row['rewrited_name'])->rel()));
$nbr_cat_displayed++;
}
$result->dispose();
$nbr_column_cats = $nbr_cat_displayed > $config->get_columns_number_per_line() ? $config->get_columns_number_per_line() : $nbr_cat_displayed;
$nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1;
$cats_columns_width = floor(100 / $nbr_column_cats);
$result = PersistenceContext::get_querier()->select('SELECT *
FROM ' . FaqSetup::$faq_table . ' faq
LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = faq.author_user_id
WHERE approved = 1
AND faq.id_category = :id_category
ORDER BY q_order ASC', array('id_category' => $this->get_category()->get_id()));
$category_description = FormatingHelper::second_parse($this->get_category()->get_description());
$this->tpl->put_all(array('C_CATEGORY' => true, 'C_ROOT_CATEGORY' => $this->get_category()->get_id() == Category::ROOT_CATEGORY, 'C_HIDE_NO_ITEM_MESSAGE' => $this->get_category()->get_id() == Category::ROOT_CATEGORY && ($nbr_cat_displayed != 0 || !empty($category_description)), 'C_CATEGORY_DESCRIPTION' => !empty($category_description), 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_QUESTIONS' => $result->get_rows_count() > 0, 'C_MORE_THAN_ONE_QUESTION' => $result->get_rows_count() > 1, 'C_DISPLAY_TYPE_ANSWERS_HIDDEN' => $config->is_display_type_answers_hidden(), 'C_MODERATION' => FaqAuthorizationsService::check_authorizations($this->get_category()->get_id())->moderation(), 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'CATS_COLUMNS_WIDTH' => $cats_columns_width, 'ID_CAT' => $this->get_category()->get_id(), 'CATEGORY_NAME' => $this->get_category()->get_name(), 'CATEGORY_IMAGE' => $this->get_category()->get_image()->rel(), 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $this->get_category()->get_id() == Category::ROOT_CATEGORY ? FaqUrlBuilder::configuration()->rel() : FaqUrlBuilder::edit_category($this->get_category()->get_id())->rel(), 'QUESTIONS_NUMBER' => $result->get_rows_count()));
while ($row = $result->fetch()) {
$faq_question = new FaqQuestion();
$faq_question->set_properties($row);
$this->tpl->assign_block_vars('questions', $faq_question->get_array_tpl_vars());
}
$result->dispose();
}
示例3: get_menu_content
public function get_menu_content()
{
//Create file template
$tpl = new FileTemplate('web/WebModuleMiniMenu.tpl');
//Assign the lang file to the tpl
$tpl->add_lang(LangLoader::get('common', 'web'));
//Load module cache
$web_cache = WebCache::load();
$partners_weblinks = $web_cache->get_partners_weblinks();
$tpl->put('C_PARTNERS', !empty($partners_weblinks));
foreach ($partners_weblinks as $partner) {
$partner_picture = new Url($partner['partner_picture']);
$picture = $partner_picture->rel();
$tpl->assign_block_vars('partners', array('C_HAS_PARTNER_PICTURE' => !empty($picture), 'NAME' => $partner['name'], 'U_PARTNER_PICTURE' => $picture, 'U_VISIT' => WebUrlBuilder::visit($partner['id'])->rel()));
}
return $tpl->render();
}
示例4: build_view
private function build_view()
{
global $LANG, $Bread_crumb;
load_module_lang('gallery');
$g_idpics = retrieve(GET, 'id', 0);
$g_views = retrieve(GET, 'views', false);
$g_notes = retrieve(GET, 'notes', false);
$g_sort = retrieve(GET, 'sort', '');
$g_sort = !empty($g_sort) ? 'sort=' . $g_sort : '';
//Récupération du mode d'ordonnement.
if (preg_match('`([a-z]+)_([a-z]+)`', $g_sort, $array_match)) {
$g_type = $array_match[1];
$g_mode = $array_match[2];
} else {
list($g_type, $g_mode) = array('date', 'desc');
}
$comments_topic = new GalleryCommentsTopic();
$config = GalleryConfig::load();
$category = $this->get_category();
$categories = GalleryService::get_categories_manager()->get_categories_cache()->get_childrens($category->get_id());
$authorized_categories = GalleryService::get_authorized_categories($category->get_id());
$Gallery = new Gallery();
$nbr_pics = $this->db_querier->count(GallerySetup::$gallery_table, 'WHERE idcat=:idcat AND aprob = 1', array('idcat' => $category->get_id()));
$total_cat = count($categories);
//On crée une pagination si le nombre de catégories est trop important.
$page = AppContext::get_request()->get_getint('p', 1);
$pagination = new ModulePagination($page, $total_cat, $config->get_categories_number_per_page());
$pagination->set_url(new Url('/gallery/gallery.php?p=%d&cat=' . $category->get_id() . '&id=' . $g_idpics . '&' . $g_sort));
if ($pagination->current_page_is_empty() && $page > 1) {
$error_controller = PHPBoostErrors::unexisting_page();
DispatchManager::redirect($error_controller);
}
//Colonnes des catégories.
$nbr_column_cats = $total_cat > $config->get_columns_number() ? $config->get_columns_number() : $total_cat;
$nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1;
$column_width_cats = floor(100 / $nbr_column_cats);
//Colonnes des images.
$nbr_column_pics = $nbr_pics > $config->get_columns_number() ? $config->get_columns_number() : $nbr_pics;
$nbr_column_pics = !empty($nbr_column_pics) ? $nbr_column_pics : 1;
$column_width_pics = floor(100 / $nbr_column_pics);
$is_admin = AppContext::get_current_user()->check_level(User::ADMIN_LEVEL);
$is_modo = GalleryAuthorizationsService::check_authorizations($category->get_id())->moderation();
$module_data_path = $this->tpl->get_pictures_data_path();
$rewrite_title = Url::encode_rewrite($category->get_name());
##### Catégorie disponibles #####
$nbr_cat_displayed = 0;
if ($total_cat > 0 && empty($g_idpics)) {
$this->tpl->put('C_GALLERY_CATS', true);
$j = 0;
$result = $this->db_querier->select('SELECT @id_cat:= gallery_cats.id, gallery_cats.*,
(SELECT COUNT(*) FROM ' . GallerySetup::$gallery_table . '
WHERE idcat IN (
@id_cat,
(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' WHERE id_parent = @id_cat),
(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' parents
INNER JOIN ' . GallerySetup::$gallery_cats_table . ' childs ON parents.id = childs.id_parent
WHERE parents.id_parent = @id_cat)
)
AND aprob = 1
) AS nbr_pics
FROM ' . GallerySetup::$gallery_cats_table . ' gallery_cats
WHERE id_parent = :id_category
AND id IN :authorized_categories
ORDER BY id_parent, c_order
LIMIT :number_items_per_page OFFSET :display_from', array('id_category' => $category->get_id(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
while ($row = $result->fetch()) {
$category_image = new Url($row['image']);
$this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'PICTURES_NUMBER' => sprintf($LANG['nbr_pics_info'], $row['nbr_pics']), 'U_CATEGORY' => GalleryUrlBuilder::get_link_cat($row['id'], $row['name'])));
$nbr_cat_displayed++;
}
$result->dispose();
}
$category_description = FormatingHelper::second_parse($category->get_description());
$this->tpl->put_all(array('C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'C_CATEGORY_DESCRIPTION' => $category_description, 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'ARRAY_JS' => '', 'NBR_PICS' => 0, 'MAX_START' => 0, 'START_THUMB' => 0, 'END_THUMB' => 0, 'COLUMNS_NUMBER' => $nbr_column_pics, 'CATS_COLUMNS_WIDTH' => $column_width_cats, 'COLUMN_WIDTH_PICS' => $column_width_pics, 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? GalleryUrlBuilder::configuration()->rel() : GalleryUrlBuilder::edit_category($category->get_id())->rel(), 'CAT_ID' => $category->get_id(), 'DISPLAY_MODE' => $config->get_pics_enlargement_mode(), 'GALLERY' => $category->get_id() != Category::ROOT_CATEGORY ? $this->lang['module_title'] . ' - ' . $category->get_name() : $this->lang['module_title'], 'HEIGHT_MAX' => $config->get_mini_max_height(), 'WIDTH_MAX' => $column_width_pics, 'MODULE_DATA_PATH' => $module_data_path, 'L_APROB' => $LANG['aprob'], 'L_UNAPROB' => $LANG['unaprob'], 'L_FILE_FORBIDDEN_CHARS' => $LANG['file_forbidden_chars'], 'L_TOTAL_IMG' => $category->get_id() != Category::ROOT_CATEGORY ? sprintf($LANG['total_img_cat'], $nbr_pics) : '', 'L_ADD_IMG' => $LANG['add_pic'], 'L_GALLERY' => $this->lang['module_title'], 'L_CATEGORIES' => $category->get_id_parent() >= 0 ? $LANG['sub_album'] : $LANG['album'], 'L_NAME' => $LANG['name'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_MOVETO' => $LANG['moveto'], 'L_DELETE' => LangLoader::get_message('delete', 'common'), 'L_SUBMIT' => $LANG['submit'], 'L_ALREADY_VOTED' => $LANG['already_vote'], 'L_ORDER_BY' => LangLoader::get_message('sort_by', 'common') . (isset($LANG[$g_type]) ? ' ' . strtolower($LANG[$g_type]) : ''), 'L_DIRECTION' => $LANG['direction'], 'L_DISPLAY' => LangLoader::get_message('display', 'common'), 'U_INDEX' => url('.php'), 'U_BEST_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?views=1&cat=' . $category->get_id(), '-' . $category->get_id() . '.php?views=1'), 'U_BEST_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?notes=1&cat=' . $category->get_id(), '-' . $category->get_id() . '.php?notes=1'), 'U_ASC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&sort=' . $g_type . '_' . 'asc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'asc'), 'U_DESC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&sort=' . $g_type . '_' . 'desc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'desc'), 'U_ORDER_BY_NAME' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=name_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=name_desc'), 'U_ORDER_BY_DATE' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=date_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=date_desc'), 'U_ORDER_BY_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=views_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=views_desc'), 'U_ORDER_BY_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=notes_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=notes_desc'), 'U_ORDER_BY_COM' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=com_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=com_desc'), 'L_BEST_VIEWS' => $LANG['best_views'], 'L_BEST_NOTES' => $LANG['best_notes'], 'L_ASC' => $LANG['asc'], 'L_DESC' => $LANG['desc'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_VIEWS' => $LANG['views'], 'L_NOTES' => LangLoader::get_message('notes', 'common'), 'L_COM' => $LANG['com_s']));
##### Affichage des photos #####
if ($nbr_pics > 0) {
switch ($g_type) {
case 'name':
$sort_type = 'g.name';
break;
case 'date':
$sort_type = 'g.timestamp';
break;
case 'views':
$sort_type = 'g.views';
break;
case 'notes':
$sort_type = 'notes.average_notes';
break;
case 'com':
$sort_type = 'com.number_comments';
break;
default:
$sort_type = 'g.timestamp';
}
switch ($g_mode) {
case 'desc':
$sort_mode = 'DESC';
break;
case 'asc':
//.........这里部分代码省略.........
示例5: build_view
private function build_view(HTTPRequestCustom $request)
{
$now = new Date();
$authorized_categories = DownloadService::get_authorized_categories($this->get_category()->get_id());
$mode = $request->get_getstring('sort', DownloadUrlBuilder::DEFAULT_SORT_MODE);
$field = $request->get_getstring('field', DownloadUrlBuilder::DEFAULT_SORT_FIELD);
$page = AppContext::get_request()->get_getint('page', 1);
$subcategories_page = AppContext::get_request()->get_getint('subcategories_page', 1);
$subcategories_number = count(DownloadService::get_categories_manager()->get_categories_cache()->get_childrens($this->get_category()->get_id()));
$subcategories_pagination = $this->get_subcategories_pagination($subcategories_number, $this->config->get_categories_number_per_page(), $field, $mode, $page, $subcategories_page);
//Children categories
$result = PersistenceContext::get_querier()->select('SELECT @id_cat:= download_cats.id, download_cats.*,
(SELECT COUNT(*) FROM ' . DownloadSetup::$download_table . '
WHERE id_category IN (
@id_cat,
(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . DownloadSetup::$download_cats_table . ' WHERE id_parent = @id_cat),
(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . DownloadSetup::$download_cats_table . ' parents
INNER JOIN ' . DownloadSetup::$download_cats_table . ' childs ON parents.id = childs.id_parent
WHERE parents.id_parent = @id_cat)
)
AND (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0)))
) AS downloadfiles_number
FROM ' . DownloadSetup::$download_cats_table . ' download_cats
WHERE id_parent = :id_category
AND id IN :authorized_categories
ORDER BY id_parent, c_order
LIMIT :number_items_per_page OFFSET :display_from', array('timestamp_now' => $now->get_timestamp(), 'id_category' => $this->category->get_id(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $subcategories_pagination->get_number_items_per_page(), 'display_from' => $subcategories_pagination->get_display_from()));
$nbr_cat_displayed = 0;
while ($row = $result->fetch()) {
$category_image = new Url($row['image']);
$this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'C_MORE_THAN_ONE_DOWNLOADFILE' => $row['downloadfiles_number'] > 1, 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'DOWNLOADFILES_NUMBER' => $row['downloadfiles_number'], 'U_CATEGORY' => DownloadUrlBuilder::display_category($row['id'], $row['rewrited_name'])->rel()));
$nbr_cat_displayed++;
}
$result->dispose();
$nbr_column_cats = $nbr_cat_displayed > $this->config->get_columns_number_per_line() ? $this->config->get_columns_number_per_line() : $nbr_cat_displayed;
$nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1;
$cats_columns_width = floor(100 / $nbr_column_cats);
$condition = 'WHERE id_category = :id_category
AND (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0)))';
$parameters = array('id_category' => $this->get_category()->get_id(), 'timestamp_now' => $now->get_timestamp());
$pagination = $this->get_pagination($condition, $parameters, $field, $mode, $page, $subcategories_page);
$sort_mode = $mode == 'asc' ? 'ASC' : 'DESC';
switch ($field) {
case 'name':
$sort_field = DownloadFile::SORT_ALPHABETIC;
break;
case 'download':
$sort_field = DownloadFile::SORT_NUMBER_DOWNLOADS;
break;
case 'com':
$sort_field = DownloadFile::SORT_NUMBER_COMMENTS;
break;
case 'note':
$sort_field = DownloadFile::SORT_NOTATION;
break;
case 'author':
$sort_field = DownloadFile::SORT_AUTHOR;
break;
case 'date':
$sort_field = DownloadFile::SORT_DATE;
break;
default:
$sort_field = DownloadFile::SORT_UPDATED_DATE;
break;
}
$result = PersistenceContext::get_querier()->select('SELECT download.*, member.*, com.number_comments, notes.average_notes, notes.number_notes, note.note
FROM ' . DownloadSetup::$download_table . ' download
LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = download.author_user_id
LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = download.id AND com.module_id = \'download\'
LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = download.id AND notes.module_name = \'download\'
LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = download.id AND note.module_name = \'download\' AND note.user_id = :user_id
' . $condition . '
ORDER BY ' . $sort_field . ' ' . $sort_mode . '
LIMIT :number_items_per_page OFFSET :display_from', array_merge($parameters, array('user_id' => AppContext::get_current_user()->get_id(), 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())));
$category_description = FormatingHelper::second_parse($this->get_category()->get_description());
$this->tpl->put_all(array('C_FILES' => $result->get_rows_count() > 0, 'C_MORE_THAN_ONE_FILE' => $result->get_rows_count() > 1, 'C_CATEGORY_DISPLAYED_SUMMARY' => $this->config->is_category_displayed_summary(), 'C_CATEGORY_DISPLAYED_TABLE' => $this->config->is_category_displayed_table(), 'C_CATEGORY_DESCRIPTION' => !empty($category_description), 'C_AUTHOR_DISPLAYED' => $this->config->is_author_displayed(), 'C_COMMENTS_ENABLED' => $this->config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $this->config->is_notation_enabled(), 'C_MODERATION' => DownloadAuthorizationsService::check_authorizations($this->get_category()->get_id())->moderation(), 'C_PAGINATION' => $pagination->has_several_pages(), 'C_CATEGORY' => true, 'C_ROOT_CATEGORY' => $this->get_category()->get_id() == Category::ROOT_CATEGORY, 'C_HIDE_NO_ITEM_MESSAGE' => $this->get_category()->get_id() == Category::ROOT_CATEGORY && ($nbr_cat_displayed != 0 || !empty($category_description)), 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_SUBCATEGORIES_PAGINATION' => $subcategories_pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $subcategories_pagination->display(), 'CATS_COLUMNS_WIDTH' => $cats_columns_width, 'PAGINATION' => $pagination->display(), 'TABLE_COLSPAN' => 4 + (int) $this->config->are_comments_enabled() + (int) $this->config->is_notation_enabled(), 'ID_CAT' => $this->get_category()->get_id(), 'CATEGORY_NAME' => $this->get_category()->get_name(), 'CATEGORY_IMAGE' => $this->get_category()->get_image()->rel(), 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $this->get_category()->get_id() == Category::ROOT_CATEGORY ? DownloadUrlBuilder::configuration()->rel() : DownloadUrlBuilder::edit_category($this->get_category()->get_id())->rel()));
while ($row = $result->fetch()) {
$downloadfile = new DownloadFile();
$downloadfile->set_properties($row);
$keywords = $downloadfile->get_keywords();
$has_keywords = count($keywords) > 0;
$this->tpl->assign_block_vars('downloadfiles', array_merge($downloadfile->get_array_tpl_vars(), array('C_KEYWORDS' => $has_keywords)));
if ($has_keywords) {
$this->build_keywords_view($keywords);
}
}
$result->dispose();
$this->build_sorting_form($field, $mode);
}
示例6: build_view
private function build_view()
{
global $LANG, $MEDIA_LANG;
require_once PATH_TO_ROOT . '/media/media_constant.php';
load_module_lang('media');
$config = MediaConfig::load();
$category = $this->get_category();
$authorized_categories = MediaService::get_authorized_categories($category->get_id());
//Contenu de la catégorie
$page = AppContext::get_request()->get_getint('p', 1);
$subcategories_page = AppContext::get_request()->get_getint('subcategories_page', 1);
$get_sort = retrieve(GET, 'sort', '');
$get_mode = retrieve(GET, 'mode', '');
$mode = $get_mode == 'asc' ? 'ASC' : 'DESC';
$unget = !empty($get_sort) && !empty($mode) ? '?sort=' . $get_sort . '&mode=' . $get_mode : '';
//On crée une pagination si le nombre de sous-catégories est trop important.
$subcategories_number = count(MediaService::get_categories_manager()->get_categories_cache()->get_childrens($category->get_id()));
$pagination = new ModulePagination($subcategories_page, $subcategories_number, $config->get_categories_number_per_page());
$pagination->set_url(new Url('/media/media.php' . (!empty($unget) ? $unget . '&' : '?') . 'cat=' . $category->get_id() . '&p=' . $page . '&subcategories_page=%d'));
if ($pagination->current_page_is_empty() && $subcategories_page > 1) {
$error_controller = PHPBoostErrors::unexisting_page();
DispatchManager::redirect($error_controller);
}
//Children categories
$result = PersistenceContext::get_querier()->select('SELECT @id_cat:= media_cats.id, media_cats.*,
(SELECT COUNT(*) FROM ' . MediaSetup::$media_table . '
WHERE idcat IN (
@id_cat,
(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . MediaSetup::$media_cats_table . ' WHERE id_parent = @id_cat),
(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . MediaSetup::$media_cats_table . ' parents
INNER JOIN ' . MediaSetup::$media_cats_table . ' childs ON parents.id = childs.id_parent
WHERE parents.id_parent = @id_cat)
)
AND infos = :status
) AS mediafiles_number
FROM ' . MediaSetup::$media_cats_table . ' media_cats
WHERE id_parent = :id_category
AND id IN :authorized_categories
ORDER BY id_parent, c_order
LIMIT :number_items_per_page OFFSET :display_from', array('id_category' => $category->get_id(), 'status' => MEDIA_STATUS_APROBED, 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
$nbr_cat_displayed = 0;
while ($row = $result->fetch()) {
$category_image = new Url($row['image']);
$this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'MEDIAFILES_NUMBER' => sprintf($row['mediafiles_number'] > 1 ? $MEDIA_LANG['num_medias'] : $MEDIA_LANG['num_media'], $row['mediafiles_number']), 'U_CATEGORY' => MediaUrlBuilder::display_category($row['id'], $row['rewrited_name'])->rel()));
$nbr_cat_displayed++;
}
$result->dispose();
$nbr_column_cats = $nbr_cat_displayed > $config->get_columns_number_per_line() ? $config->get_columns_number_per_line() : $nbr_cat_displayed;
$nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1;
$cats_columns_width = floor(100 / $nbr_column_cats);
$category_description = FormatingHelper::second_parse($category->get_description());
$this->tpl->put_all(array('C_CATEGORIES' => true, 'C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'C_CATEGORY_DESCRIPTION' => $category_description, 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_MODO' => MediaAuthorizationsService::check_authorizations($category->get_id())->moderation(), 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'L_UNAPROBED' => $MEDIA_LANG['unaprobed_media_short'], 'L_BY' => $MEDIA_LANG['media_added_by'], 'CATS_COLUMNS_WIDTH' => $cats_columns_width, 'CATEGORY_NAME' => $category->get_id() == Category::ROOT_CATEGORY ? LangLoader::get_message('module_title', 'common', 'media') : $category->get_name(), 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? MediaUrlBuilder::configuration()->rel() : MediaUrlBuilder::edit_category($category->get_id())->rel(), 'ID_CAT' => $category->get_id()));
$selected_fields = array('alpha' => '', 'date' => '', 'nbr' => '', 'note' => '', 'com' => '', 'asc' => '', 'desc' => '');
switch ($get_sort) {
case 'alpha':
$sort = 'name';
$selected_fields['alpha'] = ' selected="selected"';
break;
default:
case 'date':
$sort = 'timestamp';
$selected_fields['date'] = ' selected="selected"';
break;
case 'nbr':
$sort = 'counter';
$selected_fields['nbr'] = ' selected="selected"';
break;
case 'note':
$sort = 'average_notes';
$selected_fields['note'] = ' selected="selected"';
break;
case 'com':
$sort = 'com.number_comments';
$selected_fields['com'] = ' selected="selected"';
break;
}
if ($mode == 'ASC') {
$selected_fields['asc'] = ' selected="selected"';
} else {
$selected_fields['desc'] = ' selected="selected"';
}
$this->tpl->put_all(array('C_DISPLAY_NOTATION' => $config->is_notation_enabled(), 'C_DISPLAY_COMMENTS' => $config->are_comments_enabled(), 'L_ALPHA' => $MEDIA_LANG['sort_title'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_NBR' => $MEDIA_LANG['sort_popularity'], 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_COM' => $LANG['com'], 'L_DESC' => $LANG['desc'], 'L_ASC' => $LANG['asc'], 'L_ORDER_BY' => LangLoader::get_message('sort_by', 'common'), 'SELECTED_ALPHA' => $selected_fields['alpha'], 'SELECTED_DATE' => $selected_fields['date'], 'SELECTED_NBR' => $selected_fields['nbr'], 'SELECTED_NOTE' => $selected_fields['note'], 'SELECTED_COM' => $selected_fields['com'], 'SELECTED_ASC' => $selected_fields['asc'], 'SELECTED_DESC' => $selected_fields['desc']));
$condition = 'WHERE idcat = :idcat AND infos = :status';
$parameters = array('idcat' => $category->get_id(), 'status' => MEDIA_STATUS_APROBED);
//On crée une pagination si le nombre de fichiers est trop important.
$mediafiles_number = MediaService::count($condition, $parameters);
$pagination = new ModulePagination($page, $mediafiles_number, $config->get_items_number_per_page());
$pagination->set_url(new Url('/media/media.php' . (!empty($unget) ? $unget . '&' : '?') . 'cat=' . $category->get_id() . '&p=%d&subcategories_page=' . $subcategories_page));
if ($pagination->current_page_is_empty() && $page > 1) {
$error_controller = PHPBoostErrors::unexisting_page();
DispatchManager::redirect($error_controller);
}
$notation = new Notation();
$notation->set_module_name('media');
$notation->set_notation_scale($config->get_notation_scale());
$result = PersistenceContext::get_querier()->select("SELECT v.id, v.iduser, v.name, v.timestamp, v.counter, v.infos, v.contents, mb.display_name, mb.groups, mb.level, notes.average_notes, com.number_comments\n\t\t\tFROM " . PREFIX . "media AS v\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " AS mb ON v.iduser = mb.user_id\n\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON v.id = notes.id_in_module AND notes.module_name = 'media'\n\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON v.id = com.id_in_module AND com.module_id = 'media'\n\t\t\t" . $condition . "\n\t\t\tORDER BY " . $sort . " " . $mode . "\n\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array_merge($parameters, array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())));
$this->tpl->put_all(array('C_FILES' => $result->get_rows_count() > 0, 'C_DISPLAY_NO_FILE_MSG' => $result->get_rows_count() == 0 && $category->get_id() != Category::ROOT_CATEGORY, 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'TARGET_ON_CHANGE_ORDER' => ServerEnvironmentConfig::load()->is_url_rewriting_enabled() ? 'media-0-' . $category->get_id() . '.php?' : 'media.php?cat=' . $category->get_id() . '&'));
while ($row = $result->fetch()) {
$notation->set_id_in_module($row['id']);
$group_color = User::get_group_color($row['groups'], $row['level']);
//.........这里部分代码省略.........
示例7: to_rel
/**
* @desc Returns an url relative from the server root
* @param mixed $url the url representation. Could be a string or an Url object
* @return string an url relative from the server root
*/
public static function to_rel($url)
{
if (!$url instanceof Url) {
$url = new Url($url);
}
return $url->rel();
}
示例8: array
AND aprob = 0
) AS nbr_pics_unaprob
FROM ' . GallerySetup::$gallery_cats_table . ' gallery_cats
WHERE id_parent = :id_category
AND id IN :authorized_categories
ORDER BY id_parent, c_order
LIMIT :number_items_per_page OFFSET :display_from', array('id_category' => $id_category, 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
while ($row = $result->fetch()) {
//On genère le tableau pour $config->get_columns_number() colonnes
$multiple_x = $i / $nbr_column_cats;
$tr_start = is_int($multiple_x) ? '<tr>' : '';
$i++;
$multiple_x = $i / $nbr_column_cats;
$tr_end = is_int($multiple_x) ? '</tr>' : '';
$category_image = new Url($row['image']);
$tpl->assign_block_vars('cat.list', array('C_IMG' => !empty($row['image']), 'IDCAT' => $row['id'], 'CAT' => $row['name'], 'IMG' => $category_image->rel(), 'TR_START' => $tr_start, 'TR_END' => $tr_end, 'L_NBR_PICS' => sprintf($LANG['nbr_pics_info_admin'], $row['nbr_pics'], $row['nbr_pics_unaprob'])));
}
$result->dispose();
//Création des cellules du tableau si besoin est.
while (!is_int($i / $nbr_column_cats)) {
$i++;
$tpl->assign_block_vars('cat.end_td', array('TD_END' => '<td style="width:' . $column_width_cats . '%"> </td>', 'TR_END' => is_int($i / $nbr_column_cats) ? '</tr>' : ''));
}
}
##### Affichage des photos #####
$tpl->assign_block_vars('pics', array('C_PICS_MAX' => $nbr_pics == 0 || !empty($idpics), 'EDIT' => !empty($id_category) ? '<a href="' . GalleryUrlBuilder::edit_category($id_category)->rel() . '" title="' . LangLoader::get_message('edit', 'common') . '" class="fa fa-edit"></a>' : '', 'PICS_MAX' => '<img src="show_pics.php?id=' . $idpics . '&cat=' . $id_category . '" alt="' . $category->get_name() . '" />'));
if ($nbr_pics > 0) {
//On crée une pagination si le nombre de photos est trop important.
$page = AppContext::get_request()->get_getint('pp', 1);
$pagination = new ModulePagination($page, $nbr_pics, $config->get_pics_number_per_page());
$pagination->set_url(new Url('/gallery/admin_gallery.php?cat=' . $id_category . '&pp=%d'));
示例9: relative_url
public function relative_url(Url $url)
{
return $url->rel();
}
示例10: build_categories_listing_view
private function build_categories_listing_view(Date $now, $field, $mode, $page, $subcategories_page)
{
$authorized_categories = ArticlesService::get_authorized_categories($this->get_category()->get_id());
$subcategories_number = count(ArticlesService::get_categories_manager()->get_categories_cache()->get_childrens($this->category->get_id()));
$pagination = $this->get_subcategories_pagination($subcategories_number, $this->config->get_number_categories_per_page(), $field, $mode, $page, $subcategories_page);
$result = PersistenceContext::get_querier()->select('SELECT @id_cat:= id, articles_cats.*,
(SELECT COUNT(*) FROM ' . ArticlesSetup::$articles_table . '
WHERE id_category IN (
@id_cat,
(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . ArticlesSetup::$articles_cats_table . ' WHERE id_parent = @id_cat),
(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . ArticlesSetup::$articles_cats_table . ' parents
INNER JOIN ' . ArticlesSetup::$articles_cats_table . ' childs ON parents.id = childs.id_parent
WHERE parents.id_parent = @id_cat)
)
AND (published = 1 OR (published = 2 AND publishing_start_date < :timestamp_now AND (publishing_end_date > :timestamp_now OR publishing_end_date = 0)))
) AS articles_number
FROM ' . ArticlesSetup::$articles_cats_table . ' articles_cats
WHERE id_parent = :id_category AND id IN :authorized_categories
ORDER BY id_parent, c_order
LIMIT :number_items_per_page OFFSET :display_from', array('timestamp_now' => $now->get_timestamp(), 'id_category' => $this->category->get_id(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
$nbr_cat_displayed = 0;
while ($row = $result->fetch()) {
$category_image = new Url($row['image']);
$this->view->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'C_MORE_THAN_ONE_ARTICLE' => $row['articles_number'] > 1, 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'ARTICLES_NUMBER' => $row['articles_number'], 'U_CATEGORY' => ArticlesUrlBuilder::display_category($row['id'], $row['rewrited_name'])->rel()));
if (!empty($row['id'])) {
$nbr_cat_displayed++;
}
}
$result->dispose();
$nbr_column_cats = $nbr_cat_displayed > $this->config->get_number_cols_display_cats() ? $this->config->get_number_cols_display_cats() : $nbr_cat_displayed;
$nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1;
$cats_columns_width = floor(100 / $nbr_column_cats);
$category_description = FormatingHelper::second_parse($this->get_category()->get_description());
$this->view->put_all(array('C_CATEGORY' => true, 'C_ROOT_CATEGORY' => $this->get_category()->get_id() == Category::ROOT_CATEGORY, 'C_HIDE_NO_ITEM_MESSAGE' => $this->get_category()->get_id() == Category::ROOT_CATEGORY && ($nbr_cat_displayed != 0 || !empty($category_description)), 'C_CATEGORY_DESCRIPTION' => !empty($category_description), 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'CATEGORY_NAME' => $this->get_category()->get_name(), 'CATEGORY_IMAGE' => $this->get_category()->get_image()->rel(), 'CATEGORY_DESCRIPTION' => $category_description, 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'CATS_COLUMNS_WIDTH' => $cats_columns_width));
}
示例11: set_url
public function set_url(Url $url)
{
$this->pagination->set_url_sprintf_pattern($url->rel());
}