Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1061 from tomaszdurka/issue-1061
Browse files Browse the repository at this point in the history
Make CM_Component_Abstract stateless
  • Loading branch information
tomaszdurka committed May 30, 2014
2 parents fe4def4 + ed72743 commit 2386a17
Show file tree
Hide file tree
Showing 184 changed files with 2,296 additions and 1,875 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"phpmailer/phpmailer": "5.2.6",
"michelf/php-markdown": "1.4.0",
"lstrojny/functional-php": "1.0.0-alpha2",
"aws/aws-sdk-php": "~2.6.0"
"aws/aws-sdk-php": "~2.6.0",
"nicmart/tree": "~0.2.0"
},
"require-dev": {
"phpunit/phpunit": "~3.7.10"
Expand Down
12 changes: 6 additions & 6 deletions layout/default/Component/Example/default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@
<div class="tabs-content">
{block name="tabs-content"}
<div>
{componentTemplate file='tabs/example.tpl' foo=$foo now=$now}
{viewTemplate file='tabs/example' foo=$foo now=$now}
</div>
<div>
{code language="html5"}{load file='Component/Example/tabs/menus.tpl' namespace='CM' parse=false}{/code}
{componentTemplate file='tabs/menus.tpl'}
{viewTemplate file='tabs/menus'}
</div>
<div>
{code language="html5"}{load file='Component/Example/tabs/buttons.tpl' namespace='CM' parse=false}{/code}
{componentTemplate file='tabs/buttons.tpl'}
{viewTemplate file='tabs/buttons'}
</div>
<div>
{code language="html5"}{load file='Component/Example/tabs/forms.tpl' namespace='CM' parse=false}{/code}
{componentTemplate file='tabs/forms.tpl'}
{viewTemplate file='tabs/forms'}
</div>
<div>
{componentTemplate file='tabs/variables.tpl' colorStyles=$colorStyles}
{viewTemplate file='tabs/variables' colorStyles=$colorStyles}
</div>
<div>
{componentTemplate file='tabs/icons.tpl' icons=$icons}
{viewTemplate file='tabs/icons' icons=$icons}
</div>
{/block}
</div>
4 changes: 2 additions & 2 deletions layout/default/FormField/Boolean/default.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{tag el="input" name=$name type="hidden" value="0"}
{tag el="input" type="checkbox" id=$id name=$name tabindex=$tabindex value="1" checked=$checked}
<label for="{$id}">{if isset($text)}{$text}{/if}</label>
{tag el="input" type="checkbox" id=$inputId name=$name tabindex=$tabindex value="1" checked=$checked}
<label for="{$inputId}">{$text}</label>
2 changes: 1 addition & 1 deletion layout/default/FormField/Captcha/default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</div>
<div class="captcha-input">
<label for="{$name}">{translate 'Enter Code'}</label>
<input type="text" name="{$name}[value]" id="{$id}" class="textinput" maxlength="6" />
<input type="text" name="{$name}[value]" id="{$inputId}" class="textinput" maxlength="6" />
</div>
<input type="hidden" name="{$name}[id]" value="{$imageId}" />
</div>
2 changes: 1 addition & 1 deletion layout/default/FormField/Color/default.tpl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<input type="color" name="{$name}" id="{$id}" value="{$value}" />
<input type="color" name="{$name}" id="{$inputId}" value="{$value}" />
2 changes: 1 addition & 1 deletion layout/default/FormField/Email/default.tpl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{tag el="input" name=$name id=$id type="email" value=$value class="textinput {$class}" maxlength=$options.lengthMax tabindex=$tabindex placeholder=$placeholder autocorrect=$autocorrect}
{tag el="input" name=$name id=$inputId type="email" value=$value class="textinput {$class}" maxlength=$options.lengthMax tabindex=$tabindex placeholder=$placeholder autocorrect=$autocorrect}
2 changes: 1 addition & 1 deletion layout/default/FormField/File/default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
{/if}
<div class="uploadButton">
<input type="file" name="{$name}-file" multiple />
{if isset($text)}{$text}{else}{block name="button-text"}{translate 'Upload Files'}{/block}{/if}
{if $text}{$text}{else}{block name="button-text"}{translate 'Upload Files'}{/block}{/if}
</div>
<div class="notSupported">*{translate 'Your browser does not support file uploads.'}</div>
2 changes: 1 addition & 1 deletion layout/default/FormField/Hidden/default.tpl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{tag el="input" name=$name id=$id type="hidden" value=$value}
{tag el="input" name=$name id=$inputId type="hidden" value=$value}
2 changes: 1 addition & 1 deletion layout/default/FormField/Integer/default.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<input type="hidden" class="{$class}" name="{$name}" id="{$id}" value="{if isset($value)}{$value}{else}{$options.min}{/if}" />
<input type="hidden" class="{$class}" name="{$name}" id="{$inputId}" value="{if isset($value)}{$value}{else}{$options.min}{/if}" />
<div class="noUiSlider-value">{if isset($value)}{$value}{else}{$options.min}{/if}</div>
<div class="noUiSlider-wrapper">
<div class="noUiSlider"></div>
Expand Down
2 changes: 1 addition & 1 deletion layout/default/FormField/Password/default.tpl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{tag el="input" name=$name id=$id type="password" value=$value class="textinput {$class}" maxlength=$options.lengthMax tabindex=$tabindex placeholder=$placeholder}
{tag el="input" name=$name id=$inputId type="password" value=$value class="textinput {$class}" maxlength=$options.lengthMax tabindex=$tabindex placeholder=$placeholder}
6 changes: 3 additions & 3 deletions layout/default/FormField/Set/default.tpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{$showColumns = $optionList|count > 4}
<ul id="{$id}" class="{$class} {if $showColumns}columns{/if}">
<ul class="{$class} {if $showColumns}columns{/if}">
{foreach $optionList as $itemValue => $itemLabel}
<li class="set-item {$name}-value-{$itemValue} {if $showColumns}column4{/if}">
<input type="checkbox" id="{$id}-{$itemValue}" name="{$name}[]" value="{$itemValue|escape}" {if $value && in_array($itemValue, $value)}checked{/if} />
<label for="{$id}-{$itemValue}" class="{$name}-label-{$itemValue}">
<input type="checkbox" id="{$inputId}-{$itemValue}" name="{$name}[]" value="{$itemValue|escape}" {if $value && in_array($itemValue, $value)}checked{/if} />
<label for="{$inputId}-{$itemValue}" class="{$name}-label-{$itemValue}">
{if $translate}
{translate "{$translatePrefix}{$itemLabel}"|escape}
{else}
Expand Down
8 changes: 4 additions & 4 deletions layout/default/FormField/Set_Select/default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
{/foreach}

{if $display === CM_FormField_Set_Select::DISPLAY_RADIOS}
<ul id="{$id}" class="{$class}">
<ul id="{$inputId}" class="{$class}">
{foreach $optionList as $itemValue => $itemLabel}
<li class="set-item {$name}-value-{$itemValue}">
<input id="{$id}-{$itemValue}" name="{$name}" type="radio" value="{$itemValue|escape}" {if $itemValue==$value}checked{/if} />
<label for="{$id}-{$itemValue}" class="{$name}-label-{$itemValue}">
<input id="{$inputId}-{$itemValue}" name="{$name}" type="radio" value="{$itemValue|escape}" {if $itemValue==$value}checked{/if} />
<label for="{$inputId}-{$itemValue}" class="{$name}-label-{$itemValue}">
{if $translate}
{translate "{$translatePrefix}{$itemLabel}"|escape}
{else}
Expand All @@ -23,5 +23,5 @@
{/if}

{if $display === CM_FormField_Set_Select::DISPLAY_SELECT}
{select id=$id name=$name class=$class optionList=$optionList translate=$translate translatePrefix=$translatePrefix selectedValue=$value placeholder=$placeholder labelPrefix=$labelPrefix}
{select id=$inputId name=$name class=$class optionList=$optionList translate=$translate translatePrefix=$translatePrefix selectedValue=$value placeholder=$placeholder labelPrefix=$labelPrefix}
{/if}
2 changes: 1 addition & 1 deletion layout/default/FormField/Text/default.tpl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{tag el="input" name=$name id=$id type="text" value=$value class="textinput {$class}" maxlength=$options.lengthMax tabindex=$tabindex placeholder=$placeholder autocorrect=$autocorrect autocapitalize=$autocapitalize}
{tag el="input" name=$name id=$inputId type="text" value=$value class="textinput {$class}" maxlength=$options.lengthMax tabindex=$tabindex placeholder=$placeholder autocorrect=$autocorrect autocapitalize=$autocapitalize}
2 changes: 1 addition & 1 deletion layout/default/FormField/Textarea/default.tpl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{tag el="textarea" name=$name id=$id content=$value|escape class="textinput {$class}" maxlength=$options.lengthMax tabindex=$tabindex placeholder=$placeholder}
{tag el="textarea" name=$name id=$inputId content=$value|escape class="textinput {$class}" maxlength=$options.lengthMax tabindex=$tabindex placeholder=$placeholder}
2 changes: 1 addition & 1 deletion layout/default/FormField/TreeSelect/default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</li>
{/function}

{tag el="input" name=$name id=$id type="hidden" value=$value}
{tag el="input" name=$name id=$inputId type="hidden" value=$value}
{button_link icon="arrow-down" iconPosition='right' label={translate 'Select...'} class='selector toggleWindow'}
<ul class="options">
<li class="unselect unselectNode">{translate 'None'}</li>
Expand Down
14 changes: 7 additions & 7 deletions layout/default/Layout/Abstract/default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge; requiresActiveX=true">
{if strlen($pageDescription)}<meta name="description" content="{$pageDescription|escape}">{/if}
{if strlen($pageKeywords)}<meta name="keywords" content="{$pageKeywords|escape}">{/if}
{if isset($pageDescription)}<meta name="description" content="{$pageDescription|escape}">{/if}
{if isset($pageKeywords)}
<meta name="keywords" content="{$pageKeywords|escape}">{/if}
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<meta name="msapplication-TileColor" content="{block name='tileColor'}#ffffff{/block}">
<meta name="msapplication-TileImage" content="{resourceUrl path='img/tileImage.png' type='layout'}">
Expand All @@ -29,13 +30,13 @@
<link rel="apple-touch-startup-image" href="{resourceUrl path='img/apple-touch-startup-image-320x460.png' type='layout'}" media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 1)">

