本文整理汇总了PHP中SPRequest::word方法的典型用法代码示例。如果您正苦于以下问题:PHP SPRequest::word方法的具体用法?PHP SPRequest::word怎么用?PHP SPRequest::word使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPRequest
的用法示例。
在下文中一共展示了SPRequest::word方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cloneTpl
private function cloneTpl()
{
$dir = $this->dir(SPRequest::cmd('templateName'));
$newName = SPRequest::word('templateNewName', 'Duplicated Template', 'post');
$dirName = SPLang::nid($newName);
$dirNameOrg = $dirName;
$c = 1;
while (SPFs::exists(SPLoader::dirPath('usr.templates.' . $dirName, 'front', false))) {
$dirName = $dirNameOrg . '-' . $c++;
}
$newPath = SPLoader::dirPath('usr.templates.' . $dirName, 'front', false);
if (!SPFs::copy($dir, $newPath)) {
throw new SPException(SPLang::e('COULD_NOT_COPY_DIRECTORY', $dir, $newPath));
}
$defFile = SPLoader::path($newPath . '.template', 'absolute', true, 'xml');
if ($defFile) {
$fc = SPLoader::loadClass('base.fs.file');
$def = new DOMDocument();
$def->load($defFile);
$xdef = new DOMXPath($def);
$oldName = $xdef->query('/template/name')->item(0)->nodeValue;
$oldDesc = $xdef->query('/template/description')->item(0)->nodeValue;
$date = SPFactory::config()->date(time());
$xdef->query('/template/name')->item(0)->nodeValue = $newName;
$xdef->query('/template/creationDate')->item(0)->nodeValue = $date;
$xdef->query('/template/id')->item(0)->nodeValue = $dirName;
$newDesc = Sobi::Txt('TP.CLONE_NOTE', array('name' => $oldName, 'date' => $date));
$xdef->query('/template/description')->item(0)->nodeValue = "{$newDesc}\n{$oldDesc}";
$file = new $fc($defFile);
$file->content($def->saveXML());
$file->save();
}
$this->response(Sobi::Url(array('task' => 'template.info', 'template' => str_replace(SOBI_PATH . DS . 'usr' . DS . 'templates' . DS, null, $dirName))), Sobi::Txt('TP.DUPLICATED'), false, 'success');
}
示例2: validate
/**
* @param SPEntry $entry
* @param string $request
* @return string
*/
public function validate($entry, $request)
{
/** it can be for core files only at the moment because a stupid developer (yes, we all know which one) declared too many private methods and inherited classes returning always wrong results */
$class = strtolower(get_class($this));
if (strstr($class, 'select') || strstr($class, 'radio') || strstr($class, 'chbxgr')) {
return $this->verify($entry, $request, $this->fetchData($this->multi ? SPRequest::arr($this->nid, array(), $request) : SPRequest::word($this->nid, null, $request)));
} else {
return true;
}
}
示例3: verify
/**
* @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;
}
示例4: registerRepo
private function registerRepo()
{
$repo = trim(preg_replace('/[^a-zA-Z0-9\\.\\-\\_]/', null, SPRequest::string('repository')));
$data = SPRequest::arr('RepositoryResponse');
$answer = array();
if (count($data)) {
foreach ($data as $k => $v) {
$v = strlen($v) && $v != '' ? $v : SPC::NO_VALUE;
$answer[$k] = $v;
}
}
$defFile = SPLoader::path("etc.repos.{$repo}.repository", 'front', true, 'xml');
$repository = SPFactory::Instance('services.installers.repository');
$repository->loadDefinition($defFile);
try {
$repository->connect();
} catch (SPException $x) {
$this->ajaxResponse(true, SPLang::e('REPO_ERR', $x->getMessage()), Sobi::Url('extensions.browse'), SPC::ERROR_MSG);
}
$callback = SPRequest::word('callback');
$response = call_user_func_array(array($repository, $callback), $answer);
if (is_array($response) && isset($response['callback'])) {
return $this->parseSoapRequest($response, $repo);
} elseif ($response === true || isset($response['welcome_msg'])) {
SPFactory::mainframe()->cleanBuffer()->customHeader();
if (isset($response['token'])) {
$repository->saveToken($response['token']);
}
if (isset($response['welcome_msg']) && $response['welcome_msg']) {
echo json_encode(array('message' => array('type' => SPC::SUCCESS_MSG, 'response' => $response['welcome_msg']), 'callback' => null, 'redirect' => true));
} else {
echo json_encode(array('message' => array('type' => SPC::SUCCESS_MSG, 'response' => Sobi::Txt('EX.REPO_HAS_BEEN_ADDED', array('location' => $repo))), 'callback' => null, 'redirect' => true));
}
exit;
} else {
if (isset($response['error'])) {
$this->ajaxResponse(true, SPLang::e('REPO_ERR', $response['msg']), Sobi::Url('extensions.browse'), SPC::ERROR_MSG, false);
} else {
$this->ajaxResponse(true, SPLang::e('UNKNOWN_ERR'), Sobi::Url('extensions.browse'), SPC::ERROR_MSG, false);
}
}
}
示例5: chooser
/**
* Show category chooser
*
*/
protected function chooser($menu = false)
{
$out = SPRequest::cmd('out', null);
$exp = SPRequest::int('expand', 0);
$multi = SPRequest::int('multiple', 0);
$tpl = SPRequest::word('treetpl', null);
/* load the SigsiuTree class */
$tree = SPLoader::loadClass('mlo.tree');
$ordering = defined('SOBI_ADM_PATH') ? Sobi::GetUserState('categories.order', 'corder', 'position.asc') : Sobi::Cfg('list.categories_ordering');
/* create new instance */
$tree = new $tree($ordering);
/* set link */
if ($menu) {
$tree->setId('menuTree');
if (defined('SOBIPRO_ADM')) {
$link = Sobi::Url(array('sid' => '{sid}'), false, false, true);
} else {
$link = Sobi::Url(array('sid' => '{sid}'));
}
} else {
$link = "javascript:SP_selectCat( '{sid}' )";
}
$tree->setHref($link);
/* set the task to expand the tree */
$tree->setTask('category.chooser');
/* disable the category which is currently edited - category cannot be within it self */
if (!$multi) {
if (SPRequest::sid() != Sobi::Section()) {
$tree->disable(SPRequest::sid());
}
$tree->setPid(SPRequest::sid());
} else {
$tree->disable(Sobi::Reg('current_section'));
}
/* case we extending existing tree */
if ($out == 'xml' && $exp) {
$pid = SPRequest::int('pid', 0);
$pid = $pid ? $pid : SPRequest::sid();
$tree->setPid($pid);
$tree->disable($pid);
$tree->extend($exp);
} else {
/* init the tree for the current section */
$tree->init(Sobi::Reg('current_section'));
/* load model */
if (!$this->_model) {
$this->setModel(SPLoader::loadModel('category'));
}
/* create new view */
$class = SPLoader::loadView('category');
$view = new $class();
/* assign the task and the tree */
$view->assign($this->_task, 'task');
$view->assign($tree, 'tree');
$view->assign($this->_model, 'category');
/* select template to show */
if ($tpl) {
$view->setTemplate('category.' . $tpl);
} elseif ($multi) {
$view->setTemplate('category.mchooser');
} else {
$view->setTemplate('category.chooser');
}
Sobi::Trigger('Category', 'ChooserView', array(&$view));
$view->chooser();
}
}