par hika - 2005-07-03 11:24:53
crée le 2005-06-28 21:33:48
PHP Wakka
Tout d'abord, c'est quoi Wakka ?
Il s'agit d'un moteur Wiki pour gérer la création de page dynamique. Avec ceci, plus besoin de créer de nouveaux fichiers, puisqu'il s'agit uniquement d'ajouter de nouveaux contenus et liens internes.
Il est même possible d'intégrér des images.
Vous pouvez trouver le code source PHP de ce moteur wiki, utilisé sur certaines pages du site.
Il se compose de 3 fichiers, actuellement :
- wakka.config.php, contient les variables de configuration
- wakka_img.php, script gérant l'affichage des images, qui ont pu être uploadées
- wakka.class.php, script contenant la définition de la classe Wakka
En plus de cela, vous aurez besoin de la class Connect, gérant les accès à la base de données :
- mysql.php pour MySQL
- postgres.php pour PostgreSQL
Pour l'utiliser, mettez simplement
<?php
include_once("wakka.class.php");
$wakka = new Wakka();
// Forçage du nom de la page
$wakka->wakka_page = "index";
$wakka->can_edit = true;
// Création de l'objet Connect
$Conn = new Connect("username", "password", "hostname", "dbname");
$wakka->setConnect($Conn);
// Décommenter si on active l'URL rewriting
// $wakka->parse_rewritefile("./.htaccess");
// Décommenter ces lignes, si vous voulez seulement afficher
// une page d'upload de fichier image
// $wakka->force_postvar = false;
// $wakka->force_getvar = false;
// $wakka->only_upload_form = true;
$wakka->display();
?>
dans la page appelante.
NB : la variable $_GET[$WAKKA_PAGE_NAME] est prioritaire sur $wakka_page
(cf wakka.config.php pour $WAKKA_PAGE_NAME)
Pour le formatage du texte, vous devez paramétrer wakka.config.php en fonction de vos CSS.
Voici les ordres SQL de création de tables, ici pour PostgreSQL :
--
-- PostgreSQL database dump
--
CREATE TABLE wakka_txt (
wakka_key character varying(100) NOT NULL,
wakka_txt text DEFAULT ''::text NOT NULL,
wakka_date_creat timestamp without time zone DEFAULT '0001-01-01 00:00:00'::timestamp without time zone NOT NULL,
wakka_date_modif timestamp without time zone DEFAULT '0001-01-01 00:00:00'::timestamp without time zone NOT NULL,
wakka_public smallint DEFAULT (0)::smallint NOT NULL,
wakka_author_id integer,
wakka_author_name character varying(50)
);
ALTER TABLE ONLY wakka_txt
ADD CONSTRAINT wakka_txt_pkey PRIMARY KEY (wakka_key);
CREATE TABLE wakka_txt_revision (
wakka_key character varying(100) NOT NULL,
wakka_revision integer DEFAULT 0 NOT NULL,
wakka_txt text DEFAULT ''::text NOT NULL,
wakka_date_revision timestamp without time zone DEFAULT '0001-01-01 00:00:00'::timestamp without time zone NOT NULL,
wakka_tag character varying(100) DEFAULT ''::character varying NOT NULL,
wakka_author_id integer,
wakka_author_name character varying(50),
wakka_revision_author_id integer,
wakka_revision_author_name character varying(50)
);
ALTER TABLE ONLY wakka_txt_revision
ADD CONSTRAINT wakka_txt_revision_pkey PRIMARY KEY (wakka_key, wakka_revision);
CREATE TABLE wakka_img (
wakka_key character varying(100) NOT NULL,
wakka_type character varying(100) DEFAULT ''::character varying NOT NULL,
wakka_size integer DEFAULT 0 NOT NULL,
wakka_name character varying(100) DEFAULT ''::character varying NOT NULL,
wakka_data bytea NOT NULL,
wakka_date_creat timestamp without time zone DEFAULT '0001-01-01 00:00:00'::timestamp without time zone NOT NULL,
wakka_date_modif timestamp without time zone DEFAULT '0001-01-01 00:00:00'::timestamp without time zone NOT NULL,
CONSTRAINT "$1" CHECK ((wakka_size >= 0))
);
ALTER TABLE ONLY wakka_img
ADD CONSTRAINT wakka_img_pkey PRIMARY KEY (wakka_key);