本文整理汇总了PHP中template::text方法的典型用法代码示例。如果您正苦于以下问题:PHP template::text方法的具体用法?PHP template::text怎么用?PHP template::text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类template
的用法示例。
在下文中一共展示了template::text方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* MODULE : Édition d'une news */
public function edit()
{
// Erreur 404
if (!$this->getData([$this->getUrl(0), $this->getUrl(2)])) {
return false;
} elseif ($this->getPost('submit')) {
// Modifie la clef de la news si le titre a été modifié
$key = $this->getPost('title') ? $this->getPost('title', helper::URL) : $this->getUrl(2);
// Sauvegarde la date de création de la news
$date = $this->getData([$this->getUrl(0), $this->getUrl(2), 'date']);
// Si la clef à changée
if ($key !== $this->getUrl(2)) {
// Incrémente la nouvelle clef de la news pour éviter les doublons
$key = helper::increment($key, $this->getData($this->getUrl(0)));
// Supprime l'ancienne news
$this->removeData([$this->getUrl(0), $this->getUrl(2)]);
}
// Modifie la news ou en crée une nouvelle si la clef a changée
$this->setData([$this->getUrl(0), $key, ['title' => $this->getPost('title', helper::STRING), 'date' => $date, 'content' => $this->getPost('content')]]);
// Enregistre les données
$this->saveData();
// Notification de modification
$this->setNotification('News modifiée avec succès !');
// Redirige vers l'édition de la nouvelle news si la clef à changée ou sinon vers l'ancienne
helper::redirect('module/' . $this->getUrl(0) . '/edit/' . $key);
}
// Contenu de la page
self::$content = template::openForm() . template::openRow() . template::text('title', ['label' => 'Titre de la news', 'value' => $this->getData([$this->getUrl(0), $this->getUrl(2), 'title']), 'required' => 'required']) . template::newRow() . template::textarea('content', ['class' => 'editor', 'value' => $this->getData([$this->getUrl(0), $this->getUrl(2), 'content'])]) . template::newRow() . template::button('back', ['value' => 'Retour', 'href' => helper::baseUrl() . 'module/' . $this->getUrl(0), 'col' => 2]) . template::submit('submit', ['col' => 2, 'offset' => 8]) . template::closeRow();
template::closeForm();
}
示例2: index
/**
* MODULE : Configuration de la redirection
*/
public function index()
{
if ($this->getPost('submit')) {
$this->setData($this->getUrl(1), 'url', $this->getPost('url', helpers::URL));
$this->saveData();
$this->setNotification('Configuration du module enregistrée avec succès !');
helpers::redirect($this->getUrl());
}
self::$content = template::openForm() . template::openRow() . template::text('url', ['label' => 'URL de redirection', 'value' => $this->getData($this->getUrl(1), 'url')]) . template::newRow() . template::button('back', ['value' => 'Retour', 'href' => '?edit/' . $this->getUrl(1), 'col' => 2]) . template::submit('submit', ['col' => 2, 'offset' => 8]) . template::closeRow() . template::closeForm();
}
示例3: index
/**
* MODULE : Formulaire de contact
*/
public function index()
{
// Envoi du mail
if ($this->getPost('submit')) {
$mail = helpers::mail($this->getPost('subject', helpers::STRING), $this->getData($this->getUrl(0), 'mail'), $this->getPost('subject', helpers::STRING), $this->getPost('message', helpers::STRING));
if ($mail) {
$this->setNotification('Mail envoyé avec succès !');
} else {
$this->setNotification('Impossible d\'envoyer le mail !');
}
helpers::redirect($this->getUrl());
}
// Interface d'écriture de mail
self::$content = template::openForm() . template::openRow() . template::text('mail', ['label' => 'Adresse mail', 'required' => true, 'col' => 6]) . template::newRow() . template::text('subject', ['label' => 'Sujet', 'required' => true, 'col' => 6]) . template::newRow() . template::textarea('message', ['label' => 'Sujet', 'required' => true, 'col' => 7]) . template::newRow() . template::submit('submit', ['col' => 2]) . template::closeRow() . template::closeForm();
}
示例4: index
/** MODULE : Configuration de la redirection*/
public function index()
{
// Traitement du formulaire
if ($this->getPost('submit')) {
// Modifie l'URL de redirection
$this->setData([$this->getUrl(0), 'url', $this->getPost('url', helper::URL)]);
// Enregistre les données
$this->saveData();
// Notification de succès
$this->setNotification('URL de redirection enregistrée avec succès !');
// Redirige vers l'URL courante
helper::redirect($this->getUrl());
}
// Contenu de la page
self::$content = template::openForm() . template::openRow() . template::text('url', ['label' => 'URL de redirection', 'value' => $this->getData([$this->getUrl(0), 'url'])]) . template::newRow() . template::button('back', ['value' => 'Retour', 'href' => helper::baseUrl() . 'edit/' . $this->getUrl(0), 'col' => 2]) . template::submit('submit', ['col' => 2, 'offset' => 8]) . template::closeRow() . template::closeForm();
}
示例5: edit
/**
* MODULE : Édition d'une news
*/
public function edit()
{
if (!$this->getData($this->getUrl(1), $this->getUrl(3))) {
return false;
} elseif ($this->getPost('submit')) {
$key = $this->getPost('title') ? $this->getPost('title', helpers::URL) : $this->getUrl(3);
$date = $this->getData($this->getUrl(1), $this->getUrl(3), 'date');
if ($key !== $this->getUrl(3)) {
$key = helpers::increment($key, $this->getData($this->getUrl(1)));
$this->removeData($this->getUrl(1), $this->getUrl(3));
}
$this->setData($this->getUrl(1), $key, ['title' => $this->getPost('title', helpers::STRING), 'date' => $date, 'content' => $this->getPost('content')]);
$this->saveData();
$this->setNotification('News modifiée avec succès !');
helpers::redirect('module/' . $this->getUrl(1) . '/' . $this->getUrl(2) . '/' . $key);
}
self::$content = template::openForm() . template::openRow() . template::text('title', ['label' => 'Titre de la news', 'value' => $this->getData($this->getUrl(1), $this->getUrl(3), 'title'), 'required' => true]) . template::newRow() . template::textarea('content', ['class' => 'editor', 'value' => $this->getData($this->getUrl(1), $this->getUrl(3), 'content')]) . template::newRow() . template::button('back', ['value' => 'Retour', 'href' => '?module/' . $this->getUrl(1), 'col' => 2]) . template::submit('submit', ['col' => 2, 'offset' => 8]) . template::closeRow();
template::closeForm();
}
示例6: generateInput
/**
* Génère un champ en fonction de son type
* @param $input array Input à générer
* @return string
*/
private function generateInput($input)
{
switch ($input['type']) {
case 'text':
// Génère le champ texte
return template::openRow() . template::text('input[]', ['label' => $input['name'], 'col' => $input['width']]) . template::closeRow();
case 'textarea':
// Génère le grand champ texte
return template::openRow() . template::textarea('input[]', ['label' => $input['name'], 'col' => $input['width']]) . template::closeRow();
case 'select':
// Génère un tableau sous forme value => value
$values = array_flip(explode(',', $input['values']));
foreach ($values as $value => $key) {
$values[$value] = $value;
}
// Génère le champ de sélection
return template::openRow() . template::select('input[]', $values, ['label' => $input['name'], 'col' => $input['width']]) . template::closeRow();
}
}
示例7: config
/**
* MODULE : Configuration
*/
public function config()
{
if ($this->getPost('submit')) {
if ($this->getPost('password')) {
if ($this->getPost('password') === $this->getPost('confirm')) {
$password = $this->getPost('password', helpers::PASSWORD);
} else {
$password = $this->getData('config', 'password');
template::$notices['confirm'] = 'La confirmation ne correspond pas au nouveau mot de passe';
}
} else {
$password = $this->getData('config', 'password');
}
$this->setData('config', ['title' => $this->getPost('title', helpers::STRING), 'description' => $this->getPost('description', helpers::STRING), 'password' => $password, 'index' => $this->getPost('index', helpers::STRING), 'theme' => $this->getPost('theme', helpers::STRING)]);
$this->saveData(true);
$this->setNotification('Configuration enregistrée avec succès !');
helpers::redirect($this->getUrl());
}
self::$title = 'Configuration';
self::$content = template::openForm() . template::openRow() . template::text('title', ['label' => 'Titre du site', 'required' => true, 'value' => $this->getData('config', 'title')]) . template::newRow() . template::textarea('description', ['label' => 'Description du site', 'required' => true, 'value' => $this->getData('config', 'description')]) . template::newRow() . template::password('password', ['label' => 'Nouveau mot de passe', 'col' => 6]) . template::password('confirm', ['label' => 'Confirmation du mot de passe', 'col' => 6]) . template::newRow() . template::select('index', helpers::arrayCollumn($this->getData('pages'), 'title', 'SORT_ASC', true), ['label' => 'Page d\'accueil', 'required' => true, 'selected' => $this->getData('config', 'index')]) . template::newRow() . template::select('theme', helpers::listThemes(), ['label' => 'Thème par défaut', 'required' => true, 'selected' => $this->getData('config', 'theme')]) . template::newRow() . template::text('version', ['label' => 'Version de ZwiiCMS', 'value' => self::VERSION, 'disabled' => true]) . template::newRow() . template::button('clean', ['value' => 'Vider le cache', 'href' => '?clean', 'col' => 3, 'offset' => 4]) . template::button('export', ['value' => 'Exporter les données', 'href' => '?export', 'col' => 3]) . template::submit('submit', ['col' => 2]) . template::closeRow() . template::closeForm();
}
示例8: files
/** MODULE : Gestionnaire de fichiers */
public function files()
{
// Traitement du formulaire
if ($this->getPost('submit')) {
$this->upload(['png', 'gif', 'jpg', 'jpeg', 'txt', 'pdf', 'zip', 'rar', '7z', 'css', 'html', 'xml']);
}
// Liste les fichiers
foreach (helper::listUploads() as $path => $file) {
self::$content .= template::openRow() . template::text('file[]', ['value' => $file, 'readonly' => 'readonly', 'col' => 8]) . template::button('preview[]', ['value' => 'Aperçu', 'href' => $path, 'target' => '_blank', 'col' => 2]) . template::button('delete[]', ['value' => 'Supprimer', 'href' => helper::baseUrl() . 'delete/' . $file, 'onclick' => 'return confirm(\'' . helper::translate('Êtes-vous sûr de vouloir supprimer ce fichier ?') . '\');', 'col' => 2]) . template::closeRow();
}
// Contenu de la page
self::$title = helper::translate('Gestionnaire de fichiers');
self::$content = template::title('Envoyer un fichier') . template::openForm('form', ['enctype' => 'multipart/form-data']) . template::openRow() . template::file('file', ['label' => 'Parcourir mes fichiers', 'help' => 'Envoyez vos fichier sur votre site (formats autorisés : png, gif, jpg, jpeg, txt, pdf, zip, rar, 7z, css, html, xml).', 'col' => '10']) . template::submit('submit', ['value' => 'Envoyer', 'col' => '2']) . template::closeRow() . template::closeForm() . template::title('Liste des fichiers') . self::$content;
}