Hi all,
I got a new custommer for campsite, but I need one feature for him.
He wishes, that subscribers has a right to insert their own article.
My idea was to create some template including proper form (not using template
language and that can solve security itselve). Allowed text will be only a
plain text, but I might need to use BodyText field for storing longer plain
texts. So no worries about formating.
After sending this form, I will run PHP script that cleans unwanted characters
and enters new article to proper place.
I have no clue about possibilities in 2.2 campsite and my question is simple:
Do we have some oficial PHP library for 2.2 campsite that can be included
into PHP functions and that contain following functions?
If not, how expensive it would be to make this library and put it as a
standard part of campsite distribution?
How long it would take to create these functions?
How difficult is to use WISIWIG editor for editing fields this way?
How can I handle pictures this way?
Ondra
------------------------------------------
Posted to Phorum via PhorumMail
Hi Ondra -
2.2 does introduce the beginnings of a campsite API. We havent
published it yet because we dont think it has matured enough to be
considered stable; meaning that the names of the functions and the
arguments used to call those function may still change. However, the
article API is quite powerful as it stands today.
To create a new article, you would do the following:
----------------------------------------------------
// Create the article object (does not create anything in the database).
$article =& new Article(publication, issue, section, language);
// Create the row in the database.
$article->create(articleType, optional_name_of_article);
// Get the article ID.
$articleId = $article->getArticleId();
(put the article ID, publication, issue, section, and language in your
HTML form)
To display the input fields of the article, you would do the following:
-----------------------------------------------------------------------
// To retrieve an article from the database, also specify the article
// ID in the constructor.
$article =& new Article(pub, issue, section, language, articleId);
// The article type object stores the dynamic data for an article.
$articleData = $article->getArticleTypeObject();
// Get all the dynamic fields in the article (this returns
// an array of DbColumn objects).
$fields = $articleData->getUserDefinedColumns();
// Iterate through all the fields and display each one.
foreach ($fields as $field) {
// Prompt the user with the name of the field.
echo $field->getPrintName().":";
// Article types can be "char", "date", or "blob".
switch ($field->getType()) {
case "char":
...
break;
case "date":
...
break;
case "blob":
echo ' ';
break;
}
}
To save an article:
-------------------
$article =& new Article(pub, issue, section, language, articleId);
$articleData =& $article->getArticleTypeObject();
$fields = $articleData->getUserDefinedColumns();
foreach ($fields as $field) {
$dbColumnName = $field->getName();
if (isset($_REQUEST[$name])) {
$articleData->setProperty($name, $_REQUEST[$name]);
}
}
Reference files (in a default install):
---------------------------------------
/usr/local/campsite/www-common/html/classes/Article.php
/usr/local/campsite/www-common/html/classes/ArticleType.php
/usr/local/campsite/www-common/html/classes/DbColumn.php
/usr/local/campsite/www-common/html/priv/pub/issues/sections/articles/edit.php
/usr/local/campsite/www-common/html/priv/pub/issues/sections/articles/do_edit.php
As for the WYSIWYG editor - that is currently more difficult to set up.
I'll put an issue in mantis and see if it will be possible to make
this easy to use in custom modules.
I hope this helps, please let me know if you need more information.
- Paul
Ondra Koutek wrote:
> Hi all,
> I got a new custommer for campsite, but I need one feature for him.
> He wishes, that subscribers has a right to insert their own article.
> My idea was to create some template including proper form (not using template
> language and that can solve security itselve). Allowed text will be only a
> plain text, but I might need to use BodyText field for storing longer plain
> texts. So no worries about formating.
> After sending this form, I will run PHP script that cleans unwanted characters
> and enters new article to proper place.
>
> I have no clue about possibilities in 2.2 campsite and my question is simple:
> Do we have some oficial PHP library for 2.2 campsite that can be included
> into PHP functions and that contain following functions?
>
> article_id create_article(publication, issue, section, article_type,
> articlename);
> update_article(article_id, field, value)
>
> If not, how expensive it would be to make this library and put it as a
> standard part of campsite distribution?
> How long it would take to create these functions?
> How difficult is to use WISIWIG editor for editing fields this way?
> How can I handle pictures this way?
>
> Ondra
>
>
------------------------------------------
Posted to Phorum via PhorumMail
Those are very good news.
Thanks a lot.
The wisiwig editor is not the major problem, but I am sure I will need to
insert image to the form field somehow.
I think I know workaround and will ask you at the time it comes.
We will see, if htmlarea will be sviable in that time or if we find some
workaround. We can have a short chat about it on Summer camp.
Ondra
On Friday 13 May 2005 17:33, Paul Baranowski wrote:
> Hi Ondra -
> 2.2 does introduce the beginnings of a campsite API. We havent
> published it yet because we dont think it has matured enough to be
> considered stable; meaning that the names of the functions and the
> arguments used to call those function may still change. However, the
> article API is quite powerful as it stands today.
>
>
> To create a new article, you would do the following:
> ----------------------------------------------------
> // Create the article object (does not create anything in the database).
> $article =& new Article(publication, issue, section, language);
>
> // Create the row in the database.
> $article->create(articleType, optional_name_of_article);
>
> // Get the article ID.
> $articleId = $article->getArticleId();
>
> (put the article ID, publication, issue, section, and language in your
> HTML form)
>
> To display the input fields of the article, you would do the following:
> -----------------------------------------------------------------------
> // To retrieve an article from the database, also specify the article
> // ID in the constructor.
> $article =& new Article(pub, issue, section, language, articleId);
>
> // The article type object stores the dynamic data for an article.
> $articleData = $article->getArticleTypeObject();
>
> // Get all the dynamic fields in the article (this returns
> // an array of DbColumn objects).
> $fields = $articleData->getUserDefinedColumns();
>
> // Iterate through all the fields and display each one.
> foreach ($fields as $field) {
>
> // Prompt the user with the name of the field.
> echo $field->getPrintName().":";
>
> // Article types can be "char", "date", or "blob".
> switch ($field->getType()) {
> case "char":
> ...
> break;
> case "date":
> ...
> break;
> case "blob":
> echo ' ';
> break;
> }
> }
>
>
> To save an article:
> -------------------
> $article =& new Article(pub, issue, section, language, articleId);
> $articleData =& $article->getArticleTypeObject();
> $fields = $articleData->getUserDefinedColumns();
>
> foreach ($fields as $field) {
> $dbColumnName = $field->getName();
> if (isset($_REQUEST[$name])) {
> $articleData->setProperty($name, $_REQUEST[$name]);
> }
> }
>
>
> Reference files (in a default install):
> ---------------------------------------
> /usr/local/campsite/www-common/html/classes/Article.php
> /usr/local/campsite/www-common/html/classes/ArticleType.php
> /usr/local/campsite/www-common/html/classes/DbColumn.php
> /usr/local/campsite/www-common/html/priv/pub/issues/sections/articles/edit.
>php
> /usr/local/campsite/www-common/html/priv/pub/issues/sections/articles/do_ed
>it.php
>
>
> As for the WYSIWYG editor - that is currently more difficult to set up.
> I'll put an issue in mantis and see if it will be possible to make
> this easy to use in custom modules.
>
> I hope this helps, please let me know if you need more information.
>
> - Paul
>
> Ondra Koutek wrote:
> > Hi all,
> > I got a new custommer for campsite, but I need one feature for him.
> > He wishes, that subscribers has a right to insert their own article.
> > My idea was to create some template including proper form (not using
> > template language and that can solve security itselve). Allowed text will
> > be only a plain text, but I might need to use BodyText field for storing
> > longer plain texts. So no worries about formating.
> > After sending this form, I will run PHP script that cleans unwanted
> > characters and enters new article to proper place.
> >
> > I have no clue about possibilities in 2.2 campsite and my question is
> > simple: Do we have some oficial PHP library for 2.2 campsite that can be
> > included into PHP functions and that contain following functions?
> >
> > article_id create_article(publication, issue, section, article_type,
> > articlename);
> > update_article(article_id, field, value)
> >
> > If not, how expensive it would be to make this library and put it as a
> > standard part of campsite distribution?
> > How long it would take to create these functions?
> > How difficult is to use WISIWIG editor for editing fields this way?
> > How can I handle pictures this way?
> >
> > Ondra
------------------------------------------
Posted to Phorum via PhorumMail