コード例 #1
0
ファイル: rating.php プロジェクト: here-we-go/phpbbgallery
 /**
  * Displays the box where the user can rate the image.
  */
 public function display_box()
 {
     global $template, $user, $config;
     $gallery_config = new \phpbbgallery\core\config($config);
     $template->assign_var('GALLERY_RATING', self::MODE_SELECT);
     //@todo: phpbb_ext_gallery_core_config::get('rating_mode'));
     switch (self::MODE_SELECT) {
         //@todo: self::MODE_THUMB:
         //@todo: self::MODE_STARS:
         case self::MODE_SELECT:
         default:
             // @TODO We do not have contests for now
             /*if ($this->album_data('contest_id'))
             		{
             			if (time() < ($this->album_data('contest_start') + $this->album_data('contest_rating')))
             			{
             				$template->assign_var('GALLERY_NO_RATING_MESSAGE', $user->lang('CONTEST_RATING_STARTS', $user->format_date(($this->album_data('contest_start') + $this->album_data('contest_rating')), false, true)));
             				return;
             			}
             			if (($this->album_data('contest_start') + $this->album_data('contest_end')) < time())
             			{
             				$template->assign_var('GALLERY_NO_RATING_MESSAGE', $user->lang('CONTEST_RATING_ENDED', $user->format_date(($this->album_data('contest_start') + $this->album_data('contest_end')), false, true)));
             				return;
             			}
             		}*/
             for ($i = 1; $i <= $gallery_config->get('max_rating'); $i++) {
                 $template->assign_block_vars('rate_scale', array('RATE_POINT' => $i));
             }
             break;
     }
     $this->rating_enabled = true;
 }
コード例 #2
0
ファイル: album.php プロジェクト: vodis/phpbbgallery
 /**
  * Generate personal album for user, when moving image into it
  */
 public static function generate_personal_album($album_name, $user_id, $user_colour, $gallery_user)
 {
     global $cache, $db, $table_prefix, $config;
     $phpbb_gallery_config = new \phpbbgallery\core\config($config);
     $albums_table = $table_prefix . 'gallery_albums';
     $album_data = array('album_name' => $album_name, 'parent_id' => 0, 'album_desc_options' => 7, 'album_desc' => '', 'album_parents' => '', 'album_type' => self::TYPE_UPLOAD, 'album_status' => self::STATUS_OPEN, 'album_user_id' => $user_id, 'album_last_username' => '', 'album_last_user_colour' => $user_colour);
     $db->sql_query('INSERT INTO ' . $albums_table . ' ' . $db->sql_build_array('INSERT', $album_data));
     $personal_album_id = $db->sql_nextid();
     $gallery_user->update_data(array('personal_album_id' => $personal_album_id));
     $phpbb_gallery_config->inc('num_pegas', 1);
     // Update the config for the statistic on the index
     $phpbb_gallery_config->set('newest_pega_user_id', $user_id);
     $phpbb_gallery_config->set('newest_pega_username', $album_name);
     $phpbb_gallery_config->set('newest_pega_user_colour', $user_colour);
     $phpbb_gallery_config->set('newest_pega_album_id', $personal_album_id);
     $cache->destroy('_albums');
     $cache->destroy('sql', $albums_table);
     return $personal_album_id;
 }
