public function add($title, $folder) { $contentdesc = new Contenudesc(); $contentdesc->titre = $title; if ($contentdesc->titre !== '') { $this->datemodif = date('Y-m-d H:i:s'); $this->dossier = $folder; $this->ligne = 1; $this->classement = $this->getMaxRanking($folder) + 1; $this->id = parent::add(); $contentdesc->lang = ActionsLang::instance()->get_id_langue_courante(); $contentdesc->contenu = $this->id; $contentdesc->id = $contentdesc->add(); $contentdesc->reecrire(); ActionsModules::instance()->appel_module("ajoutcont", new Contenu($this->id)); redirige('contenu_modifier.php?id=' . $this->id . '&dossier=' . $this->dossier); } else { throw new TheliaAdminException("impossible to add new content", TheliaAdminException::CONTENT_ADD_ERROR, null, $contentdesc); } }
public function insert($position, Contenu $content) { $max = $this->_write + 1; if ($position < 0 || $position > $max) { throw new MethodParametersException('Nouvelle position invalide'); } for ($i = $position; $i < $max; $i += 1) { $content->add($this->_content[$i]); if ($i < $max - 1) { $content->add_sauts(); } } $this->_write = $position; $content->rewind(); while ($content->valid()) { if ($content->key() > 0) { $this->add_sauts(); } $this->resetLine()->add($content->current()); $content->next(); } }
function ajouter($lang, $dossier, $ligne, $titre, $chapo, $description, $postscriptum) { if (!isset($id)) { $id = ""; } $contenu = new Contenu(); $contenu->charger($id); if ($contenu->id) { return; } $contenu = new Contenu(); $contenu->datemodif = date("Y-m-d H:i:s"); $contenu->dossier = $dossier; if ($ligne == "on") { $contenu->ligne = 1; } else { $contenu->ligne = 0; } $lastid = $contenu->add(); $contenu->id = $lastid; $contenudesc = new Contenudesc(); $contenudesc->chapo = $chapo; $contenudesc->description = $description; $contenudesc->postscriptum = $postscriptum; $contenudesc->contenu = $lastid; $contenudesc->lang = $lang; $contenudesc->titre = $titre; $contenudesc->chapo = str_replace("\n", "<br/>", $contenudesc->chapo); $contenudesc->postscriptum = str_replace("\n", "<br/>", $contenudesc->postscriptum); $contenudesc->add(); $contenudesc->reecrire(); ActionsModules::instance()->appel_module("ajoutcont", $contenu); redirige($_SERVER['PHP_SELF'] . "?id=" . $lastid . "&dossier=" . $contenu->dossier); exit; }
<?php if (php_sapi_name() != 'cli') { echo 'CGI Mode !'; exit; } if ($argc < 2) { exit('paramètre manquant !'); } $path = __DIR__ . '/pages/' . $argv[1]; if (strpos($path, '.php') === false) { $path = $path . '.php'; } require 'core/contenu.php'; $file = fopen($path, 'w'); $contenu = new Contenu(); $contenu->add('Voici la page generer par le framework')->add_sauts(1)->addTab()->add('<h1>je vous invite a modifier son contenu</h1>')->add_sauts(1)->add('<hr>By jenaye'); $contenu->writeFile($file); fclose($file); chmod($path, 0777);
<?php if (php_sapi_name() != 'cli') { echo 'CGI Mode !'; exit; } if ($argc < 2) { exit('paramètre manquant !'); } $path = __DIR__ . '/functions/' . $argv[1]; if (strpos($path, '.php') === false) { $path = $path . '.php'; } require 'core/contenu.php'; $file = fopen($path, 'w'); // var_dump($argv); // recuperation du nom de la function tappé $name = ucfirst(basename($path, '.php')); $contenu = new Contenu(); $contenu->add('<?php')->add_sauts(2)->add("class {$name} {")->add_sauts(2)->addTab(1)->add('public function Votrefunction() {')->add_sauts(1)->addTab(2)->add('return "Une phrase par exemple";')->add_sauts(1)->addTab(6)->add('} ')->add_sauts(1)->addTab(3)->add('}')->add_sauts(1)->addTab(2)->add('// Ceci est un commentaire php')->add_sauts(1)->add('?>'); $contenu->writeFile($file); fclose($file); chmod($path, 0777);