Beispiel #1
0
 /**
  * Display a flag
  *
  * @param	array	$data	Link's data from db
  * @return	string			Flag path.
  */
 public function display_flag($data)
 {
     global $phpbb_extension_manager;
     $ext_path = $phpbb_extension_manager->get_extension_path('ernadoo/phpbbdirectory', false);
     $flag_path = $ext_path . 'images/flags/';
     $img_flag = 'no_flag.png';
     if ($this->config['dir_activ_flag'] && !empty($data['link_flag']) && file_exists($flag_path . $data['link_flag'])) {
         $img_flag = $data['link_flag'];
     }
     return $this->dir_helper->get_img_path('flags', $img_flag);
 }
Beispiel #2
0
 /**
  * Display form
  *
  * @param	string $parents_list	Drop-down list
  * @return	null
  */
 private function _display_cat_form($parents_list)
 {
     $dir_cat_desc_data = array('text' => $this->cat_data['cat_desc'], 'allow_bbcode' => true, 'allow_smilies' => true, 'allow_urls' => true);
     // Parse desciption if specified
     if ($this->cat_data['cat_desc']) {
         if (!isset($this->cat_data['cat_desc_uid'])) {
             // Before we are able to display the preview and plane text, we need to parse our $request->variable()'d value...
             $this->cat_data['cat_desc_uid'] = '';
             $this->cat_data['cat_desc_bitfield'] = '';
             $this->cat_data['cat_desc_options'] = 0;
             generate_text_for_storage($this->cat_data['cat_desc'], $this->cat_data['cat_desc_uid'], $this->cat_data['cat_desc_bitfield'], $this->cat_data['cat_desc_options'], $this->request->variable('desc_allow_bbcode', false), $this->request->variable('desc_allow_urls', false), $this->request->variable('desc_allow_smilies', false));
         }
         // decode...
         $dir_cat_desc_data = generate_text_for_edit($this->cat_data['cat_desc'], $this->cat_data['cat_desc_uid'], $this->cat_data['cat_desc_options']);
     }
     $this->template->assign_vars(array('S_EDIT_CAT' => true, 'S_ERROR' => sizeof($this->errors) ? true : false, 'S_CAT_PARENT_ID' => $this->cat_data['parent_id'], 'S_ADD_ACTION' => $this->action == 'add' ? true : false, 'U_BACK' => $this->u_action . '&amp;parent_id=' . $this->parent_id, 'U_EDIT_ACTION' => $this->u_action . "&amp;parent_id={$this->parent_id}&amp;action={$this->action}&amp;c={$this->cat_id}", 'L_TITLE' => $this->user->lang['DIR_' . strtoupper($this->action) . '_CAT'], 'ERROR_MSG' => sizeof($this->errors) ? implode('<br />', $this->errors) : '', 'ICON_IMAGE' => $this->cat_data['cat_icon'] ? $this->dir_helper->get_img_path('icons', $this->cat_data['cat_icon']) : 'images/spacer.gif', 'DIR_ICON_PATH' => $this->dir_helper->get_img_path('icons'), 'DIR_CAT_NAME' => $this->cat_data['cat_name'], 'DIR_CAT_DESC' => $dir_cat_desc_data['text'], 'S_DESC_BBCODE_CHECKED' => $dir_cat_desc_data['allow_bbcode'] ? true : false, 'S_DESC_SMILIES_CHECKED' => $dir_cat_desc_data['allow_smilies'] ? true : false, 'S_DESC_URLS_CHECKED' => $dir_cat_desc_data['allow_urls'] ? true : false, 'S_DISPLAY_SUBCAT_LIST' => $this->cat_data['display_subcat_list'] ? true : false, 'S_PARENT_OPTIONS' => $parents_list, 'S_ICON_OPTIONS' => $this->_get_dir_icon_list($this->dir_helper->get_img_path('icons'), $this->cat_data['cat_icon']), 'S_ALLOW_COMMENTS' => $this->cat_data['cat_allow_comments'] ? true : false, 'S_ALLOW_VOTES' => $this->cat_data['cat_allow_votes'] ? true : false, 'S_MUST_DESCRIBE' => $this->cat_data['cat_must_describe'] ? true : false, 'S_COUNT_ALL' => $this->cat_data['cat_count_all'] ? true : false, 'S_VALIDATE' => $this->cat_data['cat_validate'] ? true : false, 'DIR_CRON_EVERY' => $this->cat_data['cat_cron_freq'], 'DIR_NEXT_CRON_ACTION' => !empty($this->cat_data['cat_cron_next']) ? $this->user->format_date($this->cat_data['cat_cron_next']) : '-', 'DIR_CRON_NB_CHECK' => $this->cat_data['cat_cron_nb_check'], 'S_LINK_BACK' => $this->cat_data['cat_link_back'] ? true : false, 'S_CRON_ENABLE' => $this->cat_data['cat_cron_enable'] ? true : false, 'U_DATE' => $this->helper->route('ernadoo_phpbbdirectory_ajax_controller')));
     return;
 }
 /**
  * Populate form when an error occurred
  *
  * @param	int		$cat_id		The category ID
  * @param	string	$mode		add|edit
  * @param	string	$title		Page title (depends of $mode)
  * @return	null
  */
 private function _populate_form($cat_id, $mode, $title)
 {
     global $phpbb_extension_manager;
     if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm'] && $mode == 'new') {
         $this->s_hidden_fields = array_merge($this->s_hidden_fields, $this->captcha->get_hidden_fields());
         $this->user->add_lang('ucp');
         $this->template->assign_vars(array('CAPTCHA_TEMPLATE' => $this->captcha->get_template()));
     }
     $this->user->add_lang('posting');
     if (!function_exists('display_custom_bbcodes')) {
         include $this->root_path . 'includes/functions_display.' . $this->php_ext;
     }
     display_custom_bbcodes();
     add_form_key('dir_form');
     $ext_path = $phpbb_extension_manager->get_extension_path('ernadoo/phpbbdirectory', false);
     $flag_path = $ext_path . 'images/flags/';
     $s_guest = !$this->user->data['is_registered'] || !empty($this->guest_email);
     $s_rss = $this->config['dir_activ_rss'];
     $s_banner = $this->config['dir_activ_banner'];
     $s_back = $this->categorie->data['cat_link_back'];
     $s_flag = $this->config['dir_activ_flag'];
     $this->template->assign_vars(array('BBCODE_STATUS' => $this->config['allow_bbcode'] ? $this->user->lang('BBCODE_IS_ON', '<a href="' . append_sid($this->root_path . "faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>') : $this->user->lang('BBCODE_IS_OFF', '<a href="' . append_sid($this->root_path . "faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $this->config['allow_bbcode'] ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'], 'SMILIES_STATUS' => $this->config['allow_smilies'] ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $this->config['allow_post_links'] ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'], 'FLASH_STATUS' => $this->config['allow_bbcode'] && $this->config['allow_post_flash'] ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], 'L_TITLE' => $title, 'L_DIR_DESCRIPTION_EXP' => $this->user->lang('DIR_DESCRIPTION_EXP', $this->config['dir_length_describe']), 'L_DIR_SUBMIT_TYPE' => $this->categorie->dir_submit_type($this->categorie->need_approval()), 'L_DIR_SITE_BANN_EXP' => $this->user->lang('DIR_SITE_BANN_EXP', $this->config['dir_banner_width'], $this->config['dir_banner_height']), 'S_GUEST' => $s_guest ? true : false, 'S_RSS' => $s_rss ? true : false, 'S_BANNER' => $s_banner ? true : false, 'S_BACK' => $s_back ? true : false, 'S_FLAG' => $s_flag ? true : false, 'S_BBCODE_ALLOWED' => (bool) $this->config['allow_bbcode'], 'S_BBCODE_IMG' => (bool) $this->config['allow_bbcode'], 'S_BBCODE_FLASH' => $this->config['allow_bbcode'] && $this->config['allow_post_flash'] ? true : false, 'S_BBCODE_QUOTE' => true, 'S_LINKS_ALLOWED' => (bool) $this->config['allow_post_links'], 'DIR_FLAG_PATH' => $flag_path, 'DIR_FLAG_IMAGE' => $this->flag ? $this->dir_helper->get_img_path('flags', $this->flag) : '', 'EDIT_MODE' => $mode == 'edit' ? true : false, 'SITE_NAME' => isset($this->site_name) ? $this->site_name : '', 'SITE_URL' => isset($this->url) ? $this->url : '', 'DESCRIPTION' => isset($this->description) ? $this->description : '', 'GUEST_EMAIL' => isset($this->guest_email) ? $this->guest_email : '', 'RSS' => isset($this->rss) ? $this->rss : '', 'BANNER' => isset($this->banner) ? $this->banner : '', 'BACK' => isset($this->back) ? $this->back : '', 'S_POST_ACTION' => '', 'S_CATLIST' => $this->categorie->make_cat_select($cat_id), 'S_LIST_FLAG' => $this->link->get_dir_flag_list($flag_path, $this->flag), 'S_DESC_STAR' => @$this->categorie->data['cat_must_describe'] ? '*' : '', 'S_ROOT' => $cat_id, 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields)));
 }
 /**
  * Display cat or subcat
  *
  * @return	null
  */
 public function display()
 {
     $cat_rows = $subcats = array();
     $parent_id = $visible_cats = 0;
     $sql_array = array('SELECT' => 'cat_id, left_id, right_id, parent_id, cat_name, cat_desc, display_subcat_list, cat_desc_uid, cat_desc_bitfield, cat_desc_options, cat_links, cat_icon, cat_count_all', 'FROM' => array(DIR_CAT_TABLE => ''));
     if (empty($this->data)) {
         $root_data = array('cat_id' => 0);
         $sql_where = '';
     } else {
         $root_data = $this->data;
         $sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
     }
     $sql = $this->db->sql_build_query('SELECT', array('SELECT' => $sql_array['SELECT'], 'FROM' => $sql_array['FROM'], 'WHERE' => $sql_where, 'ORDER_BY' => 'left_id'));
     $result = $this->db->sql_query($sql);
     $branch_root_id = $root_data['cat_id'];
     while ($row = $this->db->sql_fetchrow($result)) {
         $dir_cat_id = $row['cat_id'];
         if ($row['parent_id'] == $root_data['cat_id'] || $row['parent_id'] == $branch_root_id) {
             // Direct child of current branch
             $parent_id = $dir_cat_id;
             $cat_rows[$dir_cat_id] = $row;
         } else {
             $subcats[$parent_id][$dir_cat_id]['display'] = $row['display_subcat_list'] ? true : false;
             $subcats[$parent_id][$dir_cat_id]['name'] = $row['cat_name'];
             $subcats[$parent_id][$dir_cat_id]['links'] = $row['cat_links'];
             $subcats[$parent_id][$dir_cat_id]['parent_id'] = $row['parent_id'];
         }
     }
     $this->db->sql_freeresult($result);
     foreach ($cat_rows as $row) {
         $visible_cats++;
         $dir_cat_id = $row['cat_id'];
         $subcats_list = array();
         // Generate list of subcats if we need to
         if (isset($subcats[$dir_cat_id])) {
             foreach ($subcats[$dir_cat_id] as $subcat_id => $subcat_row) {
                 $row['cat_links'] = $row['cat_count_all'] ? $row['cat_links'] + $subcat_row['links'] : $row['cat_links'];
                 if ($subcat_row['display'] && $subcat_row['parent_id'] == $dir_cat_id) {
                     $subcats_list[] = array('link' => $this->helper->route('ernadoo_phpbbdirectory_page_controller', array('cat_id' => (int) $subcat_id)), 'name' => $subcat_row['name'], 'links' => $subcat_row['links']);
                 } else {
                     unset($subcats[$dir_cat_id][$subcat_id]);
                 }
             }
         }
         $this->template->assign_block_vars('cat', array('CAT_NAME' => $row['cat_name'], 'CAT_DESC' => generate_text_for_display($row['cat_desc'], $row['cat_desc_uid'], $row['cat_desc_bitfield'], $row['cat_desc_options']), 'CAT_LINKS' => $row['cat_links'], 'CAT_IMG' => $this->dir_helper->get_img_path('icons', $row['cat_icon']), 'U_CAT' => $this->helper->route('ernadoo_phpbbdirectory_page_controller', array('cat_id' => (int) $row['cat_id']))));
         // Assign subcats loop for style authors
         foreach ($subcats_list as $subcat) {
             $this->template->assign_block_vars('cat.subcat', array('U_CAT' => $subcat['link'], 'CAT_NAME' => $subcat['name'], 'CAT_LINKS' => $subcat['links']));
         }
     }
     $this->template->assign_vars(array('S_AUTH_ADD' => $this->auth->acl_get('u_submit_dir'), 'S_AUTH_SEARCH' => $this->auth->acl_get('u_search_dir'), 'S_HAS_SUBCAT' => $visible_cats ? true : false, 'S_ROOT' => empty($this->data), 'U_MAKE_SEARCH' => $this->helper->route('ernadoo_phpbbdirectory_search_controller')));
     // Do the categorie Prune thang - cron type job ...
     if (!$this->config['use_system_cron']) {
         $task = $this->cron->find_task('ernadoo.phpbbdirectory.cron.task.core.prune_categorie');
         $task->set_categorie_data($this->data);
         if ($task->is_ready()) {
             $url = $task->get_url();
             $this->template->assign_var('RUN_CRON_TASK', '<img src="' . $url . '" width="1" height="1" alt="" />');
         }
     }
 }