Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added user friendly layout naming #779

Merged
merged 1 commit into from Mar 27, 2016
Merged

Conversation

poocart
Copy link
Contributor

@poocart poocart commented Mar 25, 2016

Removed hardcoded layout name options array from layout select fields in page forms.
Added layout name parsing and page layout select field options array with names in page forms.
Added example layout names in demo themes.

Layout name can be added by adding @Layout name: *chosen name* attribute to layout PHP file. This can either be done with PHP <?php // @Layout name: *chosen name* ?> or HTML <!-- @Layout name: *chosen name* -->. Need to remember that HTML way shows the layout name to public in rendered website DOM.

Layout PHP files with underscore still ignored as being partials like in previous ImpressPages versions.

@maskas maskas merged commit c601bfa into impresspages:develop Mar 27, 2016
$file_contents = file_get_contents($themeDir.$filename);
preg_match_all("(@Layout Name:(.*)\n)siU", $file_contents, $file_layout);
if (isset($file_layout[1]) && isset($file_layout[1][0]) && !empty($file_layout[1][0])) {
$layout_name = preg_replace('/[^a-zA-Z0-9\s]/', '', $file_layout[1][0]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this preg_replace is redundant. I could imagine some russian agency building a custom template for their clients and willing to name the layout in cyrillic. In that case, layout name will become empty. I see no security or other reasons to restrict any characters in layout title. Would you mind if I remove this line?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe restring length and special characters would be better? Now it's whitelisting. Changing to blacklist for php/html safety could be better.

maskas added a commit that referenced this pull request Dec 22, 2016
Added user friendly layout naming
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants