http://drupal.org/sandbox/peter/1509964
Cel approaches templating the way a cel is used in animation. Documented at PeterMoulding.com/cel and in use in several modules across several sites.

Cel is both a supplier of templates to code and through tokens. Cel also supplies useful functions as alternatives to token_replace() when token_replace() is not flexible enough. Programmers can use the functions. Everyone else can use the templating through any code enhanced by Cel.

Some uses include:

  • Fast flexible email templates.
  • Replace theme template files with something easier.
  • XML file generation.

Reproducing the online documentation here seems a waste. The code is used by other modules to handle templating similar to the way the Libraries API split library access out of WYSIWYG. There is an admin page so you can see what is available without having to reproduce the list in every user module. The code works with Token, Token ex, Token if, and a bunch of other modules.

Is there an alternative? There are some "half way there" modules, including Content templates, but developers are rejecting them for a dependency module because they all have several or more of the following problems. Cel has exactly what is needed for the other modules, no configuration required, a simple admin page to let you see what is available, and full documentation written by a professional writer.

  • Are not actively supported.
  • Moved to D7 too late.
  • Are not designed for use by other modules.
  • Do not connect into the relevant parts of Drupal.

Reviews of other projects

http://drupal.org/node/1167022#comment-5596872
http://drupal.org/node/1421554#comment-5596760
http://drupal.org/node/1269194#comment-5598582
http://drupal.org/node/1387212#comment-5598628
http://drupal.org/node/1684898#comment-6900784
http://drupal.org/node/1785088#comment-6903682

CommentFileSizeAuthor
#17 drupalcs-result.txt12.52 KBklausi
#1 1509964.pareview.txt7.63 KBalesr
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alesr’s picture

Status: Needs review » Needs work
FileSize
7.63 KB

Fix the PAReview issues in attachement first.
You can check here is your project meets Drupal coding standars http://ventral.org/pareview/httpgitdrupalorgsandboxpeter1509964git

patrickd’s picture

Status: Needs work » Closed (duplicate)

It appears that there have been multiple project applications opened under your username:

Project 1: Cel
Project 2: Unleash the Drupal watchdog in jQuery

As successful completion of the project application process results in the applicant being granted the 'Create Full Projects' permission, there is no need to take multiple applications through the process. Once the first application has been successfully approved, then the applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue. With this in mind, your secondary applications have been marked as 'closed(duplicate)', with only one application left open (chosen at random).

If you prefer that we proceed through this review process with a different application than the one which was left open, then feel free to close the 'open' application as a duplicate, and re-open one of the project applications which had been closed.

NancyDru’s picture

Status: Closed (duplicate) » Active

What an awesome sounding module! I think this would solve several problems I have.

Patrick: Do you have a crystal ball that tells you which one would be accepted first? Let's leave this open so it might have a chance to be the one that gets Peterx accepted.

patrickd’s picture

Status: Active » Closed (duplicate)

I'm sorry, but there were several discussions about this on groups.drupal.org.
Multiple applications just double the workload we have, and we have a lot of it.
He can feel free to reopen this one but close the other one.
I closed this one because it was newer and probably take longer then the last one which is already on half way.

peterx’s picture

Status: Closed (duplicate) » Needs review

I closed the jDog application because I am not currently working on it for any project. Cel is in use and I am currently working on code using it. The most painful part will be lowering my coding standards down to camel case.

peterx’s picture

The Drupal.org instructions tell you to set up your master branch with a single .info file. PAReview says you are not allowed to do that, You have to set up a single README.txt file.

Time warp back to 1980, 80 columns, and the Epson MX-80. I will have to make the code really unreadable to fit PAReview.

Not everything is going bad tonight. The PAReview site uses that awful recaptcha system and one of the displayed bits of text was actually readable.

Drupal says to replace t() with st() in install functions. PAReview says no, do something different.

PAReview says "WARNING | The use of private methods or properties is strongly
| | discouraged, use "protected" instead". Do we just ignore all warnings? Private is a valid choice and there are specific reasons for using private.

PAReview is WRONG here:
"ERROR | PHP4 style constructors are not allowed; use "__construct()"
| | instead"

The other PAReview messages are about using dumpy case and that will break compatibility with all existing modules in all existing sites.

