public function __construct($view, $title_page)
 {
     parent::__construct($view);
     $lang = LangLoader::get('common', 'gallery');
     $this->set_title($lang['module_title']);
     $this->add_link(LangLoader::get_message('categories.management', 'categories-common'), GalleryUrlBuilder::manage_categories());
     $this->add_link(LangLoader::get_message('category.add', 'categories-common'), GalleryUrlBuilder::add_category());
     $this->add_link($lang['gallery.management'], GalleryUrlBuilder::manage());
     $this->add_link($lang['gallery.actions.add'], GalleryUrlBuilder::admin_add());
     $this->add_link(LangLoader::get_message('configuration', 'admin-common'), GalleryUrlBuilder::configuration());
     $env = $this->get_graphical_environment();
     $env->set_page_title($title_page, $lang['module_title']);
 }
 public function get_actions_tree_links()
 {
     $lang = LangLoader::get('common', 'gallery');
     $tree = new ModuleTreeLinks();
     $manage_categories_link = new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), GalleryUrlBuilder::manage_categories());
     $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), GalleryUrlBuilder::manage_categories()));
     $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('category.add', 'categories-common'), GalleryUrlBuilder::add_category()));
     $tree->add_link($manage_categories_link);
     $manage_gallery_link = new AdminModuleLink($lang['gallery.manage'], GalleryUrlBuilder::manage());
     $manage_gallery_link->add_sub_link(new AdminModuleLink($lang['gallery.manage'], GalleryUrlBuilder::manage()));
     $manage_gallery_link->add_sub_link(new AdminModuleLink($lang['gallery.actions.add'], GalleryUrlBuilder::admin_add(AppContext::get_request()->get_getstring('id_category', 0))));
     $tree->add_link($manage_gallery_link);
     $tree->add_link(new AdminModuleLink(LangLoader::get_message('configuration', 'admin-common'), GalleryUrlBuilder::configuration()));
     if (!AppContext::get_current_user()->check_level(User::ADMIN_LEVEL)) {
         $tree->add_link(new ModuleLink($lang['gallery.actions.add'], GalleryUrlBuilder::add(AppContext::get_request()->get_getstring('id_category', 0)), GalleryAuthorizationsService::check_authorizations()->write()));
     }
     return $tree;
 }
    function get_feed_data_struct($idcat = 0, $name = '')
    {
        if (GalleryService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) {
            $category = GalleryService::get_categories_manager()->get_categories_cache()->get_category($idcat);
            $config = GalleryConfig::load();
            $site_name = GeneralConfig::load()->get_site_name();
            $site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name;
            $feed_module_name = LangLoader::get_message('module_title', 'common', 'gallery');
            $data = new FeedData();
            $data->set_title($feed_module_name . ' - ' . $site_name);
            $data->set_date(new Date());
            $data->set_link(SyndicationUrlBuilder::rss('gallery', $idcat));
            $data->set_host(HOST);
            $data->set_desc($feed_module_name . ' - ' . $site_name);
            $data->set_lang(LangLoader::get_message('xml_lang', 'main'));
            $data->set_auth_bit(Category::READ_AUTHORIZATIONS);
            $categories = GalleryService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
            $ids_categories = array_keys($categories);
            $results = PersistenceContext::get_querier()->select('SELECT *
				FROM ' . GallerySetup::$gallery_table . '
				WHERE idcat IN :ids_categories
				ORDER BY timestamp DESC
				LIMIT :pics_number_per_page', array('ids_categories' => $ids_categories, 'pics_number_per_page' => $config->get_pics_number_per_page()));
            foreach ($results as $row) {
                $link = TextHelper::htmlentities(GalleryUrlBuilder::get_link_item($row['idcat'], $row['id']));
                $item = new FeedItem();
                $item->set_title($row['name']);
                $item->set_link($link);
                $item->set_guid($link);
                $item->set_date(new Date($row['timestamp'], Timezone::SERVER_TIMEZONE));
                $item->set_image_url(Url::to_rel('/gallery/pics/' . $row['path']));
                $item->set_auth(GalleryService::get_categories_manager()->get_heritated_authorizations($row['idcat'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
                $data->add_item($item);
            }
            $results->dispose();
            return $data;
        }
    }
 protected function get_categories_management_url()
 {
     return GalleryUrlBuilder::manage_categories();
 }
 private function generate_response()
 {
     $response = new SiteDisplayResponse($this->tpl);
     $graphical_environment = $response->get_graphical_environment();
     $graphical_environment->set_page_title($this->get_category()->get_name(), $this->lang['module_title']);
     $graphical_environment->get_seo_meta_data()->set_description($this->get_category()->get_description());
     $graphical_environment->get_seo_meta_data()->set_canonical_url(GalleryUrlBuilder::display_category($this->get_category()->get_id(), $this->get_category()->get_rewrited_name(), AppContext::get_request()->get_getint('page', 1)));
     $breadcrumb = $graphical_environment->get_breadcrumb();
     $breadcrumb->add($this->lang['module_title'], GalleryUrlBuilder::home());
     $categories = array_reverse(GalleryService::get_categories_manager()->get_parents($this->get_category()->get_id(), true));
     foreach ($categories as $id => $category) {
         if ($category->get_id() != Category::ROOT_CATEGORY) {
             $breadcrumb->add($category->get_name(), GalleryUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()));
         }
     }
     return $response;
 }
 protected function get_category_url(Category $category)
 {
     return GalleryUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name());
 }
Example #7
0
        $tpl->assign_block_vars('image_up', array('NAME' => stripslashes($imageup['name']), 'IMG' => '<a href="gallery.php?cat=' . $imageup['idcat'] . '&amp;id=' . $g_idpics . '#pics_max"><img src="pics/' . $imageup['path'] . '" alt="' . $imageup['name'] . '" /></a>', 'L_SUCCESS_UPLOAD' => $LANG['success_upload_img'], 'U_CAT' => '<a href="gallery.php?cat=' . $imageup['idcat'] . '">' . $categories[$imageup['idcat']]->get_name() . '</a>'));
    }
    //Affichage du quota d'image uploadée.
    $category_authorizations = GalleryService::get_categories_manager()->get_heritated_authorizations($id_category, Category::WRITE_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY);
    $quota = isset($category_authorizations['r-1']) ? $category_authorizations['r-1'] != '3' : true;
    if ($quota) {
        switch (AppContext::get_current_user()->get_level()) {
            case 2:
                $l_pics_quota = $LANG['illimited'];
                break;
            case 1:
                $l_pics_quota = $config->get_moderator_max_pics_number();
                break;
            default:
                $l_pics_quota = $config->get_member_max_pics_number();
        }
        $nbr_upload_pics = $Gallery->get_nbr_upload_pics(AppContext::get_current_user()->get_id());
        $tpl->assign_block_vars('image_quota', array('L_IMAGE_QUOTA' => sprintf($LANG['image_quota'], $nbr_upload_pics, $l_pics_quota)));
    }
    $search_category_children_options = new SearchCategoryChildrensOptions();
    $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
    $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS);
    $tpl->put_all(array('CAT_ID' => $id_category, 'GALLERY' => !empty($id_category) ? $categories[$id_category]->get_name() : $LANG['gallery'], 'CATEGORIES_TREE' => GalleryService::get_categories_manager()->get_select_categories_form_field('cat', LangLoader::get_message('form.category', 'common'), $id_category, $search_category_children_options)->display()->render(), 'WIDTH_MAX' => $config->get_max_width(), 'HEIGHT_MAX' => $config->get_max_height(), 'WEIGHT_MAX' => $config->get_max_weight(), 'IMG_FORMAT' => 'JPG, PNG, GIF', 'L_IMG_FORMAT' => $LANG['img_format'], 'L_WIDTH_MAX' => $LANG['width_max'], 'L_HEIGHT_MAX' => $LANG['height_max'], 'L_WEIGHT_MAX' => $LANG['weight_max'], 'L_ADD_IMG' => $LANG['add_pic'], 'L_GALLERY' => $LANG['gallery'], 'L_GALLERY_INDEX' => $LANG['gallery_index'], 'L_CATEGORIES' => $LANG['categories'], 'L_NAME' => $LANG['name'], 'L_UNIT_PX' => LangLoader::get_message('unit.pixels', 'common'), 'L_UNIT_KO' => LangLoader::get_message('unit.kilobytes', 'common'), 'L_UPLOAD' => $LANG['upload_img'], 'U_GALLERY_CAT_LINKS' => $cat_links, 'U_GALLERY_ACTION_ADD' => GalleryUrlBuilder::get_link_cat_add($id_category, null, AppContext::get_session()->get_token()), 'U_INDEX' => url('.php')));
    $tpl->display();
} else {
    $module = AppContext::get_extension_provider_service()->get_provider('gallery');
    if ($module->has_extension_point(HomePageExtensionPoint::EXTENSION_POINT)) {
        echo $module->get_extension_point(HomePageExtensionPoint::EXTENSION_POINT)->get_home_page()->get_view()->display();
    }
}
require_once '../kernel/footer.php';
Example #8
0
         $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 . '%">&nbsp;</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 . '&amp;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 . '&amp;pp=%d'));
     if ($pagination->current_page_is_empty() && $page > 1) {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
     $tpl->put_all(array('C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display()));
     if (!empty($idpics)) {
         $info_pics = PersistenceContext::get_querier()->select_single_row_query("SELECT g.id, g.idcat, g.name, g.user_id, g.views, g.width, g.height, g.weight, g.timestamp, g.aprob, m.display_name, m.level, m.groups\n\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\tWHERE g.idcat = :idcat AND g.id = :id", array('idcat' => $id_category, 'id' => $idpics));
         if (!empty($info_pics['id'])) {
             //Affichage miniatures.
             $id_previous = 0;
 protected function get_delete_category_url(Category $category)
 {
     return GalleryUrlBuilder::delete_category($category->get_id());
 }
Example #10
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 ###################################################*/
if (defined('PHPBOOST') !== true) {
    exit;
}
load_module_lang('gallery');
//Chargement de la langue du module.
//Création de l'arborescence des catégories.
$module_title = LangLoader::get_message('module_title', 'common', 'gallery');
$Bread_crumb->add($module_title, GalleryUrlBuilder::home());
$id_category = AppContext::get_request()->get_getint('cat', 0);
if (!empty($id_category)) {
    try {
        $category = GalleryService::get_categories_manager()->get_categories_cache()->get_category($id_category);
    } catch (CategoryNotFoundException $e) {
        $error_controller = PHPBoostErrors::unexisting_page();
        DispatchManager::redirect($error_controller);
    }
} else {
    $category = GalleryService::get_categories_manager()->get_categories_cache()->get_category(Category::ROOT_CATEGORY);
}
$parent_categories = array_reverse(GalleryService::get_categories_manager()->get_parents($id_category));
foreach ($parent_categories as $cat) {
    if ($cat->get_id() != Category::ROOT_CATEGORY) {
        $Bread_crumb->add($cat->get_name(), url('gallery.php?cat=' . $cat->get_id(), 'gallery-' . $cat->get_id() . '.php'));