本文整理汇总了PHP中Uri::build_query_string方法的典型用法代码示例。如果您正苦于以下问题:PHP Uri::build_query_string方法的具体用法?PHP Uri::build_query_string怎么用?PHP Uri::build_query_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Uri
的用法示例。
在下文中一共展示了Uri::build_query_string方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_save
/**
* Either creates or updates a model depending on whether an ID is passed in.
*/
public function action_save($table_name, $id = null, $method = null)
{
// Find class name and metadata etc
$class_name = \Admin::getClassForTable($table_name);
if ($class_name === false) {
return $this->customPageOr404(array($table_name, $method), "type");
}
$can_edit = \CMF\Auth::can('edit', $class_name);
if (!$can_edit) {
return $this->show403('action_singular', array('action' => \Lang::get('admin.verbs.edit'), 'resource' => strtolower($class_name::singular())));
}
$metadata = $class_name::metadata();
$plural = $class_name::plural();
$singular = $class_name::singular();
$list_page_segment = $metadata->table['name'];
if ($metadata->name != $metadata->rootEntityName) {
$rootClass = $metadata->rootEntityName;
$rootMeta = $rootClass::metadata();
$list_page_segment = $rootMeta->table['name'];
}
if (\Input::param('alias', false) !== false) {
$plural = 'Links';
$singular = 'Link';
}
\Admin::setCurrentClass($class_name);
$message = \Lang::get('admin.messages.item_save_success', array('resource' => $singular));
// Find the model, or create a new one if there's no ID
if ($exists = isset($id) && !empty($id)) {
$model = $class_name::find($id);
if (is_null($model)) {
return $this->show404(null, "type");
}
} else {
$model = new $class_name();
$message = \Lang::get('admin.messages.item_create_success', array('resource' => $singular));
}
$create_new = \Input::post('create_new', false) !== false;
$save_and_close = \Input::post('saveAndClose', false) !== false;
$old_url = $model->url;
// Populate the model with posted data
$model->populate(\Input::post());
// Validate the model
if ($model->validate(null, null, array('id', 'pos'))) {
$em = \D::manager();
$em->persist($model);
$em->flush();
if (!$exists && $model->_has_processing_errors) {
// Try populating the model again if we've had errors - they could be to do with unit of work
$model->populate(\Input::post());
$em->persist($model);
$em->flush();
}
// Sync file fields to DB
try {
\CMF\Storage::syncFileFieldsFor($model);
} catch (\Exception $e) {
}
// Do something depending on what mode we're in...
switch (\Input::param('_mode', 'default')) {
// Renders a page with some JS that will close the fancybox popup
case 'inline':
$options = $class_name::options();
$ids = array_keys($options);
$pos = array_search(strval($model->id), $ids);
if ($pos === false) {
$pos = 0;
}
$this->options = $options;
$this->pos = $pos;
$this->model = $model;
$this->className = $metadata->name;
$this->template = 'admin/item/saved-inline.twig';
return;
break;
default:
$qs = \Uri::build_query_string(\Input::get());
if (strlen($qs) > 0) {
$qs = '?' . $qs;
}
\Session::set_flash('main_alert', array('attributes' => array('class' => 'alert-success'), 'msg' => $message));
if ($create_new) {
\Response::redirect("/admin/{$table_name}/create{$qs}", 'location');
}
if ($save_and_close) {
\Response::redirect("/admin/{$list_page_segment}" . $qs, 'location');
}
\Response::redirect("/admin/{$table_name}/" . $model->get('id') . "/edit{$qs}", 'location');
break;
}
}
// If it's come this far, we have a problem. Render out the form with the errors...
$this->actions = $class_name::actions();
$this->form = new ModelForm($metadata, $model);
$this->table_name = $metadata->table['name'];
$this->model = $model;
$this->qs = \Uri::build_query_string(\Input::get());
$this->template = 'admin/item/edit.twig';
//.........这里部分代码省略.........
示例2: test_build_query_string
/**
* Tests Uri::build_query_string()
*
* @test
*/
public function test_build_query_string()
{
$output = Uri::build_query_string(array('varA' => 'varA'), 'varB', array('varC' => 'varC'));
$expected = "varA=varA&varB=1&varC=varC";
$this->assertEquals($expected, $output);
}
示例3:
echo $sort == "priority" || $sort == "" ? "current" : "";
?>
"><a href="?<?php
echo Uri::build_query_string(['sort' => 'priority'], ['area' => $area], ['category' => $category]);
?>
">おすすめ順</a></li>
<li class="<?php
echo $sort == "saleoff" ? "current" : "";
?>
"><a href="?<?php
echo Uri::build_query_string(['sort' => 'saleoff'], ['area' => $area], ['category' => $category]);
?>
">割引順</a></li>
<li class="<?php
echo $sort == "price" ? "current" : "";
?>
"><a href="?<?php
echo Uri::build_query_string(['sort' => 'price'], ['area' => $area], ['category' => $category]);
?>
">売れ行き順</a></li>
<li class="<?php
echo $sort == "sold" ? "current" : "";
?>
"><a href="?<?php
echo Uri::build_query_string(['sort' => 'sold'], ['area' => $area], ['category' => $category]);
?>
">定価の安い順</a></li>
</ul>
</nav>
<!-- /#contentsWrap --></section>
<!--===== Contents End =====-->