Файл: concrete5.7.5.6/concrete/src/StyleCustomizer/Style/Style.php
Строк: 77
<?php
namespace ConcreteCoreStyleCustomizerStyle;
use Environment;
abstract class Style
{
protected $variable;
protected $name;
abstract public function render($value = false);
abstract public function getValuesFromVariables($rules = array());
abstract public function getValueFromRequest(SymfonyComponentHttpFoundationParameterBag $request);
public function getValueFromList(ConcreteCoreStyleCustomizerStyleValueList $list)
{
$type = static::getTypeFromClass($this);
foreach($list->getValues() as $value) {
if ($value->getVariable() == $this->getVariable() && $type == static::getTypeFromClass($value, 'Value')) {
return $value;
}
}
}
protected static function getTypeFromClass($class, $suffix = 'Style')
{
$class = get_class($class);
$class = substr($class, strrpos($class, '\') + 1);
$type = uncamelcase(substr($class, 0, strrpos($class, $suffix)));
return $type;
}
public function setName($name)
{
$this->name = $name;
}
public function getName()
{
return $this->name;
}
/** Returns the display name for this style (localized and escaped accordingly to $format)
* @param string $format = 'html'
* Escape the result in html format (if $format is 'html').
* If $format is 'text' or any other value, the display name won't be escaped.
* @return string
*/
public function getDisplayName($format = 'html')
{
$value = tc('StyleName', $this->getName());
switch($format) {
case 'html':
return h($value);
case 'text':
default:
return $value;
}
}
public function setVariable($variable)
{
$this->variable = $variable;
}
public function getVariable()
{
return $this->variable;
}
/**
* Returns a path to an elements directory for this Style. Might not be used by all styles.
* @return string
*/
public function getFormElementPath()
{
$className = join('', array_slice(explode('\', get_called_class()), -1));
$segment = substr($className, 0, strpos($className, 'Style'));
$element = uncamelcase($segment);
$env = Environment::get();
return $env->getPath(DIRNAME_ELEMENTS . '/' . DIRNAME_STYLE_CUSTOMIZER . '/' . DIRNAME_STYLE_CUSTOMIZER_TYPES . '/' . $element . '.php');
}
}