/** * @param string $txt * @return string */ private static function translate($txt) { if (strstr($txt, 'translate:')) { $matches = array(); preg_match('/translate\\:\\[(.*)\\]/', $txt, $matches); $txt = str_replace($matches[0], Sobi::Txt($matches[1]), $txt); } return Sobi::Clean($txt); }
/** * * @param mixed $attr * @param int $index * @return mixed */ public function &get($attr, $index = -1) { $r = null; if (strstr($attr, '.')) { $properties = explode('.', $attr); } else { $properties[0] = $attr; } if (isset($this->_attr[$properties[0]])) { $var = null; /* if array field */ if ($index > -1) { if (is_array($this->_attr[$properties[0]]) && isset($this->_attr[$properties[0]][trim($index)])) { $var = $this->_attr[$properties[0]][trim($index)]; } else { Sobi::Error($this->name(), SPLang::e('ATTR_DOES_NOT_EXISTS', $attr), SPC::NOTICE, 0, __LINE__, __FILE__); } } else { $var = $this->_attr[$properties[0]]; } /* remove first field of properties */ array_shift($properties); /* if there are still fields in array, accessing object attribute or array field */ if (is_array($properties) && count($properties)) { foreach ($properties as $property) { $property = trim($property); /* it has to be SPObject subclass to access the attribute */ if (method_exists($var, 'has') && $var->has($property)) { if (method_exists($var, 'get')) { $var = $var->get($property); } else { /*@TODO need to create error object */ $r = ''; return $r; } } elseif (is_array($var)) { $var = $var[$property]; } else { /* nothing to show */ Sobi::Error($this->name(), SPLang::e('NO_PROPERTY_TO_SHOW', $attr), SPC::NOTICE, 0, __LINE__, __FILE__); /*@TODO need to create error object */ $r = ''; return $r; } } } $r = $var; } else { $r = null; } $r = is_string($r) ? Sobi::Clean($r) : $r; return $r; }
/** * */ public function ProxyDependency() { $path = json_decode(Sobi::Clean(SPRequest::string('path')), true); $values = $this->loadDependencyDefinition($path); SPFactory::mainframe()->cleanBuffer()->customHeader(); exit(json_encode(array('options' => $values, 'path' => json_encode($path)))); }