patrickd’s picture

Yes, the problem is that these instructions are somewhere hardcoded in the project module, there are and where discussions about how to finally handle the master branch but this is still not resolved. pareview only suggests you to leave a readme rather then a single info file because many people were confused were the actual code is.

Also the 80-character per line issue should rather be understood as suggestion, if the code is going to look ugly because your following coding standarts that's really not the sense. We wont force applicants to follow all coding standarts perfectly, just whenever possible. (You can point people to this comment if they keep annoying you about it ;) )

I added some additional security checks to the pareview service client yesterday, so the captcha is (hopefully) not needed anylonger. I turned it off because many people were annoyed about it, so lets see if it is actually necessary.

The other issues are from drupalcs, please go ahead and create an issue about these points in its issue queue. Maybe your right and there's something to change, maybe you and me just don't know the reasons for these.

As said, take coding style as suggestion rather then policies, but whenever you can, follow them to help making code on drupal.org consistent.

thanks

peterx’s picture

Cels are now available as blocks. Some sites use them because they get a nice range of tokens to use in the text. The current version in the sandbox makes all cels into blocks. I will eventually copy in code from another version that lets you specify the block option by node, via an extra field.

Novalnet’s picture

Hi,

Manual Review :

1. Please use t() and placeholders for the description in cel.module line 75.
2. It seems you calling the cel_display_name() inbetween strings.Better you return the value to variable and use placeholders to use them.
3. Please avoid using HTML inside t() in line 129 of cel.module.
4. In cel_log() you are using Placeholders without t().It can be better if you enclose it.
ex:cel_log(t("abc"));
5. Use l() to create link markup instead of creating by your own in cel.install line 32.
6.It seems PAREVIEW contains some errors.so please get it cleared.

Thanks,

peterx’s picture

@Novalnet,
1 I added t() for the description.
2 Changed.
3 HTML removed.
4 t() added inside cel_log() for type and message. t() not added to variables going into messages because they are diagnostic and need the original machine name, or similar, untranslated.
5 Done.
6 I change everything to fit Coder, including warnings, then commit then PAREVIEW. Unfortunately Coder does not report everything and PAREVIEW reports some things that are different to some of the Drupal documentation pages.

peterx’s picture

45 | ERROR | PHP4 style constructors are not allowed; use "__construct()"
| | instead
The error message is wrong. The class uses __construct().

peterx’s picture

32 | ERROR | Do not use t() or st() in installation phase hooks, use $t =
| | get_t() to retrieve the appropriate localization function name
First it says to use st() instead of t() then after the change it says to use $t.

peterx’s picture

All the PAREVIEW changes changed. Backward compatibility is wrecked, as is compatibility with non Drupal versions. I hope there is a benefit for someone somewhere.

apaderno’s picture

Priority: Normal » Critical
peterx’s picture

Some more sites are now using this. Testing of the install on those sites improved the install code with more checking of existing settings.

peterx’s picture

PAReview still incorrectly reports an error. Apart from the one mistake by PAReview, I cannot find any error. The sites using Cel have no errors. The test pages test every function individually and in sequence without any errors. There are no code problems with PHP 5.3. The code works with Drupal from 7.9 through to 7.14. The memory usage is microscopic compared to traditional Drupal code. Several sites are now waiting on the module because their policy is to only use formally released drupal.org code.

klausi’s picture

Priority: Critical » Normal
Status: Needs review » Needs work
Issue tags: +PAreview: security
FileSize
12.52 KB

Sorry for the delay, but you have not listed any reviews of other project applications in your issue summary as strongly recommended in the application documentation.

There is still a master branch, make sure to set the correct default branch: http://drupal.org/node/1659588 . Then remove the master branch, see also step 6 and 7 in http://drupal.org/node/1127732
Review of the 7.x-1.x branch:

  • Remove "version" from the info file, it will be added by drupal.org packaging automatically.
  • Drupal Code Sniffer has found some issues with your code (please check the Drupal coding standards). See attachment.

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.