<link rel="shortcut icon" href="{resourceUrl path='img/favicon.ico' type='layout'}">
<title>{$title|escape}</title>
<title>{$pageTitle|escape}</title>
{resourceCss file='all.css' type="vendor"}
{resourceCss file='all.css' type="library"}
{resourceJs file='before-body.js' type="vendor"}
{block name='head'}{/block}
</head>
<body id="{$viewObj->getAutoId()}" class="{$viewObj->getClassHierarchy()|implode:' '}">
<body id="{$autoId}" class="{$layout->getClassHierarchy()|implode:' '}">

{if CM_Request_Abstract::hasInstance() && !CM_Request_Abstract::getInstance()->isSupported()}
<div id="browserNotSupported">
Expand All @@ -48,7 +49,7 @@
{block name='body-start'}{/block}
<div id="body-container">
{block name='body'}
{component name=$viewObj->getPage()}
{$renderAdapter->fetchPage()}
{/block}
</div>
{if CM_Bootloader::getInstance()->isDebug()}{component name='CM_Component_Debug'}{/if}
Expand All @@ -57,8 +58,7 @@
{if $render->getLanguage()}
{resourceJs file="translations/{CM_Model_Language::getVersionJavascript()}.js" type="library"}
{/if}
{$render->getJs()->renderScripts()}
{$render->getJs()->getTracking()->getHtml($render->getSite())}
{$render->getGlobalResponse()->getHtml($render)}
{block name='body-end'}{/block}
</body>
</html>
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion library/CM/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function fillCaches() {
$assetList[] = new CM_Asset_Javascript_VendorAfterBody($site);
$assetList[] = new CM_Asset_Javascript_VendorBeforeBody($site);
foreach ($languageList as $language) {
$render = new CM_Render($site, null, $language);
$render = new CM_Frontend_Render($site, null, $language);
$assetList[] = new CM_Asset_Css_Vendor($render);
$assetList[] = new CM_Asset_Css_Library($render);
}
Expand Down
10 changes: 5 additions & 5 deletions library/CM/Asset/Css.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class CM_Asset_Css extends CM_Asset_Abstract {

/** @var CM_Render */
/** @var CM_Frontend_Render */
protected $_render;

/** @var string|null */
Expand All @@ -15,11 +15,11 @@ class CM_Asset_Css extends CM_Asset_Abstract {
private $_children = array();

/**
* @param CM_Render $render
* @param CM_Frontend_Render $render
* @param string|null $content
* @param string|null $prefix
*/
public function __construct(CM_Render $render, $content = null, $prefix = null) {
public function __construct(CM_Frontend_Render $render, $content = null, $prefix = null) {
$this->_render = $render;
if (null !== $content) {
$this->_content = (string) $content;
Expand Down Expand Up @@ -79,12 +79,12 @@ private function _compile($content, $compress = null) {
if (false === ($contentTransformed = $cache->get($cacheKey))) {
$lessCompiler = new lessc();
$lessCompiler->registerFunction('image', function ($arg) use ($render) {
/** @var CM_Render $render */
/** @var CM_Frontend_Render $render */
list($type, $delimiter, $values) = $arg;
return array('function', 'url', array('string', $delimiter, array($render->getUrlResource('layout', 'img/' . $values[0]))));
});
$lessCompiler->registerFunction('urlFont', function ($arg) use ($render) {
/** @var CM_Render $render */
/** @var CM_Frontend_Render $render */
list($type, $delimiter, $values) = $arg;
return array($type, $delimiter, array($render->getUrlStatic('/font/' . $values[0])));
});
Expand Down
4 changes: 2 additions & 2 deletions library/CM/Asset/Css/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
class CM_Asset_Css_Library extends CM_Asset_Css {

/**
* @param CM_Render $render
* @param CM_Frontend_Render $render
* @throws CM_Exception
*/
public function __construct(CM_Render $render) {
public function __construct(CM_Frontend_Render $render) {
parent::__construct($render);

foreach (array_reverse($render->getSite()->getNamespaces()) as $namespace) {
Expand Down
2 changes: 1 addition & 1 deletion library/CM/Asset/Css/Vendor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class CM_Asset_Css_Vendor extends CM_Asset_Css {

public function __construct(CM_Render $render) {
public function __construct(CM_Frontend_Render $render) {
parent::__construct($render);
$extensions = array('css', 'less');
foreach (array_reverse($render->getSite()->getNamespaces()) as $namespace) {
Expand Down
4 changes: 2 additions & 2 deletions library/CM/Asset/Css/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
class CM_Asset_Css_View extends CM_Asset_Css {

/**
* @param CM_Render $render
* @param CM_Frontend_Render $render
* @param string $className
* @throws CM_Exception
*/
public function __construct(CM_Render $render, $className) {
public function __construct(CM_Frontend_Render $render, $className) {
parent::__construct($render);
if (!preg_match('#^([^_]+)_([^_]+)_?(.*)$#', $className, $matches)) {
throw new CM_Exception('Cannot detect all className parts from view\'s classNname `' . $className . '`');
Expand Down
2 changes: 1 addition & 1 deletion library/CM/Component/Abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var CM_Component_Abstract = CM_View_Abstract.extend({
* @return jqXHR
*/
reload: function(params) {
return this.ajaxModal('reload', params);
return this.ajaxModal('reloadComponent', params);
},

/**
Expand Down
Loading

0 comments on commit 2386a17

Please sign in to comment.