本文整理汇总了PHP中url::arg方法的典型用法代码示例。如果您正苦于以下问题:PHP url::arg方法的具体用法?PHP url::arg怎么用?PHP url::arg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类url
的用法示例。
在下文中一共展示了url::arg方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: on_get_search_form
/**
* Вывод поисковой формы.
*/
public static function on_get_search_form(Context $ctx)
{
$output = '';
$url = new url($ctx->get('destination', $ctx->get('from')));
if (null === $url->arg('preset')) {
$types = Node::find(array('class' => 'type', 'published' => 1, 'deleted' => 0, 'name' => $ctx->user->getAccess(ACL::READ)), $ctx->db);
$list = array();
foreach ($types as $type) {
if (!$type->isdictionary) {
$list[$type->name] = $type->title;
}
}
asort($list);
if ('file' == ($type = $ctx->get('type')) and array_key_exists($type, $list)) {
$list = array($type => $type);
}
$tmp = '';
foreach ($list as $k => $v) {
$tmp .= html::em('type', array('name' => $k, 'title' => $v));
}
$output .= html::em('types', $tmp);
}
$tmp = '';
foreach (Node::getSortedList('user', 'fullname', 'id') as $k => $v) {
$tmp .= html::em('user', array('id' => $k, 'name' => $v));
}
$output .= html::em('users', $tmp);
if (null === $url->arg('preset')) {
$tmp = '';
foreach (Node::getSortedList('tag', 'id', 'name') as $k => $v) {
$tmp .= html::em('section', array('id' => $k, 'name' => $v));
}
$output .= html::em('sections', $tmp);
}
return html::em('content', array('name' => 'search', 'query' => self::get_clean_query($url->arg('search')), 'from' => urlencode($ctx->get('from'))), $output);
}
示例2: getAction
private function getAction()
{
$action = isset($this->action) ? $this->action : MCMS_REQUEST_URI;
if ($this->edit) {
$url = new url($action);
if (null !== ($next = $url->arg('destination'))) {
$next = new url($next);
$next->setarg('pending', null);
$next->setarg('created', null);
$destination = $next->string();
$next->setarg('mode', 'edit');
$next->setarg('type', null);
$next->setarg('id', '%ID');
$next->setarg('destination', $destination);
$url->setarg('destination', $next->string());
$action = $url->string();
}
}
return $action;
}
示例3: on_post_sendto
public static function on_post_sendto(Context $ctx)
{
if ($pick = $ctx->post('selected')) {
if (false === strpos($ctx->post('sendto'), '.')) {
list($nid, $fieldName) = array($ctx->post('sendto'), null);
} else {
list($nid, $fieldName) = explode('.', $ctx->post('sendto'));
}
$params = array($fieldName);
$sql = "REPLACE INTO `node__rel` (`tid`, `nid`, `key`) SELECT %ID%, `id`, ? FROM `node` WHERE `deleted` = 0 AND `id` " . sql::in($pick, $params);
$ctx->db->beginTransaction();
$node = Node::load($nid)->knock(ACL::UPDATE);
if (isset($node->{$fieldName})) {
unset($node->{$fieldName});
}
$node->onSave("DELETE FROM `node__rel` WHERE `tid` = %ID% AND `key` = ?", array($fieldName))->onSave($sql, $params)->save();
$ctx->db->commit();
// destiantion сейчас указывает на список, а нам надо
// вернуться на уровень выше.
$url = new url($ctx->get('destination'));
if ($next = $url->arg('destination')) {
$ctx->redirect($next);
}
}
return $ctx->getRedirect();
}
示例4: redirect
/**
* Перенаправление в контексте CMS.
*
* Позволяет перенаправлять используя относительные урлы (относительно папки,
* в которой установлена CMS).
*
* @param mixed $url текст ссылки, массив или объект url.
* @return void
*/
public function redirect($url, $status = 301, Node $node = null)
{
$url1 = new url($url);
if (empty($_GET['__cleanurls'])) {
if (isset($url1->path)) {
$url1->setarg('q', $url1->path);
$url1->path = null;
}
} elseif (!isset($url1->path)) {
$url1->path = $url1->arg('q');
$url1->setarg('q', null);
}
$next = $url1->getAbsolute($this);
if (null !== $node and $node->id) {
if (!$node->published) {
$mode = 'pending';
} elseif ($node->isNew()) {
$mode = 'created';
} else {
$mode = 'updated';
}
$url = new url($next);
$url->setarg('pending', null);
$url->setarg('created', null);
$url->setarg('updated', null);
if ('%ID' == $url->arg('id')) {
$url->setarg('id', $node->id);
} else {
$url->setarg($mode, $node->id);
$url->setarg('type', $node->class);
}
$next = $url->string();
}
$r = new Redirect($next, $status);
$r->send();
}