manual review:

  1. cel_module_name(): that should be a constant, not a function.
  2. cel_module_name(): link in the doc block is dead. Please add all your function documentation inline in code, you can generate HTML for your pages with doxygen, and possibly with the API module.
  3. cel_block_view(): What about node access modules here? You should check if the user has access to that node before displaying it so that node access grant modules stay intact. See http://api.drupal.org/api/drupal/modules!node!node.module/group/node_acc...
  4. cel_block_view(): this is vulnerable to XSS exploits. If I enter <script>alert('XSS');</script> as Cel content then I get a nasty javascript popup when the block is displayed. Anyone with the "Cel: Create new content" permission (or similar) can inject potentially malicious script stuff. See http://drupal.org/node/28984
  5. /admin/config/system/cel: Fatal error: Call to undefined function cel_list() in cel.admin.list.php on line 33
peterx’s picture

Class renamed to bumpy case. Master branch removed. Version removed. Working through other code format changes.

klausi’s picture

You need to set the status to "needs review" if you want to get a review.

Don't forget to add the "PAReview: review bonus" tag as indicated in #1410826: [META] Review bonus, otherwise you will not show up on my high priority list.

And please add all your reviews to the issue summary.

peterx’s picture

Status: Needs work » Needs review
Issue tags: -PAreview: security +PAreview: review bonus

PAReviewed down to one message, a message that does not apply because the constructor has the correct __construct() name.
ERROR | PHP4 style constructors are not allowed; use "__construct()"
| | instead

klausi’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus +PAreview: security

Please don't remove the security tag, we keep that for statistics and to show examples of security problems.

manual review:

  1. cel.class.php: coder_sniffer complains because you have a method cel() which has the same name as the class. Better rename it to avoid any confusion.
  2. cel_token_info(): "t($name),": do not pass variables to t() where possible, because that cannot be found by automtic translation extraction tools.
  3. cel.class.php: Please add all your function documentation inline in code, you can generate HTML for your pages with doxygen, and possibly with the API module.
  4. Fatal error: Call to undefined function cel_list() in cel.admin.list.php on line 29

Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

peterx’s picture

Status: Needs work » Needs review

method cel(): This is basic to all versions of the code, including the Drupal version, across all applications and Web sites. If changing this is a requirement, I will go back to using the original cel code from a library.

t($name): Strings changed to t('...@name...', array('@name' => $name)).

Please add all your function documentation inline in code, you can generate HTML for your pages with doxygen:
Doxygen does not handle images and all the things you put into documentation. Doxygen is a 1980s approach, not a Web approach. The rest of the documentation already exists in other forms and will going online, not locked into code.

peterx’s picture

Issue tags: -PAreview: security

What is the PAReview: security tag for? There are no security issues. A cel is content. If having content in a Web site is a security issue, all nodes have to be banned.

klausi’s picture

Status: Needs review » Needs work
Issue tags: +PAreview: security

Sorry for the delay. Make sure to review more project applications and get a new review bonus and this will get finished faster.

manual review:

  1. The Drupal way of documenting things is inline with doxygen in the code. If you decide to leave the project and shut down your documentation site then the docs are basically gone. Therefore the best practice is to have a lot of documentation with the code and additional documentation pages on drupal.org.
  2. cel_admin_list_cels(): all user facing text must run through t() for translation, for example the words in the table header.
  3. cel_admin_list_cels(): this is vulnerable to XSS exploits. If I enter <script>alert('XSS');</script> as Cel node title a get a nasty javascript popup at admin/config/system/cel_admin. You need to sanitize user provided text before printing, please read http://drupal.org/node/28984 again.
  4. cel.admin.list.php: why is this file still needed?

The security issue is of course a blocker. The tag is used for statistics and to show examples of security problems.

peterx’s picture

peterx’s picture

cel.admin.list.php removed. Left over from before the creation of the admin module.
Cel admin is now a separate project because most sites will not need it.

The documentation pages will be moved to drupal.org pages when the module is published. Drupal.org does not allow child pages off the sandbox page. I have not found an example of a sandbox project documented in the documentation section of drupal.org.

peterx’s picture

Issue summary: View changes

Added list of done reviews.

peterx’s picture

Status: Needs work » Needs review

Pareview does not show any errors in the code. It lists only the incorrect message about PHP4 constructors. The security tag is no longer relevant because the questioned code is in a separate project.

robinvdvleuten’s picture

Status: Needs review » Needs work