コード例 #3
0
    /**
     * This function is called, when the main() function is called.
     * You can use this function to add your language files, check for a valid mode, unset config options and more.
     *
     * @param	int		$id		The ID of the module
     * @param	string	$mode	The name of the mode we want to display
     * @return	void
     */
    public function main($id, $mode)
    {
        // Check whether the mode is allowed.
        if (!isset($this->display_vars[$mode])) {
            trigger_error('NO_MODE', E_USER_ERROR);
        }
        global $config, $db, $user, $template, $cache, $phpbb_container, $phpbb_root_path, $phpEx, $phpbb_gallery_url;
        global $request, $config;
        $phpbb_gallery_url = $phpbb_container->get('phpbbgallery.core.url');
        $user->add_lang_ext('phpbbgallery/core', array('gallery', 'gallery_acp'));
        $submit = isset($_POST['submit']) ? true : false;
        $form_key = 'acp_time';
        add_form_key($form_key);
        // Create the toolio config object
        //$this->toolio_config = new phpbb_ext_gallery_core_config($config, $db, CONFIG_TABLE);
        switch ($mode) {
            case 'main':
                $vars = $this->get_display_vars('main');
                break;
        }
        // Init gallery block class
        $phpbb_ext_gallery_core_constants = new \phpbbgallery\core\block();
        // Init gallery configs class
        $phpbb_gallery_configs = new \phpbbgallery\core\config($config);
        $this->new_config = $phpbb_gallery_configs->get_all();
        $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc($request->variable('config', array('' => ''), true)) : $this->new_config;
        $error = array();
        // We validate the complete config if whished
        validate_config_vars($vars['vars'], $cfg_array, $error);
        if ($submit && !check_form_key($form_key)) {
            $error[] = $user->lang['FORM_INVALID'];
        }
        // Do not write values if there is an error
        if (sizeof($error)) {
            $submit = false;
        }
        //now we display the variables
        foreach ($vars['vars'] as $config_name => $null) {
            if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
                continue;
            }
            $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
            if ($submit) {
                // Check for RRC-display-options
                if (isset($null['method']) && ($null['method'] == 'rrc_display' || $null['method'] == 'rrc_modes')) {
                    // Changing the value, casted by int to not mess up anything
                    $config_value = (int) array_sum($request->variable($config_name, array(0)));
                }
                // Recalculate the Watermark-position
                if (isset($null['method']) && $null['method'] == 'watermark_position') {
                    // Changing the value, casted by int to not mess up anything
                    $config_value = $request->variable('watermark_position_x', 0) + $request->variable('watermark_position_y', 0);
                }
                if ($config_name == 'link_thumbnail') {
                    $update_bbcode = $request->variable('update_bbcode', '');
                    // Update the BBCode
                    if ($update_bbcode) {
                        if (!class_exists('acp_bbcodes')) {
                            $phpbb_gallery_url->_include('acp/acp_bbcodes', 'phpbb');
                            //include_once($phpbb_root_path . 'includes/acp/acp_bbcodes.' . $phpEx);
                        }
                        $acp_bbcodes = new \acp_bbcodes();
                        $bbcode_match = '[image]{NUMBER}[/image]';
                        $bbcode_tpl = $this->bbcode_tpl($config_value);
                        $sql_ary = $acp_bbcodes->build_regexp($bbcode_match, $bbcode_tpl);
                        $sql_ary = array_merge($sql_ary, array('bbcode_match' => $bbcode_match, 'bbcode_tpl' => $bbcode_tpl, 'display_on_posting' => true, 'bbcode_helpline' => 'GALLERY_HELPLINE_ALBUM'));
                        $sql = 'UPDATE ' . BBCODES_TABLE . '
							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE bbcode_tag = '" . $sql_ary['bbcode_tag'] . "'";
                        $db->sql_query($sql);
                        $cache->destroy('sql', BBCODES_TABLE);
                    }
                }
                if (strpos($config_name, 'watermark') !== false && $phpbb_gallery_configs->get($config_name) != $config_value) {
                    $phpbb_gallery_configs->set('watermark_changed', time());
                }
                $phpbb_gallery_configs->set($config_name, $config_value);
            }
        }
        if ($submit) {
            $cache->destroy('sql', CONFIG_TABLE);
            trigger_error($user->lang['GALLERY_CONFIG_UPDATED'] . adm_back_link($this->u_action));
        }
        $this->tpl_name = 'acp_board';
        $this->page_title = $vars['title'];
        $template->assign_vars(array('L_TITLE' => $user->lang[$vars['title']], 'L_TITLE_EXPLAIN' => $user->lang[$vars['title'] . '_EXPLAIN'], 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'U_ACTION' => $this->u_action));
        // Output relevant page
        foreach ($vars['vars'] as $config_key => $vars) {
            if (!is_array($vars) && strpos($config_key, 'legend') === false) {
                continue;
            }
            if (strpos($config_key, 'legend') !== false) {
                $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars));
                continue;
            }
            if (isset($vars['append'])) {
                $vars['append'] = isset($user->lang[$vars['append']]) ? ' ' . $user->lang[$vars['append']] : $vars['append'];
            }
            $this->new_config[$config_key] = $phpbb_gallery_configs->get($config_key);
            $type = explode(':', $vars['type']);
            $l_explain = '';
            //$this->var_display($vars);
            if (isset($vars['explain'])) {
                $l_explain = isset($user->lang[$vars['lang'] . '_EXP']) ? $user->lang[$vars['lang'] . '_EXP'] : '';
            }
            $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
            if (empty($content)) {
                continue;
            }
            $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => isset($vars['explain']) ? $vars['explain'] : '', 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content));
            unset($this->display_vars['vars'][$config_key]);
        }
    }