Exemplo n.º 1
0
 function validateProperty($property)
 {
     $data = array();
     $Validation = new ThemeValidation();
     foreach ($property as $name => $value) {
         $unit = 'px';
         if (is_array($value)) {
             if (isset($value['unit'])) {
                 $unit = $value['unit'];
             }
             if (isset($value['value'])) {
                 $value = $value['value'];
             }
         }
         switch ($name) {
             case 'left':
             case 'width':
             case 'height':
             case 'font-size':
             case 'padding-top':
             case 'padding-left':
             case 'padding-right':
             case 'padding-bottom':
             case 'border-width':
                 if ($Validation->isNumber($value, 0, 9999)) {
                     $data[$name] = $value . $unit;
                 }
                 break;
             case 'top':
             case 'margin-top':
             case 'margin-left':
             case 'margin-right':
             case 'margin-bottom':
                 if ($Validation->isNumber($value, -9999, 9999)) {
                     $data[$name] = $value . $unit;
                 }
                 break;
             case 'color':
             case 'border-color':
             case 'border-top-color':
             case 'border-right-color':
             case 'border-bottom-color':
             case 'border-left-color':
             case 'outline-color':
             case 'background-color':
                 $value = ThemeColor::getColor($value);
                 if ($Validation->isNotEmpty($value)) {
                     $data[$name] = $value;
                 }
                 break;
             case 'font-family':
                 foreach ((array) $value as $family) {
                     if ($Validation->isNotEmpty($family)) {
                         ThemeHelper::removeUIndex($data, $name);
                         if ($Validation->isNotEmpty($data[$name])) {
                             $data[$name] .= ',';
                         }
                         $data[$name] .= '\'' . $family . '\'';
                     }
                 }
                 break;
             case 'font-style':
                 if (isset($this->fontStyle[$value])) {
                     $data[$name] = $value;
                 }
                 break;
             case 'font-weight':
                 if (isset($this->fontWeight[$value])) {
                     $data[$name] = $value;
                 }
                 break;
             case 'display':
             case 'border-style':
             case 'line-height':
             case 'background':
             case 'background-repeat':
             case 'background-position':
                 if ($Validation->isNotEmpty($value)) {
                     $data[$name] = $value;
                 }
                 break;
             case 'background-image':
                 if ($Validation->isNotEmpty($value)) {
                     $data[$name] = 'url(\'' . $value . '\',THEME_CONTEXT)';
                 }
                 break;
         }
     }
     return $data;
 }