Beispiel #1
0
 function validateProperty($property)
 {
     $data = array();
     $Validation = new TSValidation();
     foreach ($property as $name => $value) {
         switch ($name) {
             case 'color':
             case 'border-color':
             case 'outline-color':
             case 'background-color':
             case 'border-top-color':
             case 'border-right-color':
             case 'border-bottom-color':
             case 'border-left-color':
                 $value = TSColor::getColor($value);
                 if ($value !== false) {
                     $data[$name] = $value;
                 }
                 break;
             case 'outline-width':
             case 'border-width':
             case 'padding-top':
             case 'padding-right':
             case 'padding-bottom':
             case 'padding-left':
             case 'border-top-width':
             case 'border-right-width':
             case 'border-bottom-width':
             case 'border-left-width':
                 if ($Validation->isNumber($value, 0, 9999)) {
                     $data[$name] = $value . 'px';
                 }
                 break;
             case 'border-style':
             case 'outline-style':
             case 'border-top-style':
             case 'border-right-style':
             case 'border-bottom-style':
             case 'border-left-style':
                 $data[$name] = $value;
                 break;
         }
     }
     return $data;
 }
 static function getColor($color)
 {
     $Validation = new TSValidation();
     if (!$Validation->isColor($color, false)) {
         return false;
     }
     if ($color === 'transparent') {
         return $color;
     }
     $length = strlen($color);
     if ($length == 6) {
         return '#' . $color;
     }
     if ($length == 8) {
         return self::HEX2RGBA($color);
     }
     return false;
 }
 function createCSSFile()
 {
     global $ts_rule;
     $Validation = new TSValidation();
     if (!is_array($ts_rule)) {
         return false;
     }
     $content = null;
     $CSS = new TSCSS();
     foreach ($ts_rule['panel'] as $panelData) {
         foreach ($panelData as $panelSection) {
             foreach ($panelSection['field'] as $panelField) {
                 $property = array();
                 $value = TSOption::getOption($panelField['id']);
                 $property[$panelField['type']] = $value;
                 if ($Validation->isNotEmpty($value)) {
                     if (array_key_exists('additionalRule', $panelField)) {
                         $property = $property + $panelField['additionalRule'];
                     }
                 }
                 if (count($panelField['selector'])) {
                     $content .= $CSS->create(array('selector' => $panelField['selector'], 'property' => $property));
                 }
                 if (array_key_exists('customCSS', $panelField)) {
                     $content .= preg_replace('/__VALUE__/', TSColor::getColor(TSOption::getOption($panelField['id'])), $panelField['customCSS']);
                 }
             }
         }
     }
     $file = TSData::get('theme_path_multiste_site_style') . 'TS.Frontend.css';
     @chmod($file, 0755);
     if (file_put_contents($file, $content) === false) {
         return false;
     }
     return true;
 }