Skip to content

Commit

Permalink
Merge pull request #20 from nliautaud/1.1
Browse files Browse the repository at this point in the history
1.1
  • Loading branch information
nliautaud authored Oct 24, 2017
2 parents 4625051 + bae4b64 commit 680f080
Show file tree
Hide file tree
Showing 50 changed files with 3,272 additions and 2,031 deletions.
51 changes: 34 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
p01contact
==========
# p01contact

Create contact forms by writing simple tags.

p01-contact is natively a plugin for [GetSimple CMS](http://get-simple.info).
Usage as a plugin for [GetSimple CMS] or [Pico CMS], syntax and settings are documented in the [wiki].

Live examples, syntax and settings are documented in the [Wiki](https://github.com/nliautaud/p01contact/wiki/_pages)
![](https://img.shields.io/github/release/nliautaud/p01contact.svg?style=for-the-badge&label=Latest+release)

<p align="center">
<img src="capture.png"><img src="capture_complex.png">
</p>

## Installation

Download the files.

For GetSimple CMS, unzip it in the ``plugins/`` directory.
For [GetSimple CMS], place the `p01-contact` directory and the file `p01-contact_gs.php` in `plugins/`.

## Use
For [Pico CMS], place the `p01-contact` directory in `plugins/`.

### As a GetSimple plugin
## Usage as a plugin

Just write tags in your pages according to the [syntax](https://github.com/nliautaud/p01contact/wiki/Syntax). Reminds you to fill the Meta Description accessible in page options. If you don't, GetSimple will show the tag source in the source code of the output page.
Just write tags in your pages.

```
This is a default contact form :
Expand All @@ -27,24 +30,38 @@ This is a default contact form :
Simple.
```

You can also use it in components or templates by manipulating the variable ``$p01contact``, already initialized. For example, to add a default contact form in your sidebar :
Follow the [syntax] to create custom forms.

```php
<?php
get_component('sidebar');
echo $p01contact->parse('(% contact %)');
?>
```
(% contact en :
    subject => A locked subject,
    radio "I'd like to contact you" = a little | a lot |: passionately,
    select "Department" (the floor you look for) = Silly walks :| Strange things,
    email!,
    message =< Bla bla placeholder,
    checkbox! "I'm in control",
    askcopy
%)
```

### As a PHP script
Details about usage as a plugin can be found in the [wiki] :
- [GetSimple plugin](https://github.com/nliautaud/p01contact/wiki/GetSimple-plugin)
- [Pico CMS plugin](https://github.com/nliautaud/p01contact/wiki/Pico-CMS-plugin)

Include the script, create a new instance and parse a string containing tags using the [syntax](https://github.com/nliautaud/p01contact/wiki/Syntax).
## Usage as a PHP script

The simplest method is to include the script, create a new instance and parse strings containing tags using the [syntax].

```php
include 'path/to/p01-contact/p01-contact.php';
include 'p01-contact/P01contact.php';

$p01contact = new P01contact();

$content = 'This is a default contact form : (% contact %)'
$content = $p01contact->parse($content);
```

[GetSimple CMS]: http://get-simple.info
[Pico CMS]: http://picocms.org
[wiki]: https://github.com/nliautaud/p01contact/wiki/_pages
[syntax]: https://github.com/nliautaud/p01contact/wiki/Syntax
Binary file added capture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added capture_complex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 97 additions & 0 deletions p01-contact/P01contact_pico.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php
/**
* p01-contact for Pico CMS - Simply add contact forms in your pages
*
* This plugin let you add contact forms in your pages by writing simple tags.
* You can also define recipients or create your own complex forms.
*
* This file is the handle of p01-contact for Pico CMS.
*
* @link https://github.com/nliautaud/p01contact
* @author Nicolas Liautaud
* @package p01contact
* @version 1.1
*/

require_once 'src/P01contact.php';

class P01contact_pico extends AbstractPicoPlugin
{
private $P01contact;

/**
* Initialize P01contact and set the default language from Pico settings
*
* Triggered after Pico has read its configuration
*
* @see Pico::getConfig()
* @param array &$config array of config variables
* @return void
*/
public function onConfigLoaded(array &$config)
{
$this->P01contact = new P01C\P01contact();

if(!empty($config['default_language'])) {
$this->P01contact->default_lang = $config['default_language'];
}
}
/**
* Replace (% contact %) tags and contact_admin tags in pages content
*
* Triggered after Pico has prepared the raw file contents for parsing
*
* @see Pico::parseFileContent()
* @see DummyPlugin::onContentParsed()
* @param string &$content prepared file contents for parsing
* @return void
*/
public function onContentPrepared(&$content)
{
// replace config panel (% contact_admin_config %)
$content = preg_replace_callback('`\(%\s*contact_admin_config\s*%\)`', function () {
return $this->P01contact->panel();
}, $content, 1);

// replace debug report (% contact_admin_debug %)
$content = preg_replace_callback('`\(%\s*contact_admin_debug\s*%\)`', function () {
return $this->P01contact->config('debug') ? $this->P01contact->debugReport() : '';
}, $content, 1);

// replace forms (% contact ... %)
$content = $this->P01contact->parse($content);
}
/**
* Add {{ contact() }} and {{ contact_admin() }} twig functions
* For outputing forms and admin panels from themes templates
*
* Triggered before Pico renders the page
*
* @see Pico::getTwig()
* @see DummyPlugin::onPageRendered()
* @param Twig_Environment &$twig twig template engine
* @param array &$twigVariables template variables
* @param string &$templateName file name of the template
* @return void
*/
public function onPageRendering(Twig_Environment &$twig, array &$twigVariables, &$templateName)
{
// {{ contact() }} output the default form
// {{ contact('parameters') }} custom parameters
// {{ contact('fr', 'parameters') }} custom parameters and form-specific language
// {{ contact('fr', null) }} default form with form-specific language
$twig->addFunction(new Twig_SimpleFunction('contact', function ($a, $b) {
if (isset($b)) return $this->P01contact->newForm($b, $a);
return $this->P01contact->newForm($a);
}));

// {{ contact_admin('debug') }} output the debug report
// {{ contact_admin('config') }} output the config panel
$twig->addFunction(new Twig_SimpleFunction('contact_admin', function ($type) {
if ($type == 'debug' && $this->P01contact->config('debug'))
return $this->P01contact->debugReport();
if ($type == 'config')
return $this->P01contact->panel();
}));
}
}
104 changes: 0 additions & 104 deletions p01-contact/lang/bg.php

This file was deleted.

86 changes: 86 additions & 0 deletions p01-contact/lang/bg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
# Bulgarian language file for p01-contact
key: bg
name: Bulgarian
english_name: Bulgarian
authors: Panayot Kuyvliev
date: "2011-10-22"
compatibility: 1.1
strings:
# fields
name: Име
email: Email
address: Адрес
tel: Телефон
url: Уебсайт
subject: Относно
message: Съобщение
file: Прикачи
captcha: Captcha
reload: Презареди
fieldcaptcha: Грешен код
askcopy: Прати ми копие на това съобщение
send: Прати

# email words
askedcopy: Поискано е копие на това съобщение
anonymous: Анонимен
nosubject: (Няма тема)
email_title: Съобщението е изпратено от

# status messages
sent: Съобщението е изпратено.
error: "Грешка : съобщението не е изпратено."
disable: Контактната форма е недостъпна.
error_notarget: Тази контактна форма няма получател.
token: Съобщението вече е изпратено.

# fields errors
field_required: Това поле е задължително
field_email: Моля използвайте валиден имейл адрес
field_tel: Моля използвайте валиден телефонен номер
field_url: Моля напишете валиден уеб адрес
field_message: Моля напишете по дълго съобщение
field_captcha: Моля копирайте следния текст
field_fieldcaptcha: Моля не попълвайте това поле
field_password: Грешна парола

# configuration panel

config_title: p01contact Настройки

# messages
config_updated: Твоите промени са запазени успешно.

config_error_open: "<b>Конфигуриращият файл не може да бъде отворен.</b> Проверете дали файла съществува и неговата достъпност :"

# New release alert
new_release: Има нова версия!
download: Свали последната версия

# Links
doc: Документация
forum: Форум

# Parameters
enable: Пусни
enable_sub: Пускане и спиране изпращането на съобщения (без да се скрива контактната форма).

default_email: Емейл по подразбиране
default_email_sub: Оставете празно, за да го настроите да

lang: Език
lang_sub: Езикът по подразбиране е

default_params: Параметри по подразбиране

message_len: Минимална големина на съобщението

blacklist: Черен списък
whitelist: Бял списък
checklists_sub: "Черен списък: стойности, които не трябва да присъстват в областта за изпращане на имейл <br />. Бял списък: Възможните стойности от значение за областта, за да изпратите имейл <br />. Разделени със запетаи."

general_fields: Общи полета
special_fields: Специални полета

debug_sub: Изключване на изпращането на съобщения, display p01-contact data structure, data sent by POST and the email that would have been sent.
Loading

0 comments on commit 680f080

Please sign in to comment.