Exemple #1
0
            secure_directory(PHPWG_ROOT_PATH . $conf['data_location']);
            $tmp_filename = md5(uniqid(time()));
            $fh = @fopen(PHPWG_ROOT_PATH . $conf['data_location'] . 'pwg_' . $tmp_filename, 'w');
            @fputs($fh, $file_content, strlen($file_content));
            @fclose($fh);
            $template->assign(array('config_creation_failed' => true, 'config_url' => 'install.php?dl=' . $tmp_filename, 'config_file_content' => $file_content));
        }
        @fputs($fp, $file_content, strlen($file_content));
        @fclose($fp);
        // tables creation, based on piwigo_structure.sql
        execute_sqlfile(PHPWG_ROOT_PATH . 'install/piwigo_structure-mysql.sql', DEFAULT_PREFIX_TABLE, $prefixeTable, 'mysql');
        // We fill the tables with basic informations
        execute_sqlfile(PHPWG_ROOT_PATH . 'install/config.sql', DEFAULT_PREFIX_TABLE, $prefixeTable, 'mysql');
        $query = '
INSERT INTO ' . $prefixeTable . 'config (param,value,comment) 
   VALUES (\'secret_key\',md5(' . pwg_db_cast_to_text(DB_RANDOM_FUNCTION . '()') . '),
   \'a secret key specific to the gallery for internal use\');';
        pwg_query($query);
        conf_update_param('piwigo_db_version', get_branch_from_version(PHPWG_VERSION));
        conf_update_param('gallery_title', l10n('Just another Piwigo gallery'));
        conf_update_param('page_banner', '<h1>%gallery_title%</h1>' . "\n\n<p>" . l10n('Welcome to my photo gallery') . '</p>');
        // fill languages table
        foreach ($languages->fs_languages as $language_code => $fs_language) {
            $languages->perform_action('activate', $language_code);
        }
        // fill $conf global array
        load_conf_from_db();
        // PWG_CHARSET is required for building the fs_themes array in the
        // themes class
        if (!defined('PWG_CHARSET')) {
            define('PWG_CHARSET', 'utf-8');
    /**
     * Assigns the next/previous link to the template with regards to
     * the currently choosen date.
     */
    protected function build_next_prev()
    {
        global $template, $page;
        $prev = $next = null;
        if (empty($page['chronology_date'])) {
            return;
        }
        $sub_queries = array();
        $nb_elements = count($page['chronology_date']);
        for ($i = 0; $i < $nb_elements; $i++) {
            if ('any' === $page['chronology_date'][$i]) {
                $sub_queries[] = '\'any\'';
            } else {
                $sub_queries[] = pwg_db_cast_to_text($this->calendar_levels[$i]['sql']);
            }
        }
        $query = 'SELECT ' . pwg_db_concat_ws($sub_queries, '-') . ' AS period';
        $query .= $this->inner_sql . '
AND ' . $this->date_field . ' IS NOT NULL
GROUP BY period';
        $current = implode('-', $page['chronology_date']);
        $upper_items = query2array($query, null, 'period');
        usort($upper_items, 'version_compare');
        $upper_items_rank = array_flip($upper_items);
        if (!isset($upper_items_rank[$current])) {
            $upper_items[] = $current;
            // just in case (external link)
            usort($upper_items, 'version_compare');
            $upper_items_rank = array_flip($upper_items);
        }
        $current_rank = $upper_items_rank[$current];
        $tpl_var = array();
        if ($current_rank > 0) {
            // has previous
            $prev = $upper_items[$current_rank - 1];
            $chronology_date = explode('-', $prev);
            $tpl_var['previous'] = array('LABEL' => $this->get_date_nice_name($prev), 'URL' => duplicate_index_url(array('chronology_date' => $chronology_date), array('start')));
        }
        if ($current_rank < count($upper_items) - 1) {
            // has next
            $next = $upper_items[$current_rank + 1];
            $chronology_date = explode('-', $next);
            $tpl_var['next'] = array('LABEL' => $this->get_date_nice_name($next), 'URL' => duplicate_index_url(array('chronology_date' => $chronology_date), array('start')));
        }
        if (!empty($tpl_var)) {
            $existing = $template->smarty->getVariable('chronology_navigation_bars');
            if (!$existing instanceof Undefined_Smarty_Variable) {
                $existing->value[sizeof($existing->value) - 1] = array_merge($existing->value[sizeof($existing->value) - 1], $tpl_var);
            } else {
                $template->append('chronology_navigation_bars', $tpl_var);
            }
        }
    }