Example #1
0
 /**
  * Constructor
  */
 function __construct()
 {
     parent::__construct();
     $this->availableProperties = array_merge($this->availableProperties, array('color', 'weight', 'opacity'));
 }
Example #2
0
 public function setProperty($name, $value)
 {
     global $egMultiMaps_CoordinatesSeparator, $egMultiMaps_OptionsSeparator;
     if (strtolower($name) != 'icon') {
         return parent::setProperty($name, $value);
     }
     // Explode icon, it containt 'icon', 'size', 'anchor', 'shadow', 'shSize', 'shAnchor'
     $properties = array_map('trim', explode($egMultiMaps_CoordinatesSeparator, $value));
     // Icon URL
     if (!empty($properties[0])) {
         $v = $properties[0];
         if ($v[0] == '/' && $GLOBALS['egMultiMaps_IconAllowFromDirectory'] === true) {
             if (preg_match('#[^0-9a-zA-Zа-яА-Я/_=\\.\\+\\-]#', $v) || mb_strpos($v, '/../') !== false) {
                 $this->errormessages[] = \wfMessage('multimaps-marker-incorrect-icon-url', $v)->escaped();
                 return false;
             }
             $v = $GLOBALS['wgServer'] . $GLOBALS['egMultiMaps_IconPath'] . $v;
         } else {
             $title = \Title::newFromText($v, NS_FILE);
             if (!is_null($title) && $title->exists()) {
                 $imagePage = new \ImagePage($title);
                 $v = $imagePage->getDisplayedFile()->getURL();
             } else {
                 $this->errormessages[] = \wfMessage('multimaps-marker-incorrect-icon', $v)->escaped();
                 return false;
             }
         }
         $this->properties['icon'] = htmlspecialchars($v, ENT_NOQUOTES);
     }
     // Icon size
     if (!empty($properties[1])) {
         $v = array_map('intval', explode($egMultiMaps_OptionsSeparator, $properties[1]));
         if (count($v) != 2) {
             $this->errormessages[] = \wfMessage('multimaps-marker-incorrect-icon-size', $v, $value)->escaped();
             return false;
         }
         $this->properties['size'] = $v;
     }
     // Icon anchor
     if (!empty($properties[2])) {
         $v = array_map('intval', explode($egMultiMaps_OptionsSeparator, $properties[2]));
         if (count($v) != 2) {
             $this->errormessages[] = \wfMessage('multimaps-marker-incorrect-icon-anchor', $v, $value)->escaped();
             return false;
         }
         $this->properties['anchor'] = $v;
     }
     // Shadow URL
     if (!empty($properties[3])) {
         $v = $properties[3];
         if ($v[0] == '/' && $GLOBALS['egMultiMaps_IconAllowFromDirectory'] === true) {
             if (preg_match('#[^0-9a-zA-Zа-яА-Я./_=\\+\\-]#', $v) || preg_match('#/../#', $v)) {
                 $this->errormessages[] = \wfMessage('multimaps-marker-incorrect-shadow-url', $v)->escaped();
                 return false;
             }
             $v = $GLOBALS['wgServer'] . $GLOBALS['egMultiMaps_IconPath'] . $v;
         } else {
             $title = \Title::newFromText($v, NS_FILE);
             if (!is_null($title) && $title->exists()) {
                 $imagePage = new \ImagePage($title);
                 $v = $imagePage->getDisplayedFile()->getURL();
             } else {
                 $this->errormessages[] = \wfMessage('multimaps-marker-incorrect-shadow-file', $v)->escaped();
                 return false;
             }
         }
         $this->properties['shadow'] = htmlspecialchars($v, ENT_NOQUOTES);
     }
     // Shadow size
     if (!empty($properties[4])) {
         $v = array_map('intval', explode($egMultiMaps_OptionsSeparator, $properties[4]));
         if (count($v) != 2) {
             $this->errormessages[] = \wfMessage('multimaps-marker-incorrect-shadow-size', $v, $value)->escaped();
             return false;
         }
         $this->properties['shSize'] = $v;
     }
     // Shadow anchor
     if (!empty($properties[5])) {
         $v = array_map('intval', explode($egMultiMaps_OptionsSeparator, $properties[5]));
         if (count($v) != 2) {
             $this->errormessages[] = \wfMessage('multimaps-marker-incorrect-shadow-anchor', $v, $value)->escaped();
             return false;
         }
         $this->properties['shAnchor'] = $v;
     }
     return true;
 }