本文整理汇总了PHP中_url函数的典型用法代码示例。如果您正苦于以下问题:PHP _url函数的具体用法?PHP _url怎么用?PHP _url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* render the main layout
*
* @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
*/
public function index()
{
if ($this->hasRequestParameter('openFolder')) {
$folder = $this->getRequestParameter('openFolder');
if (tao_helpers_File::securityCheck($folder, true)) {
$folder = preg_replace('/^\\//', '', $folder);
$folder = preg_replace('/\\/$/', '', $folder);
$this->setData('openFolder', $folder);
}
}
if ($this->hasRequestParameter('urlData')) {
$this->setData('urlData', $this->getRequestParameter('urlData'));
}
if ($this->hasRequestParameter('error')) {
$this->setData('error', $this->getRequestParameter('error'));
}
// Show select action?
$this->setData('showSelect', false);
if ($this->hasRequestParameter('showselect') && $this->getRequestParameter('showselect') == '1') {
$this->setData('showSelect', true);
}
//creates the URL of the action used to configure the client side
$context = Context::getInstance();
$clientConfigParameters = array('extension' => $context->getExtensionName(), 'module' => $context->getModuleName(), 'action' => $context->getActionName());
$this->setData('client_config_url', _url('config', 'ClientConfig', 'tao', $clientConfigParameters));
$this->setData('upload_limit', $this->getFileUploadLimit());
$this->setView('index.tpl');
}
示例2: launch
/**
* Entrypoint of every tool
*/
public function launch()
{
try {
taoLti_models_classes_LtiService::singleton()->startLtiSession(common_http_Request::currentRequest());
// check if cookie has been set
if (tao_models_classes_accessControl_AclProxy::hasAccess('verifyCookie', 'CookieUtils', 'taoLti')) {
$this->redirect(_url('verifyCookie', 'CookieUtils', 'taoLti', array('session' => session_id(), 'redirect' => _url('run', null, null, $_GET))));
} else {
$this->returnError(__('You are not authorized to use this system'));
}
} catch (common_user_auth_AuthFailedException $e) {
common_Logger::i($e->getMessage());
$this->returnError(__('The LTI connection could not be established'), false);
} catch (taoLti_models_classes_LtiException $e) {
// In regard of the IMS LTI standard, we have to show a back button that refer to the
// launch_presentation_return_url url param. So we have to retrieve this parameter before trying to start
// the session
$params = common_http_Request::currentRequest()->getParams();
if (isset($params[taoLti_models_classes_LtiLaunchData::TOOL_CONSUMER_INSTANCE_NAME])) {
$this->setData('consumerLabel', $params[taoLti_models_classes_LtiLaunchData::TOOL_CONSUMER_INSTANCE_NAME]);
} elseif (isset($params[taoLti_models_classes_LtiLaunchData::TOOL_CONSUMER_INSTANCE_DESCRIPTION])) {
$this->setData('consumerLabel', $params[taoLti_models_classes_LtiLaunchData::TOOL_CONSUMER_INSTANCE_DESCRIPTION]);
}
if (isset($params[taoLti_models_classes_LtiLaunchData::LAUNCH_PRESENTATION_RETURN_URL])) {
$this->setData('returnUrl', $params[taoLti_models_classes_LtiLaunchData::LAUNCH_PRESENTATION_RETURN_URL]);
}
common_Logger::i($e->getMessage());
$this->returnError(__('The LTI connection could not be established'), false);
} catch (tao_models_classes_oauth_Exception $e) {
common_Logger::i($e->getMessage());
$this->returnError(__('The LTI connection could not be established'), false);
}
}
示例3: index
/**
* Renders the auhtoring for simple tests
*/
public function index()
{
$test = new \core_kernel_classes_Resource($this->getRequestParameter('uri'));
$model = $this->getServiceManager()->get(TestModel::SERVICE_ID);
$itemSequence = array();
$itemUris = array();
$counter = 1;
foreach ($model->getItems($test) as $item) {
$itemUris[] = $item->getUri();
$itemSequence[$counter] = array('uri' => tao_helpers_Uri::encode($item->getUri()), 'label' => $item->getLabel());
$counter++;
}
// data for item sequence, terrible solution
// @todo implement an ajax request for labels or pass from tree to sequence
$allItems = array();
foreach (\taoTests_models_classes_TestsService::singleton()->getAllItems() as $itemUri => $itemLabel) {
$allItems['item_' . tao_helpers_Uri::encode($itemUri)] = $itemLabel;
}
$config = $model->getConfig($test);
$checked = isset($config['previous']) ? $config['previous'] : false;
$testConfig['previous'] = array('label' => __('Allow test-taker to go back in test'), 'checked' => $checked);
$this->setData('uri', $test->getUri());
$this->setData('allItems', json_encode($allItems));
$this->setData('itemSequence', $itemSequence);
$this->setData('testConfig', $testConfig);
// data for generis tree form
$this->setData('relatedItems', json_encode(tao_helpers_Uri::encodeArray($itemUris)));
$openNodes = TreeHelper::getNodesToOpen($itemUris, new core_kernel_classes_Class(TAO_ITEM_CLASS));
$this->setData('itemRootNode', TAO_ITEM_CLASS);
$this->setData('itemOpenNodes', $openNodes);
$this->setData('saveUrl', _url('saveItems', 'Authoring', 'taoTestLinear'));
$this->setView('Authoring/index.tpl');
}
示例4: processGetTable
public function processGetTable()
{
$ppo = new CopixPPO();
// Si c'est pour de l'ajax
if (CopixRequest::get('url') == null) {
try {
//Recup les données
$id = CopixRequest::get('table_id');
$table = CopixListFactory::get($id);
if (CopixRequest::get('submit') !== 'false') {
$table->getFromRequest();
}
//On génère le HTML
$ppo->MAIN = $table->generateTable();
} catch (Exception $e) {
//En cas d'erreur en etant en ajax, on renvoi l'erreur
$ppo->MAIN = $e->getMessage();
return _arDirectPPO($ppo, 'blank.tpl');
}
return _arDirectPPO($ppo, 'blank.tpl');
//Si c'est pas en ajax
} else {
//On récup les données
$id = CopixRequest::get('table_id');
$table = CopixListFactory::get($id);
if (CopixRequest::get('submit') !== 'false') {
$table->getFromRequest();
}
//Et on redirige
return _arRedirect(_url(CopixRequest::get('url')));
}
}
示例5: testPreserveFormActionAfterAJAX
/**
* Tests that a form's action is retained after an Ajax submission.
*
* The 'action' attribute of a form should not change after an Ajax submission
* followed by a non-Ajax submission, which triggers a validation error.
*/
function testPreserveFormActionAfterAJAX()
{
// Create a multi-valued field for 'page' nodes to use for Ajax testing.
$field_name = 'field_ajax_test';
entity_create('field_storage_config', array('field_name' => $field_name, 'entity_type' => 'node', 'type' => 'text', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED))->save();
entity_create('field_config', array('field_name' => $field_name, 'entity_type' => 'node', 'bundle' => 'page'))->save();
entity_get_form_display('node', 'page', 'default')->setComponent($field_name, array('type' => 'text_textfield'))->save();
// Log in a user who can create 'page' nodes.
$this->web_user = $this->drupalCreateUser(array('create page content'));
$this->drupalLogin($this->web_user);
// Get the form for adding a 'page' node. Submit an "add another item" Ajax
// submission and verify it worked by ensuring the updated page has two text
// field items in the field for which we just added an item.
$this->drupalGet('node/add/page');
$this->drupalPostAjaxForm(NULL, array(), array('field_ajax_test_add_more' => t('Add another item')), 'system/ajax', array(), array(), 'page-node-form');
$this->assert(count($this->xpath('//div[contains(@class, "field-name-field-ajax-test")]//input[@type="text"]')) == 2, 'AJAX submission succeeded.');
// Submit the form with the non-Ajax "Save" button, leaving the title field
// blank to trigger a validation error, and ensure that a validation error
// occurred, because this test is for testing what happens when a form is
// re-rendered without being re-built, which is what happens when there's
// a validation error.
$this->drupalPostForm(NULL, array(), t('Save'));
$this->assertText('Title field is required.', 'Non-AJAX submission correctly triggered a validation error.');
// Ensure that the form contains two items in the multi-valued field, so we
// know we're testing a form that was correctly retrieved from cache.
$this->assert(count($this->xpath('//form[contains(@id, "page-node-form")]//div[contains(@class, "form-item-field-ajax-test")]//input[@type="text"]')) == 2, 'Form retained its state from cache.');
// Ensure that the form's action is correct.
$forms = $this->xpath('//form[contains(@class, "node-page-form")]');
$this->assert(count($forms) == 1 && $forms[0]['action'] == _url('node/add/page'), 'Re-rendered form contains the correct action value.');
}
示例6: testNormalize
/**
* Tests the normalize function.
*/
public function testNormalize()
{
$target_entity_de = entity_create('entity_test', array('langcode' => 'de', 'field_test_entity_reference' => NULL));
$target_entity_de->save();
$target_entity_en = entity_create('entity_test', array('langcode' => 'en', 'field_test_entity_reference' => NULL));
$target_entity_en->save();
// Create a German entity.
$values = array('langcode' => 'de', 'name' => $this->randomMachineName(), 'field_test_text' => array('value' => $this->randomMachineName(), 'format' => 'full_html'), 'field_test_entity_reference' => array('target_id' => $target_entity_de->id()));
// Array of translated values.
$translation_values = array('name' => $this->randomMachineName(), 'field_test_entity_reference' => array('target_id' => $target_entity_en->id()));
$entity = entity_create('entity_test', $values);
$entity->save();
// Add an English value for name and entity reference properties.
$entity->getTranslation('en')->set('name', array(0 => array('value' => $translation_values['name'])));
$entity->getTranslation('en')->set('field_test_entity_reference', array(0 => $translation_values['field_test_entity_reference']));
$entity->save();
$type_uri = _url('rest/type/entity_test/entity_test', array('absolute' => TRUE));
$relation_uri = _url('rest/relation/entity_test/entity_test/field_test_entity_reference', array('absolute' => TRUE));
$expected_array = array('_links' => array('curies' => array(array('href' => '/relations', 'name' => 'site', 'templated' => true)), 'self' => array('href' => $this->getEntityUri($entity)), 'type' => array('href' => $type_uri), $relation_uri => array(array('href' => $this->getEntityUri($target_entity_de), 'lang' => 'de'), array('href' => $this->getEntityUri($target_entity_en), 'lang' => 'en'))), '_embedded' => array($relation_uri => array(array('_links' => array('self' => array('href' => $this->getEntityUri($target_entity_de)), 'type' => array('href' => $type_uri)), 'uuid' => array(array('value' => $target_entity_de->uuid())), 'lang' => 'de'), array('_links' => array('self' => array('href' => $this->getEntityUri($target_entity_en)), 'type' => array('href' => $type_uri)), 'uuid' => array(array('value' => $target_entity_en->uuid())), 'lang' => 'en'))), 'uuid' => array(array('value' => $entity->uuid())), 'langcode' => array(array('value' => 'de')), 'name' => array(array('value' => $values['name'], 'lang' => 'de'), array('value' => $translation_values['name'], 'lang' => 'en')), 'field_test_text' => array(array('value' => $values['field_test_text']['value'], 'format' => $values['field_test_text']['format'])));
$normalized = $this->serializer->normalize($entity, $this->format);
$this->assertEqual($normalized['_links']['self'], $expected_array['_links']['self'], 'self link placed correctly.');
// @todo Test curies.
// @todo Test type.
$this->assertFalse(isset($normalized['id']), 'Internal id is not exposed.');
$this->assertEqual($normalized['uuid'], $expected_array['uuid'], 'Non-translatable fields is normalized.');
$this->assertEqual($normalized['name'], $expected_array['name'], 'Translatable field with multiple language values is normalized.');
$this->assertEqual($normalized['field_test_text'], $expected_array['field_test_text'], 'Field with properties is normalized.');
$this->assertEqual($normalized['_embedded'][$relation_uri], $expected_array['_embedded'][$relation_uri], 'Entity reference field is normalized.');
$this->assertEqual($normalized['_links'][$relation_uri], $expected_array['_links'][$relation_uri], 'Links are added for entity reference field.');
}
示例7: getDirectory
/**
* (non-PHPdoc)
* @see \oat\tao\model\media\MediaBrowser::getDirectory
*/
public function getDirectory($parentLink = '/', $acceptableMime = array(), $depth = 1)
{
$sysPath = $this->getSysPath($parentLink);
$label = substr($parentLink, strrpos($parentLink, '/') + 1);
if (!$label) {
$label = 'local';
}
$data = array('path' => $parentLink, 'label' => $label);
if ($depth > 0) {
$children = array();
if (is_dir($sysPath)) {
foreach (new DirectoryIterator($sysPath) as $fileinfo) {
if (!$fileinfo->isDot()) {
$subPath = rtrim($parentLink, '/') . '/' . $fileinfo->getFilename();
if ($fileinfo->isDir()) {
$children[] = $this->getDirectory($subPath, $acceptableMime, $depth - 1);
} else {
$file = $this->getFileInfo($subPath, $acceptableMime);
if (!is_null($file) && (count($acceptableMime) == 0 || in_array($file['mime'], $acceptableMime))) {
$children[] = $file;
}
}
}
}
} else {
common_Logger::w('"' . $sysPath . '" is not a directory');
}
$data['children'] = $children;
} else {
$data['url'] = _url('files', 'ItemContent', 'taoItems', array('uri' => $this->item->getUri(), 'lang' => $this->lang, 'path' => $parentLink));
}
return $data;
}
示例8: process
public function process($pParams)
{
// paramètres requis
$requestedParameters = array('form', 'submit', 'divErrors', 'urlVerif', 'urlSubmit');
foreach ($requestedParameters as $param) {
if (!isset($pParams[$param])) {
throw new CopixTemplateTagException(_i18n('copix:copix.smarty.badTagParamValue', array('null', $param, 'ajax_submitform')));
}
}
// on a besoin de mootools
_tag('mootools');
// code javascript
$jsCode = '
window.addEvent(\'domready\', function(){
$(\'' . $pParams['submit'] . '\').addEvent(\'click\', function(e) {
$(\'' . $pParams['submit'] . '\').disabled = true;
$(\'' . $pParams['form'] . '\').action = \'' . _url($pParams['urlVerif']) . '\';
new Event (e).stop ();
$(\'' . $pParams['form'] . '\').send ({
update: $(\'formErrors\'),
onComplete: function (response) {
if (response == \'true\') {
$(\'' . $pParams['form'] . '\').action = \'' . _url($pParams['urlSubmit']) . '\';
$(\'' . $pParams['form'] . '\').submit ();
} else {
$(\'' . $pParams['submit'] . '\').disabled = false;
}
},
});
});
});';
CopixHTMLHeader::addJSCode($jsCode, 'ajax_submitform_' . $pParams['form']);
}
示例9: paginate
public static function paginate($paginator, $params, $options = array())
{
$length = 11;
$pager = '<ul>';
if ($paginator->page() == 1) {
$before = 1;
} else {
$before = $paginator->page() - 1;
}
$pager .= '<li><a href="' . _url(array_merge($params, array('page' => $before))) . '">◀</a></li>';
// pages d'avant
$first = max(1, $paginator->page() - floor($length / 2));
$last = min($paginator->pageCount(), $paginator->page() + floor($length / 2));
for ($i = $first; $i < $paginator->page(); $i++) {
$pager .= '<li><a href="' . _url(array_merge($params, array('page' => $i))) . '">' . $i . '</a></li>';
}
$pager .= '<li class="active"><a href="#">' . $paginator->page() . '</a></li>';
for ($i = $paginator->page() + 1; $i <= $last; $i++) {
$pager .= '<li><a href="' . _url(array_merge($params, array('page' => $i))) . '">' . $i . '</a></li>';
}
// after
if ($paginator->page() == $paginator->pageCount()) {
$after = $paginator->page();
} else {
$after = $paginator->page() + 1;
}
$pager .= '<li><a href="' . _url(array_merge($params, array('page' => $after))) . '">▶</a></li>';
$pager .= '</ul>';
return $pager;
}
示例10: testMenus
/**
* Tests the menu functionality.
*/
function testMenus()
{
$this->drupalPlaceBlock('system_menu_block:main');
// Create a view with a page display and a menu link in the Main Menu.
$view = array();
$view['label'] = $this->randomMachineName(16);
$view['id'] = strtolower($this->randomMachineName(16));
$view['description'] = $this->randomMachineName(16);
$view['page[create]'] = 1;
$view['page[title]'] = $this->randomMachineName(16);
$view['page[path]'] = $this->randomMachineName(16);
$view['page[link]'] = 1;
$view['page[link_properties][menu_name]'] = 'main';
$view['page[link_properties][title]'] = $this->randomMachineName(16);
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
// Make sure there is a link to the view from the front page (where we
// expect the main menu to display).
$this->drupalGet('');
$this->assertResponse(200);
$this->assertLink($view['page[link_properties][title]']);
$this->assertLinkByHref(_url($view['page[path]']));
// Make sure the link is associated with the main menu.
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
/** @var \Drupal\Core\Menu\MenuLinkInterface $link */
$link = $menu_link_manager->createInstance('views_view:views.' . $view['id'] . '.page_1');
$url = $link->getUrlObject();
$this->assertEqual($url->getRouteName(), 'view.' . $view['id'] . '.page_1', String::format('Found a link to %path in the main menu', array('%path' => $view['page[path]'])));
$metadata = $link->getMetaData();
$this->assertEqual(array('view_id' => $view['id'], 'display_id' => 'page_1'), $metadata);
}
示例11: testGet
public function testGet()
{
// Test si on récupère une adresse par défault
$this->assertRegexp('/^http:\\/\\/.*www\\/$/', CopixUrl::get());
$this->assertRegexp('/^http:\\/\\/.*www/', CopixUrl::get("#"));
// Test des URL récupérées en mode prepend
CopixConfig::instance()->significant_url_mode = 'prepend';
// On attend ici une URL en utilisant tous les cas du paramètre $pDest
// @todo : Changer le test quand on voudra enlever le deuxième default
$this->assertRegexp('/^http:\\/\\/.*\\/default\\/default\\/copixtest/', _url('copixtest'));
$params = new StdClass();
$this->assertRegexp('/^http:\\/\\/.*\\/default\\/default\\/copixtest/', _url('copixtest', $params));
$this->assertRegexp('/^http:\\/\\/.*\\/default\\/copixtest/', _url('copixtest|'));
$this->assertRegexp('/^http:\\/\\/.*\\/copixtest/', _url('copixtest||'));
// On cherche l'URL d'un module avec une variable définie dans une fichier significanturl
$this->assertRegexp('/^http:\\/\\/.*?test=value$/', _url('copixtest||', array('test' => 'value')));
$params = new StdClass();
$params->test = 'value';
$this->assertRegexp('/^http:\\/\\/.*?test=value$/', _url('copixtest||', $params));
// On cherche l'URL d'un module avec une variable non définie dans une fichier significanturl
$this->assertRegexp('/^http:\\/\\/.*\\/value$/', _url('copixtest||', array('var' => 'value')));
// On cherche l'URL d'un module inexistant dans le site
// @todo : Changer le test quand on voudra enlever le deuxième default
$this->assertRegexp('/^http:\\/\\/.*\\/test$/', _url('test||'));
// Test des URL récupérées en mode default
CopixConfig::instance()->significant_url_mode = 'default';
// On cherche l'URL d'un module avec une variable définie dans une fichier significanturl
$this->assertRegexp('/^http:\\/\\/.*\\?module=copixtest.*&test=value$/', _url('copixtest||', array('test' => 'value')));
// On cherche l'URL d'un module avec une variable non définie dans une fichier significanturl
$this->assertRegexp('/^http:\\/\\/.*\\?module=copixtest.*&var=value$/', _url('copixtest||', array('var' => 'value')));
// On cherche l'URL d'un module inexistant dans le site
$this->assertRegexp('/^http:\\/\\/.*\\?module=test/', _url('test||'));
$this->assertEquals('http://www.google.fr', _url('copixtest|google|'));
}
示例12: validateClient
protected function validateClient($deliveryId)
{
$service = $this->getServiceLocator()->get(RequirementsServiceInterface::CONFIG_ID);
if (!$service->compliesToDelivery($deliveryId)) {
throw new UnAuthorizedException(_url('notCompatibleEnvironment', 'Error', 'taoClientRestrict'));
}
}
示例13: index
function index($ctx)
{
$ctx->title = '绑定微信账号';
setcookie('no_subscribe_prj', '', time() + 3600);
$user = UC::auth();
if ($user) {
$connect = WxConnect::get_by('user_id', $user['id']);
if ($connect) {
_redirect('/');
}
}
if (!$this->openid) {
if (!$_GET['redirect']) {
// 避免循环跳转
UC::logout();
// 使用域名 axelahome.com, 避免因为跨域导致 session 获取不到问题
$jump = _url('https://axelahome.com/weixin/bind', array('redirect' => 1));
$url = _url('https://axelahome.com/weixin/oauth', array('jump' => $jump));
_redirect($url);
}
_throw("链接已经过期, 请重新获取微信消息!", 200);
} else {
$connect = WxConnect::get_by('wx_openid', $this->openid);
if ($connect) {
_throw('此微信号已经绑定过懒投资账号, 请先解绑!');
}
}
}
示例14: process
/**
* Construction du message
* @param mixed $pParams tableau de paramètre ou clef
* @param mixed $pContent null (ImageProtect n'est pas censé recevoir de contenu)
* @return string balise html contenant l'image
*/
public function process($pParams, $pContent = null)
{
if (!isset($pParams['id'])) {
throw new CopixTagException("[ImageProtect] Missing id parameter");
}
return '<img src="' . _url('antispam|default|getimage') . '?id=' . $pParams['id'] . '" />';
}
示例15: processDelete
/**
* Actiongroup qui permet de gérer la suppression
*
*/
public function processDelete()
{
$form = CopixFormFactory::get(_request('form_id'));
$form->delete(CopixRequest::asArray());
$url = _request('url');
return _arRedirect(_url($url));
}