Automated Review:
You say that there is only an issue here about a PHP4 constructor. The minimum PHP version of Drupal is 5.2.5 (http://drupal.org/requirements) so why do you have PHP4 style coding here?

Manual Review:

  • Why do you have a function that returns the module's name? It seems very obvious that this always would be 'cel'.
  • The names of your class files in the .info file doesn't have to contain quotes.
  • In the overview page of content_types, the url to the documentation is rendered as plain text.
  • What's the purpose of this module? I've created a new cel content item and nothing seems to happen there. Maybe you can give a better explanation in the module itself, instead of just pointing to an url.
  • Why do you create a new content_type? Isn't it better to make use of the entity api?
peterx’s picture

@robinvdvleuten, thank you for the review.

Re PHP4 code. I do not have PHP code, it is a mistake in Pareview. I have a PHP5 constructor, __construct(), then I have a function with a name that might be interpreted as a constructor in PHP4. Pareview should be updated for PHP5, look for __construct(), then skip the PHP4 constructor check.

Re function returning the module's name. I write many modules in a way where the code can be reused by other modules. Cel could be reused by someone creating a different templating system. For that reason I place data, including names and identifiers, in one place where the programmer can make one change in the copied code. For classes, I often accept the data from outside so other modules can reuse the class without changing the code.

I will remove the quotes from the .info file. Just a habit from the early days of .ini files.

I will look at the URL. I will move the documentation to Drupal.org when the module is published, which will change all the URLs.

The purpose of the module? It is the base for other modules performing templating. It is packaged in many sites with something else to provide specific templating for mail and other uses. There are now so many add-ons for Cel that I separated them out so people can load exactly what they need and nothing else. Cel twig uses Cel and Twig7 to provide twig based templating. There is a module to use Cel twig for mail templating. There was an admin module packaged with Cel to you can administer all the different cels for the different modules then I moved it to a separate project because most sites using cels administer cels through the content pages or the module using the cels.

Re new content type. Templates are content to editors. The node containing the cel documents the cel. You can use the content body to document the template. You can use comments for feedback. The node is left user modifiable so you can add your own identifiers and classifications. You can use other modules, including Workbench, with cels.

I would like to change the code, readme, and documentation now that I have moved the admin module out to a different project but there is a new release already out among the sites using Cel. I do not see the sense in making minor changes to the version in the sandbox when everyone will be using the new version before the old version is published. Submitting the new version also creates a problem, the new version will go back to waiting for review until after it is obsolete.

ain’s picture

Automated review

FILE: /var/www/drupal-7-pareview/pareview_temp/cel.class.php
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
45 | ERROR | PHP4 style constructors are not allowed; use "__construct()"
| | instead
--------------------------------------------------------------------------------
  • The problem here is surely PAReview-related, but as these kind of things usually appear given exceptional circumstances, I looked into your code and found that your class name is Cel whilst you also have a protected property called cel. This overlap is the cause of this behaviour. Whilst it's not entirely incorrect, it's still bad practice. Code should always be readable and without even digging into the code, question is what is what? The class is Cel and the property is also cel? Please consider a better naming convention.

Manual review

  1. Inline Doxygen documentation is missing for all classes (properties, methods). See http://drupal.org/node/1354#classes for the standard. Links to external documentation could still remain as an addition.
  2. Log messages should not be translated (e.g. cel_log() ln 28) and should not be open to mutations over the translations.
  3. No proper documentation in cel.module, e.g. @param, @return missing for cel_tokens_cel()
  4. Instead of // Why custom? Document. use standard TODO, FIXME or XXX comments, e.g. // TODO: document or @todo … in function doc.
  5. Remove useless comments, e.g. cel.install ln 17-19. It's much more effective to push some parts into a ticket, discussion, blog post.

Recommendations

  1. You are using a getter and setter in one go, e.g. in Cel::cel(). Maybe it's not a problem in the circumstances, but how do I set a property to null? It's a good practice to use getSomething() and setSomething(), robustly.
  2. Write self-explanatory code. I'd always prefer getLastItemOfDataCollection() to last() which often says absolutely nothing.
PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.

I'm a robot and this is an automated message from Project Applications Scraper.

PA robot’s picture

Issue summary: View changes

Update of reviews list.

apaderno’s picture

Title: Cel » [D7] Cel