protected function save() { if (!SPFactory::mainframe()->checkToken()) { Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__); } $id = SPRequest::cmd('filter_id'); if ($id) { $this->validate('field.filter', 'filter'); $filters = $this->getFilters(); $name = SPRequest::string('filter_name', 'Filter Name'); $msg = str_replace(array("\n", "\t", "\r"), null, SPLang::clean(SPRequest::string('filter_message', 'The data entered in the $field field contains not allowed characters'))); $regex = SPLang::clean(SPRequest::raw('filter_regex', '/^[\\.*]+$/')); $regex = str_replace('[:apostrophes:]', '\\"' . "\\'", $regex); $regex = base64_encode(str_replace(array("\n", "\t", "\r"), null, $regex)); $custom = 'custom'; if (isset($filters[$id]) && !strlen($filters[$id]['options'])) { $regex = $filters[$id]['params']; $custom = null; } $filters[$id] = array('params' => $regex, 'key' => $id, 'value' => $name, 'description' => $msg, 'options' => $custom); SPFactory::registry()->saveDBSection($filters, 'fields_filter'); $this->response(Sobi::Url('filter'), Sobi::Txt('FLR.MSG_FILTER_SAVED'), false, 'success'); } else { $this->response(Sobi::Url('filter'), SPLang::e('FILTER_NOT_FOUND'), true, SPC::ERROR_MSG); } }
/** * @param SPEntry $entry * @param string $request * @throws SPException * @return array */ protected function verify($entry, $request) { $save = array(); $data = SPRequest::raw($this->nid . '_url', null, $request); $dexs = strlen($data); $data = SPFactory::db()->escape($data); if ($this->ownLabel) { $save['label'] = SPRequest::raw($this->nid, null, $request); /* check if there was a filter */ if ($this->filter && strlen($save['label'])) { $registry =& SPFactory::registry(); $registry->loadDBSection('fields_filter'); $filters = $registry->get('fields_filter'); $filter = isset($filters[$this->filter]) ? $filters[$this->filter] : null; if (!count($filter)) { throw new SPException(SPLang::e('FIELD_FILTER_ERR', $this->filter)); } else { if (!preg_match(base64_decode($filter['params']), $save['label'])) { throw new SPException(str_replace('$field', $this->name, SPLang::e($filter['description']))); } } } } /* check if it was required */ if ($this->required && !$dexs) { throw new SPException(SPLang::e('FIELD_REQUIRED_ERR', $this->name)); } /* check if there was an adminField */ if ($this->adminField && $dexs) { if (!Sobi::Can('adm_fields.edit')) { throw new SPException(SPLang::e('FIELD_NOT_AUTH', $this->name)); } } /* check if it was free */ if (!$this->isFree && $this->fee && $dexs) { SPFactory::payment()->add($this->fee, $this->name, $entry->get('id'), $this->fid); } /* check if it should contains unique data */ if ($this->uniqueData && $dexs) { $matches = $this->searchData($data, Sobi::Reg('current_section')); if (count($matches)) { throw new SPException(SPLang::e('FIELD_NOT_UNIQUE', $this->name)); } } /* check if it was editLimit */ if ($this->editLimit == 0 && !Sobi::Can('entry.adm_fields.edit') && $dexs) { throw new SPException(SPLang::e('FIELD_NOT_AUTH_EXP', $this->name)); } /* check if it was editable */ if (!$this->editable && !Sobi::Can('entry.adm_fields.edit') && $dexs && $entry->get('version') > 1) { throw new SPException(SPLang::e('FIELD_NOT_AUTH_NOT_ED', $this->name)); } /* check the response code */ if ($dexs && $this->validateUrl) { if (preg_match('/[a-z0-9]@[a-z0-9].[a-z]/i', $data)) { $domain = explode('@', $data, 2); $domain = $domain[1]; if (!checkdnsrr($domain, 'MX')) { throw new SPException(SPLang::e('FIELD_MAIL_NO_MX', $data)); } } else { throw new SPException(SPLang::e('FIELD_MAIL_WRONG_FORM', $data)); } } if ($dexs) { /* if we are here, we can save these data */ $save['url'] = $data; } else { $save = null; } $this->setData($save); return $save; }
/** * Creating URL from a array for the current CMS * @param array $var * @param bool $js * @param bool $sef * @param bool $live * @param bool $forceItemId * @return string */ public static function url($var = null, $js = false, $sef = true, $live = false, $forceItemId = false) { $url = self::baseUrl; if ($var == 'current') { return SPRequest::raw('REQUEST_URI', self::baseUrl, 'SERVER'); } // don't remember why :( // Nevertheless it is generating & in URL fro ImEx // $sef = Sobi::Cfg( 'disable_sef_globally', false ) ? false : ( defined( 'SOBIPRO_ADM' ) && !( $forceItemId ) ? false : $sef ); $sef = Sobi::Cfg('disable_sef_globally', false) ? false : $sef; Sobi::Trigger('Create', 'Url', array(&$var, $js)); if (is_array($var) && !empty($var)) { if (isset($var['option'])) { $url = str_replace('com_sobipro', $var['option'], $url); unset($var['option']); } if (isset($var['sid']) && (!defined('SOBIPRO_ADM') || $forceItemId) || defined('SOBIPRO_ADM') && $sef && $live) { if (!isset($var['Itemid']) || !$var['Itemid']) { SPFactory::mainframe()->getItemid($var); } } if (isset($var['title'])) { if (Sobi::Cfg('url.title', true)) { $var['title'] = trim(SPLang::urlSafe($var['title'])); $var['sid'] = $var['sid'] . ':' . $var['title']; } unset($var['title']); } if (isset($var['format']) && $var['format'] == 'raw' && $sef) { unset($var['format']); } foreach ($var as $k => $v) { if ($k == 'out') { switch ($v) { case 'html': $var['tmpl'] = 'component'; unset($var['out']); break; case 'xml': $var['tmpl'] = 'component'; $var['format'] = 'raw'; case 'raw': $var['tmpl'] = 'component'; $var['format'] = 'raw'; break; case 'json': $var['out'] = 'json'; $var['format'] = 'raw'; $var['tmpl'] = 'component'; break; } } } foreach ($var as $k => $v) { $url .= "&{$k}={$v}"; } } elseif (is_string($var)) { if (strstr($var, 'index.php?')) { $url = null; } else { $url .= '&'; } if (strstr($var, '=')) { $var = str_replace('&', '&', $var); $var = str_replace('&', '&', $var); $url .= $var; } else { $url .= SOBI_TASK . '='; $url .= $var; } } elseif (is_array($var)) { } if ($sef && !$live) { $url = JRoute::_($url, false); } else { $url = preg_replace('/&(?![#]?[a-z0-9]+;)/i', '&', $url); } if ($live) { /* * SubDir Issues: * when using SEF Joomla! router returns also the subdir * and JURI::base returns the subdir too * So if the URL should be SEF we have to remove the subdirectory once * Otherwise it doesn't pass the JRoute::_ method so there is no subdir included * */ if ($sef) { $base = JURI::base(true); $root = str_replace($base, null, Sobi::Cfg('live_site')); $url = explode('/', $url); $url = $url[count($url) - 1]; // if ( defined( 'SOBIPRO_ADM' ) ) { // $router = JApplication::getInstance( 'site' )->getRouter(); // $a = $router->build( $url ); // $url = $router->build( $url )->toString(); // } if (!defined('SOBIPRO_ADM')) { $url = JRoute::_($url, false); } $url = Sobi::FixPath("{$root}{$url}"); } else { $adm = defined('SOBIPRO_ADM') ? SOBI_ADM_FOLDER : null; $url = Sobi::FixPath(Sobi::Cfg('live_site') . $adm . '/' . $url); } } $url = str_replace('%3A', ':', $url); // all urls in front are passed to the XML/XSL template are going to be encoded anyway $o = SPRequest::cmd('format', SPRequest::cmd('out')); if (!in_array($o, array('raw', 'xml')) && !defined('SOBI_ADM_PATH')) { $url = html_entity_decode($url); } $url = str_replace(' ', '%20', urldecode($url)); return $js ? str_replace('amp;', null, $url) : $url; }
private function __construct() { $this->client = $this->parse_user_agent(SPRequest::raw('HTTP_USER_AGENT', null, 'server')); }
protected function save($new = false) { if (!SPFactory::mainframe()->checkToken()) { Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__); } $content = SPRequest::raw('file_content', null, 'post'); $file = $this->file(SPRequest::cmd('fileName'), !$new); Sobi::Trigger('Save', $this->name(), array(&$content, &$file)); if (!$file) { throw new SPException(SPLang::e('Missing file to save %s', SPRequest::cmd('fileName'))); } $File = SPFactory::Instance('base.fs.file', $file); $File->content(stripslashes($content)); try { $File->save(); $u = array('task' => 'template.edit', 'file' => SPRequest::cmd('fileName')); if (Sobi::Section()) { $u['sid'] = Sobi::Section(); } $this->response(Sobi::Url($u), Sobi::Txt('TP.FILE_SAVED'), $new, 'success'); } catch (SPException $x) { $this->response(Sobi::Back(), $x->getMessage(), false, 'error'); } }
/** * @param SPEntry $entry * @param SPdb $db * @param string $request * @throws SPException * @return array */ private function verify($entry, &$db, $request) { $save = array(); if ($this->ownLabel) { $save['label'] = SPRequest::raw($this->nid, null, $request); /* check if there was a filter */ if ($this->filter && strlen($save['label'])) { $registry =& SPFactory::registry(); $registry->loadDBSection('fields_filter'); $filters = $registry->get('fields_filter'); $filter = isset($filters[$this->filter]) ? $filters[$this->filter] : null; if (!count($filter)) { throw new SPException(SPLang::e('FIELD_FILTER_ERR', $this->filter)); } else { if (!preg_match(base64_decode($filter['params']), $save['label'])) { throw new SPException(str_replace('$field', $this->name, SPLang::e($filter['description']))); } } } } $data = SPRequest::raw($this->nid . '_url', null, $request); $save['protocol'] = $db->escape(SPRequest::word($this->nid . '_protocol', null, $request)); $dexs = strlen($data); $data = $db->escape($data); $data = preg_replace('/([a-z]{1,5}\\:\\/\\/)/i', null, $data); $save['url'] = $data; /* check if it was required */ if ($this->required && !$dexs) { throw new SPException(SPLang::e('FIELD_REQUIRED_ERR', $this->name)); } /* check if there was an adminField */ if ($this->adminField && $dexs) { if (!Sobi::Can('entry.adm_fields.edit')) { throw new SPException(SPLang::e('FIELD_NOT_AUTH', $this->name)); } } /* check if it was free */ if (!$this->isFree && $this->fee && $dexs) { SPFactory::payment()->add($this->fee, $this->name, $entry->get('id'), $this->fid); } /* check if it should contains unique data */ if ($this->uniqueData && $dexs) { $matches = $this->searchData($data, Sobi::Reg('current_section')); if (count($matches)) { throw new SPException(SPLang::e('FIELD_NOT_UNIQUE', $this->name)); } } /* check if it was editLimit */ if ($this->editLimit == 0 && !Sobi::Can('entry.adm_fields.edit') && $dexs) { throw new SPException(SPLang::e('FIELD_NOT_AUTH_EXP', $this->name)); } /* check if it was editable */ if (!$this->editable && !Sobi::Can('entry.adm_fields.edit') && $dexs && $entry->get('version') > 1) { throw new SPException(SPLang::e('FIELD_NOT_AUTH_NOT_ED', $this->name)); } /* check the response code */ if ($dexs && $this->validateUrl) { $rclass = SPLoader::loadClass('services.remote'); $err = 0; $response = 0; try { $connection = new $rclass(); $connection->setOptions(array('url' => $save['protocol'] . '://' . $data, 'connecttimeout' => 10, 'header' => false, 'returntransfer' => true)); $connection->exec(); $response = $connection->info('response_code'); $err = $connection->error(false); $errTxt = $connection->error(); $connection->close(); if ($err) { Sobi::Error($this->name(), SPLang::e('FIELD_URL_CANNOT_VALIDATE', $errTxt), SPC::WARNING, 0, __LINE__, __FILE__); } } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('FIELD_URL_CANNOT_VALIDATE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } if ($err || $response != 200) { $response = $err ? $errTxt : $response; Sobi::Error($this->name(), SPLang::e('FIELD_URL_ERR', $save['protocol'] . '://' . $data, $response), SPC::WARNING, 0, __LINE__, __FILE__); throw new SPException(SPLang::e('FIELD_URL_ERR', $save['protocol'] . '://' . $data, $response)); } } if (!$dexs) { $save = null; } return $save; }
/** * Shows the field in the search form * @param bool $return return or display directly * @return string */ public function searchForm($return = false) { if ($this->searchMethod == 'general') { return false; } $hidden = null; $d = $this->getValues(false); $data = array('' => Sobi::Txt('FD.SEARCH_SELECT_LIST', array('name' => $this->name))); foreach ($d as $k => $v) { $data[$k] = $v; } $params = array('id' => $this->nid, 'size' => $this->ssize, 'class' => $this->cssClass . ' ' . Sobi::Cfg('search.form_list_def_css', 'SPSearchSelect')); //still there for compatibility reason if ($this->swidth) { $params['style'] = "width: {$this->swidth}px;"; } if ($this->dependency) { SPFactory::header()->addJsFile('opt.field_select'); $request = json_decode(SPLang::clean(SPRequest::raw($this->nid . '_path', null, 'requestcache')), true); $params['class'] .= ' ctrl-dependency-field'; $hidden = $this->travelDependencyPath($request, $params); $this->_selected = isset($request[1]) ? $request[1] : null; $hiddenValue = str_replace('"', "'", json_encode((object) $request)); $hidden .= SPHtml_Input::hidden($this->nid . '_path', $hiddenValue, null, array('data' => array('selected' => '', 'section' => Sobi::Section()))); $params['data'] = array('order' => '1'); } return SPHtml_Input::select($this->nid, $data, $this->_selected, $this->searchMethod == 'mselect', $params) . $hidden; }
/** * @param SPEntry $entry * @param string $request * @throws SPException * @return string */ private function verify($entry, $request) { $data = SPRequest::raw($this->nid, null, $request); $dexs = strlen($data); /* check if it was required */ if ($this->required && !$dexs) { throw new SPException(SPLang::e('FIELD_REQUIRED_ERR', $this->name)); } if ($dexs) { /* check if there was an adminField */ if ($this->adminField) { if (!Sobi::Can('entry.adm_fields.edit')) { throw new SPException(SPLang::e('FIELD_NOT_AUTH', $this->get('name'))); } } /* check if it was free */ if (!$this->isFree && $this->fee) { SPFactory::payment()->add($this->fee, $this->name, $entry->get('id'), $this->fid); } /* check if it was editLimit */ if ($this->editLimit == 0 && !Sobi::Can('entry.adm_fields.edit')) { throw new SPException(SPLang::e('FIELD_NOT_AUTH_EXP', $this->name)); } /* check if it was editable */ if (!$this->editable && !Sobi::Can('entry.adm_fields.edit') && $entry->get('version') > 1) { throw new SPException(SPLang::e('FIELD_NOT_AUTH_NOT_ED', $this->name)); } if ($this->allowHtml) { $checkMethod = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen'; $check = $checkMethod(str_replace(array("\n", "\r", "\t"), null, strip_tags($data))); if ($this->maxLength && $check > $this->maxLength) { throw new SPException(SPLang::e('FIELD_TEXTAREA_LIMIT', $this->maxLength, $this->name, $dexs)); } } else { if ($this->maxLength && $dexs > $this->maxLength) { throw new SPException(SPLang::e('FIELD_TEXTAREA_LIMIT', $this->maxLength, $this->name, $dexs)); } } } $data = SPRequest::string($this->nid, null, true, $request); $this->setData($data); return $data; }
protected function search() { $this->_request = SPRequest::search('field_'); $this->_request['search_for'] = str_replace('*', '%', SPRequest::string('sp_search_for', null)); $this->_request['phrase'] = SPRequest::string('spsearchphrase', Sobi::Cfg('search.form_searchphrase_def', 'all')); $this->_request['phrase'] = strlen($this->_request['phrase']) ? $this->_request['phrase'] : Sobi::Cfg('search.form_searchphrase_def', 'all'); $ssid = SPRequest::cmd('ssid', SPRequest::cmd('ssid', null, 'cookie')); $this->_fields = $this->loadFields(); $searchForString = false; Sobi::Trigger('OnRequest', 'Search', array(&$this->_request)); $searchLimit = Sobi::Cfg('search.result_limit', 1000); for ($i = 1; $i < 11; $i++) { $this->_resultsByPriority[$i] = array(); } // if the visitor wasn't on the search page first if (!$ssid || SPRequest::int('reset', 0)) { $this->session($ssid); } /* clean request */ if (count($this->_request)) { foreach ($this->_request as $i => $v) { if (is_array($v)) { foreach ($v as $index => $value) { $v[$index] = htmlspecialchars_decode($value, ENT_QUOTES); } $this->_request[$i] = SPRequest::cleanArray($v, true); } else { $this->_request[$i] = $this->_db->escape($v); } } } /* sort fields by priority */ usort($this->_fields, array('self', 'sortByPrio')); /* First the basic search ..... */ /* if we have a string to search */ if (strlen($this->_request['search_for']) && $this->_request['search_for'] != Sobi::Txt('SH.SEARCH_FOR_BOX')) { $searchForString = true; $this->_narrowing = true; switch ($this->_request['phrase']) { case 'exact': $this->searchPhrase(); break; default: case 'all': case 'any': $this->searchWords($this->_request['phrase'] == 'all'); break; } $this->_results = array_unique($this->_results); } Sobi::Trigger('AfterBasic', 'Search', array(&$this->_results, &$this->_resultsByPriority)); /* ... now the extended search. Check which data we've received */ if (count($this->_fields)) { $results = null; foreach ($this->_fields as $field) { if (isset($this->_request[$field->get('nid')]) && $this->_request[$field->get('nid')] != null) { $this->_narrowing = true; $fr = $field->searchData($this->_request[$field->get('nid')], Sobi::Section()); $priority = $field->get('priority'); if (is_array($fr)) { $this->_resultsByPriority[$priority] = array_merge($this->_resultsByPriority[$priority], $fr); } /* if we didn't got any results before this array contains the results */ if (!is_array($results)) { $results = $fr; } else { if (is_array($fr)) { $results = array_intersect($results, $fr); } } } } /** Tue, Oct 21, 2014 10:18:37 * No result is also a result so no "count" * */ // if ( is_array( $results ) && count( $results ) ) { if (is_array($results)) { /* if we had also a string to search we have to get the intersection */ if ($searchForString) { $this->_results = array_intersect($this->_results, $results); } else { $this->_results = $results; } } } $this->verify(); /** @since 1.1 - a method to narrow the search results down */ if (count($this->_fields)) { // If we have any results already - the we are limiting results down // if we don't have results but we were already searching then skip - because there is nothing to narrow down // if we don't have results but we weren't searching for anything else - then we are narrowing down everything if (count($this->_results) || !$this->_narrowing) { foreach ($this->_fields as &$field) { $request = isset($this->_request[$field->get('nid')]) ? $this->_request[$field->get('nid')] : null; if ($request) { $field->searchNarrowResults($request, $this->_results, $this->_resultsByPriority); } } } } $this->_request['search_for'] = str_replace('%', '*', $this->_request['search_for']); if (count($this->_results) > $searchLimit) { SPFactory::message()->error(Sobi::Txt('SH.SEARCH_TOO_MANY_RESULTS', count($this->_results), $searchLimit), false); $this->_resultsByPriority = array(); $this->_results = array_slice($this->_results, 0, $searchLimit); } else { $this->sortPriority(); } Sobi::Trigger('AfterExtended', 'Search', array(&$this->_results, &$this->_resultsByPriority)); $req = is_array($this->_request) && count($this->_request) ? SPConfig::serialize($this->_request) : null; $res = is_array($this->_results) && count($this->_results) ? implode(', ', $this->_results) : null; $cre = is_array($this->_categoriesResults) && count($this->_categoriesResults) ? implode(', ', $this->_categoriesResults) : null; /* determine the search parameters */ $attr = array('entriesResults' => array('results' => $res, 'resultsByPriority' => $this->_resultsByPriority), 'catsResults' => $cre, 'uid' => Sobi::My('id'), 'browserData' => SPConfig::serialize(SPBrowser::getInstance())); if (strlen($req)) { $attr['requestData'] = $req; } /* finally save */ try { Sobi::Trigger('OnSave', 'Search', array(&$attr, &$ssid)); $this->_db->update('spdb_search', $attr, array('ssid' => $ssid)); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('CANNOT_CREATE_SESSION_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__); } $url = array('task' => 'search.results', 'sid' => Sobi::Section()); // For Peter's Components Anywhere extension and other $params = Sobi::Cfg('search.params_to_pass'); if (count($params)) { foreach ($params as $param) { $val = SPRequest::raw($param); if ($val) { $url[$param] = SPRequest::raw($param); } } } /* if we cannot transfer the search id in cookie */ if (!SPRequest::cmd('ssid', null, 'cookie')) { $url['ssid'] = $ssid; } if (Sobi::Cfg('cache.unique_search_url')) { $url['t'] = microtime(true); } Sobi::Redirect(Sobi::Url($url)); }
protected function validate($field) { $type = SPRequest::cmd('field_fieldType'); $definition = SPLoader::path('field.' . $type, 'adm', true, 'xml'); if ($definition) { $xdef = new DOMXPath(DOMdocument::load($definition)); $required = $xdef->query('//field[@required="true"]'); if ($required->length) { for ($i = 0; $i < $required->length; $i++) { $node = $required->item($i); $name = $node->attributes->getNamedItem('name')->nodeValue; if (!SPRequest::raw(str_replace('.', '_', $name))) { $this->response(Sobi::Url(array('task' => 'field.edit', 'fid' => $field->get('fid'), 'sid' => SPRequest::sid())), Sobi::Txt('PLEASE_FILL_IN_ALL_REQUIRED_FIELDS'), false, 'error', array('required' => $name)); } } } } }
/** * @param SPEntry $entry * @param string $request * @throws SPException * @return string */ private function verify($entry, $request) { $data = SPRequest::raw($this->nid, null, $request); $dexs = strlen($data); /* check if it was required */ if ($this->required && !$dexs) { throw new SPException(SPLang::e('FIELD_REQUIRED_ERR', $this->name)); } /* check if there was a filter */ if ($this->filter && $dexs) { $registry =& SPFactory::registry(); $registry->loadDBSection('fields_filter'); $filters = $registry->get('fields_filter'); $filter = isset($filters[$this->filter]) ? $filters[$this->filter] : null; if (!count($filter)) { throw new SPException(SPLang::e('FIELD_FILTER_ERR', $this->filter)); } else { if (!preg_match(base64_decode($filter['params']), $data)) { throw new SPException(str_replace('$field', $this->name, SPLang::e($filter['description']))); } } } /* check if there was an adminField */ if ($this->adminField && $dexs) { if (!Sobi::Can('entry.adm_fields.edit')) { throw new SPException(SPLang::e('FIELD_NOT_AUTH', $this->name)); } } /* check if it was free */ if (!$this->isFree && $this->fee && $dexs) { SPFactory::payment()->add($this->fee, $this->name, $entry->get('id'), $this->fid); } /* check if it should contains unique data */ if ($this->uniqueData && $dexs) { $matches = $this->searchData($data, Sobi::Reg('current_section')); if (count($matches) > 1 || count($matches) == 1 && $matches[0] != $entry->get('id')) { throw new SPException(SPLang::e('FIELD_NOT_UNIQUE', $this->name)); } } /* check if it was editLimit */ if ($this->editLimit == 0 && !Sobi::Can('entry.adm_fields.edit') && $dexs) { throw new SPException(SPLang::e('FIELD_NOT_AUTH_EXP', $this->name)); } /* check if it was editable */ if (!$this->editable && !Sobi::Can('entry.adm_fields.edit') && $dexs && $entry->get('version') > 1) { throw new SPException(SPLang::e('FIELD_NOT_AUTH_NOT_ED', $this->name)); } if (!$dexs) { $data = null; } $this->setData($data); return $data; }
/** * @param $xml - path to xml file inside the administrator directory (e.g. field.definitions.filter) * @param $type - object type or array with error url * */ protected function validate($xml, $type) { $definition = SPLoader::path($xml, 'adm', true, 'xml'); if ($definition) { if (is_array($type)) { $errorUrl = Sobi::Url($type); } else { $errorUrl = Sobi::Url(array('task' => $type . '.edit', 'sid' => SPRequest::sid())); } $xdef = new DOMXPath(DOMdocument::load($definition)); $required = $xdef->query('//field[@required="true"]'); if ($required->length) { for ($i = 0; $i < $required->length; $i++) { $node = $required->item($i); $name = $node->attributes->getNamedItem('name')->nodeValue; if (!SPRequest::raw(str_replace('.', '_', $name))) { $this->response($errorUrl, Sobi::Txt('PLEASE_FILL_IN_ALL_REQUIRED_FIELDS'), false, SPC::ERROR_MSG, array('required' => $name)); } } } } }