コード例 #1
0
/**
* Some bbcodes have help wizards :)
*
* @return bbcode tag with link
* @version 3.0.8
*/
function abbcode_wizards($abbcode_bbcode, $form_name, $text_name, $in_admin)
{
    global $template, $user, $config, $abbcode, $phpbb_admin_path, $phpbb_root_path, $phpEx;
    if (!class_exists('abbcode')) {
        include $phpbb_root_path . 'includes/abbcode.' . $phpEx;
    }
    // $phpbb_admin_path need to be defined previously initialize abbcode
    if ($in_admin) {
        $phpbb_admin_path = "{$phpbb_root_path}adm/";
        $template->set_custom_template($phpbb_admin_path . 'style', 'admin');
    }
    $abbcode->abbcode_init();
    $user->add_lang(array('posting', 'mods/abbcode'));
    // The Gradient BBCode must use a wizard, so lets force it to use one if they are disabled ;)
    if ($abbcode_bbcode == 'abbc3_grad' && $abbcode->abbcode_config['ABBC3_WIZARD_MODE'] == 0) {
        $abbcode->abbcode_config['ABBC3_WIZARD_MODE'] = 1;
    }
    if (!$abbcode->abbcode_config['ABBC3_WIZARD_MODE']) {
        trigger_error('ABBC3_FUNCTION_DISABLED');
    }
    $abbcode_name = strtoupper($abbcode_bbcode);
    if ($abbcode_bbcode == 'abbc3_bbvideo') {
        static $abbcode_video_ary = array();
        if (empty($abbcode_video_ary)) {
            $abbcode_video_ary = abbcode::video_init();
            $allowed_videos = explode(';', $config['ABBC3_VIDEO_OPTIONS']);
            foreach ($abbcode_video_ary as $video_name => $video_data) {
                if (!isset($video_data['id'])) {
                    $abbcode_video_ary[$video_name]['display'] = false;
                    continue;
                }
                $abbcode_video_ary[$video_name]['display'] = in_array($video_data['id'], $allowed_videos) ? true : false;
                // Now clear video optgroup
                if ($video_data['id'] >= 1 && $video_data['id'] <= 200 && $abbcode_video_ary[$video_name]['display']) {
                    $abbcode_video_ary['video']['display'] = true;
                } else {
                    if ($video_data['id'] >= 201 && $video_data['id'] <= 300 && $abbcode_video_ary[$video_name]['display']) {
                        $abbcode_video_ary['file']['display'] = true;
                    }
                }
            }
        }
        if (sizeof($abbcode_video_ary)) {
            $video_options = '<option value="-1" class="disabled-options">-- ' . $user->lang['ABBC3_BBVIDEO_SELECT'] . ' --</option>' . "\n";
            $video_optgroup = false;
            $video_selected = false;
            foreach ($abbcode_video_ary as $video_name => $video_data) {
                // First check that this video is enabled
                if (!$video_data['display']) {
                    continue;
                }
                if ($video_name == 'video' || $video_name == 'file') {
                    $video_options .= $video_optgroup ? '</optgroup>' . "\n" : '';
                    $video_options .= '<optgroup label="-- ' . $user->lang['ABBC3_BBVIDEO_' . strtoupper($video_name)] . ' --">' . "\n";
                    $video_optgroup = true;
                } else {
                    if (isset($video_data['match']) && $video_data['match'] != '' && (isset($video_data['replace']) && $video_data['replace'] != '')) {
                        $example = isset($video_data['example']) ? str_replace('&', '&amp;', $video_data['example']) : $user->lang['ABBC3_NO_EXAMPLE'];
                        if ($video_name == 'youtube.com') {
                            $selected = ' selected="selected"';
                            $video_selected = true;
                        } else {
                            $selected = '';
                        }
                        $video_options .= '<option value="' . $example . '"' . $selected . '>' . $video_name . '</option>' . "\n";
                    } else {
                        continue;
                    }
                }
            }
            $video_options .= $video_optgroup ? '</optgroup>' . "\n" : '';
            if (!$video_optgroup) {
                $template->assign_var('L_BBVIDEO_ERROR', sprintf($user->lang['ABBC3_BBVIDEO_SELECT_ERROR'], '<a href="mailto:' . $config['board_contact'] . '">', '</a>'));
            }
            $user->lang['ABBC3_BBVIDEO_EXAMPLE'] = $video_selected ? $user->lang['ABBC3_BBVIDEO_EXAMPLE'] : '&nbsp;';
        }
    }
    if (strpos($abbcode_bbcode, '_')) {
        list($garbage, $tag) = explode('_', $abbcode_bbcode == 'abbc3_ed2k' ? 'abbc3_url' : $abbcode_bbcode);
    } else {
        $tag = $abbcode_bbcode;
    }
    $need_description = array('url', 'email', 'click');
    $need_width_height = array('web', 'flash', 'flv', 'video', 'quicktime', 'ram', 'bbvideo');
    // General setings
    $template->assign_vars(array('S_ABBC3_IN_WIZARD' => true, 'S_ABBC3_WIZARD_MODE' => $abbcode->abbcode_config['ABBC3_WIZARD_MODE'], 'FORM_NAME' => $form_name, 'TEXT_NAME' => $text_name, 'ABBC3_OPEN' => $tag, 'ABBC3_CLOSE' => "/{$tag}", 'ABBC3_TAG' => isset($user->lang[$abbcode_name . '_TAG']) ? $user->lang[$abbcode_name . '_TAG'] : '', 'ABBC3_MOVER' => isset($user->lang[$abbcode_name . '_MOVER']) ? $user->lang[$abbcode_name . '_MOVER'] : '', 'ABBC3_NOTE' => isset($user->lang[$abbcode_name . '_NOTE']) ? $user->lang[$abbcode_name . '_NOTE'] : '', 'ABBC3_EXAMPLE' => isset($user->lang[$abbcode_name . '_EXAMPLE']) ? $user->lang[$abbcode_name . '_EXAMPLE'] : '', 'ABBC3_DESC' => in_array($tag, $need_description) ? true : false, 'ABBC3_W_H' => in_array($tag, $need_width_height) ? true : false, 'ABBC3_WIDTH' => $abbcode_bbcode == 'abbc3_web' ? '100%' : $abbcode->abbcode_config['ABBC3_VIDEO_WIDTH'], 'ABBC3_HEIGHT' => $abbcode_bbcode == 'abbc3_web' ? '400' : $abbcode->abbcode_config['ABBC3_VIDEO_HEIGHT'], 'S_WIZARD_GENERAL' => $abbcode_bbcode == 'abbc3_table' ? false : $abbcode_bbcode == 'abbc3_grad' ? false : true, 'S_WIZARD_TABLE' => $abbcode_bbcode == 'abbc3_table' ? true : false, 'S_WIZARD_GRAD' => $abbcode_bbcode == 'abbc3_grad' ? true : false, 'S_BBVIDEO_OPTIONS' => $abbcode_bbcode == 'abbc3_bbvideo' ? $video_options : '', 'S_ABBC3_ALIGN' => $abbcode_bbcode == 'abbc3_img' || $abbcode_bbcode == 'abbc3_thumbnail' ? radio_select('image_align', $user->lang['ABBC3_ALIGN_SELECTOR'], 'none', 'image_align') : ''));
    // $phpbb_admin_path need to be defined previously initialize abbcode
    if ($in_admin) {
        $phpbb_admin_path = "{$phpbb_root_path}adm/";
        $template->set_custom_template($phpbb_admin_path . 'style', 'admin');
    }
    // Output page ...
    page_header($user->lang[$abbcode_name . '_MOVER']);
    if ($in_admin) {
        $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
    }
    $template->set_filenames(array('body' => 'posting_abbcode_wizards.html'));
    page_footer();
}
コード例 #2
0
/**
* Select list of BBvideos
*/
function video_select($current, $name, $u_action, $ide = 'ABBC3_VIDEO_OPTIONS')
{
    global $user, $config, $phpbb_admin_path, $phpbb_root_path, $phpEx;
    $abbcode_video_ary = abbcode::video_init();
    $allowed_videos = !$current ? array() : explode(';', $current);
    if (sizeof($abbcode_video_ary)) {
        $video_options = '';
        $video_optgroup = false;
        foreach ($abbcode_video_ary as $video_name => $video_data) {
            // Get option group labels
            if ($video_name == 'video' || $video_name == 'file') {
                $video_options .= $video_optgroup ? '</optgroup>' . "\n" : '';
                $video_options .= '<optgroup label="-- ' . $user->lang['ABBC3_BBVIDEO_' . strtoupper($video_name)] . ' --">' . "\n";
                $video_optgroup = true;
            } else {
                if (isset($video_data['match']) && $video_data['match'] != '' && (isset($video_data['replace']) && $video_data['replace'] != '')) {
                    $selected = in_array($video_data['id'], $allowed_videos) ? ' selected="selected"' : '';
                    $video_options .= '<option value="' . $video_data['id'] . '"' . $selected . '>' . $video_name . '</option>' . "\n";
                } else {
                    continue;
                }
            }
        }
        $video_options .= $video_optgroup ? '</optgroup>' . "\n" : '';
    }
    return '<select id="' . $ide . '" name="' . $name . '" multiple="multiple" size="10">' . "\n" . $video_options . '</select>
	<br /><a href="#" onclick="selector(true, \'' . $ide . '\'); return false;">' . $user->lang['ABBCODES_SELECT_ALL'] . '</a> :: <a href="#" onclick="selector(false, \'' . $ide . '\'); return false;">' . $user->lang['ABBCODES_DESELECT_ALL'] . '</a>
	<br /><br />' . $user->lang['ABBCODES_VIDEO_ALLOWED_NOTE'];
}
コード例 #3
0
 /**
  * Parsing the web videos - Second pass.
  * '[BBvideo${1}${2}:$uid]'.trim('${3}').'[/BBvideo:$uid]'
  * @param string		$in		post text between [BBvideo] & [/BBvideo]
  * @param string		$w		value for video width
  * @param string		$h		value for video Height
  * @return embed video
  * @version 3.0.12
  */
 function BBvideo_pass($in, $w, $h)
 {
     global $user, $config;
     if (empty($this->abbcode_config)) {
         $this->abbcode_init(false);
     }
     // fill the bbvideo array (use static so it keeps its value after execution)
     static $abbcode_video_ary = array();
     if (empty($abbcode_video_ary)) {
         $abbcode_video_ary = abbcode::video_init();
     }
     $allowed_videos = explode(';', $config['ABBC3_VIDEO_OPTIONS']);
     $video_unique_id = substr(base_convert(unique_id(), 16, 36), 0, 8);
     $video_width = intval($w) ? $w : $this->abbcode_config['ABBC3_VIDEO_WIDTH'];
     $video_height = intval($h) ? $h : $this->abbcode_config['ABBC3_VIDEO_HEIGHT'];
     $video_image_path = $this->abbcode_config['S_ABBC3_PATH'];
     $in = trim($in);
     $video_link = '';
     $video_content = '';
     foreach ($abbcode_video_ary as $video_name => $video_data) {
         // only process BBvideos that have match, replace and id values
         if (!isset($video_data['match']) || $video_data['match'] == '' || !isset($video_data['replace']) || $video_data['replace'] == '' || !isset($video_data['id']) || $video_data['id'] == '') {
             continue;
         }
         // find a BBvideo match for the video url
         if (preg_match($video_data['match'], $in)) {
             // if this BBvideo is not allowed, return a link
             if (!in_array($video_data['id'], $allowed_videos)) {
                 return make_clickable($in);
             }
             // if user has flash animations disabled in UCP, return as [ flash ] link
             if (!$user->optionget('viewflash')) {
                 return str_replace(array('$1', '$2'), array($in, '[ flash ]'), $this->bbcode_tpl('url', -1, true));
             }
             // Construct XHTML compliant embed code for flash-based embeds
             if (isset($video_data['method']) && $video_data['method'] == 'flash') {
                 $flashvars = isset($video_data['flashvars']) ? $video_data['flashvars'] : '';
                 $params_ary = isset($video_data['params']) ? $video_data['params'] : array();
                 $attribs_ary = isset($video_data['attribs']) ? $video_data['attribs'] : array();
                 $video_data['replace'] = $this->auto_embed_video($video_data['replace'], $video_width, $video_height, $flashvars, $attribs_ary, $params_ary);
             }
             // perform match/replace from input URL to output code
             $video_content = preg_replace($video_data['match'], $video_data['replace'], $in);
             // For oEmbed videos, now is the time to get the embed code
             if (isset($video_data['method']) && $video_data['method'] == 'oEmbed') {
                 $video_content = $this->oembed_url($video_content, $video_width, $video_height);
             }
             // replace variables in the video content string with values
             $video_content = str_replace(array('{WIDTH}', '{HEIGHT}', '{ID}'), array($video_width, $video_height, $video_unique_id), $video_content);
             // create the icon image tag for the BBvideo info bar
             $video_image = $video_image_path . '/images/' . $video_data['image'];
             $video_image = file_exists($video_image) ? '<img src="' . $video_image . '" class="postimage" alt="" width="20" height="20" /> ' : '';
             //create a direct link to the embedded video site or file
             $video_link_string = '%1$s <a href="%2$s" onclick="window.open(this.href);return false;" >%3$s</a>';
             if ($video_data['id'] > 200) {
                 // this is for direct file formats, they have an ID of 200+, get the extension
                 $video_link = sprintf($video_link_string, $user->lang['ABBC3_BBVIDEO_FILE'] . ':', $in, pathinfo(parse_url($in, PHP_URL_PATH), PATHINFO_EXTENSION));
             } else {
                 // this is the link back to the video site
                 $video_link = sprintf($video_link_string, $user->lang['ABBC3_BBVIDEO_WATCH'], $in, $video_name);
             }
             // Dump everything we've done into the BBvideo html template
             $video_content = str_replace(array('{BBVIDEO_WIDTH}', '{BBVIDEO_IMAGE}', '{BBVIDEO_LINK}', '{BBVIDEO_VIDEO}'), array($video_width, $video_image, $video_link, $video_content), $this->bbcode_tpl('bbvideo'));
             return $video_content;
         }
     }
     // if input did not match any BBvideos, return a link
     return make_clickable($in);
 }