How to change Symfony 1.x message for secure module - symfony1

I'm looking for a way how to change default message saying that login is required to see a page created in secure module. Currently it look like this: https://gyazo.com/1477f388deb20e4da3e13c5a957e86ce
Do you know how to change it or create a redirect to a different route ?
Currently I'm using symfony 1.19

You can use
login_module and login_action: Action called when a nonauthenticated user tries to access a page defined as secure in security.yml. The default value is default/login.
secure_module and secure_action: Action called when a user doesn't have the credentials required for an action. The default value is default/secure.
You can override the default pages in two ways:
You can create your own default module in the application's modules/ directory, override all the actions defined in the settings.yml file (index, error404, login, secure, disabled) and all the related templates (indexSuccess.php, error404Success.php, loginSuccess.php, secureSuccess.php, disabledSuccess.php).
You can change the default module and action settings of the settings.yml file to use pages of your application.

Related

How to remove a query parameter from URL without refresh the router in Ember js

I have a website built from Ember.js. A user can access a page through URL http://..../view?showTitle=true. However I don't want to explicitly expose the parameter showTitle=true to the user (meaning user will only see http://..../view). This URL is automatically generated and serves as a redirect destination URL. So, I have to remove it manually somewhere before the page load. But I still need this value of this query parameter to query data. Is there a way to achieve that (A example would be great)? What about do it without refreshing the router?
Actually, an example of your scenario would be greater :)
There are some other ways to store data while transitioning to a route. Such as: storing the params in transition object or storing the value in a service. Create a redirection route, use beforeModel hook to grab the value from query params then do a redirection to the real route.
A working example is: ember-twiddle-1
By the way, even if you don't describe your queryParamsin your routes, you can access them via transition.queryParams. This seems a bit hacky. But it works: ember-twiddle-2 (Note: It doesn't work in the same route.)
Updated:
At the setupController hook you can override the controller parameters. So you can remove the parameters from the url. ember-twiddle-3

With the Orbeon Proxy Portlet is there a way to enable form selection via Inter Portlet Communication?

The Orbeon Proxy Portlet allows form selection via URL parameters. It would be preferable if the parameters were not included in the URL. I thought I might be able to use a public render parameter as described in the Liferay documentation but it looks like the proxy portlet isn't configured that way.
Looking at OrbeonProxyPortlet.scala I see this method is used to retrieve the URL parameters:
private def portalQuery(request: PortletRequest) =
collectByErasedType[String](request.getAttribute("javax.servlet.forward.query_string")) map decodeSimpleQuery getOrElse Nil
Could this method be modified to combine that map with the map returned by PorletRenderRequest.getParameterMap() or PorletRenderRequest.getPublicParameterMap()?
Or perhaps there could be another init-param like enable-url-parameters, for example, enable-inter-portlet-parameters?
This would also require the following configuration in the portlet.xml:
<supported-public-render-parameter>orbeon-app</supported-public-render-parameter>
<supported-public-render-parameter>orbeon-form</supported-public-render-parameter>
<supported-public-render-parameter>orbeon-document</supported-public-render-parameter>
<supported-public-render-parameter>orbeon-page</supported-public-render-parameter>
As you noticed, currently this is not implemented, and I don't think there is a way without modifying the code of OrbeonProxyPortlet.scala. But yes, it would make sense to make this work, and in fact the option was considered in issue #1850.

redirect root url according to locale in Zend

Working in ZF: Is it possible to change the base or root url on the www.example.com to www.example.com/$language/home, thus depending on the (browser) locale of the users browser?
Example; If a guest manually types www.example.com I would like to change the url automatically to a url with locale: www.example.com/en/home for guests in en_GB region or www.example.fr/home for guests in fr_FR region.
From the root-url I have all the menu-urls and content locale aware. Clicking a link to a menu item in the url the lang is automatically added after the root. The content on the root url is locale aware too using translate, so english for en_GB en french for fr_FR, etc.
Still missing though I would like to have the root url change to locale aware right from the start of the visit to the application if only the root is entered.
I guess something like
root :to => redirect("/prepayments")
in Rails 3 from what I understand from this Q&A on this forum
I have tried and implemented controller action helpers, redirects, etc. etc. for as far as I could find on this forum, but they all don't offer the solution.
A redirect in htaccess is not possible I think since I first need to get the locale from the browser. Since I don't know this the redirect is dynamic and I cannot set a redirect in htaccess.
I woud appreciate any suggestions?
Since I don't know what version of Zend you're using I am posting this for Zend 1.1x. One thing you could do is "catch" the request before it is dispatched, get the Accept-Language header and based on the user's preferences there set the locale or redirect the user to a URL you like. One way to do this is in the FrontController's preDispatch() method.
Keep in mind that:
You will need to check if all browsers send this through
This header string must be parsed careful
Because of the way it is defined:
Accept-Language en,bg;q=0.7,en-us;q=0.3
Also users may and often do set language preferences to a foreign language so this header on its own may not be enough.
The best way to do this in a OOP way is to wrap this functionality in a ZendPlugin.
Attach it in your bootstrap:
protected function _initLocaleHandlerControllerPlugin() {
$frontController = Zend_Controller_Front::getInstance();
$plugin = new App_Controller_Plugin_LocaleHandler();
$frontController->registerPlugin($plugin);
}
Now in this plugin redefine the preDispatch() callback:
public function preDispatch(Zend_Controller_Request_Http $request) {
$acceptLang = $request->getHeader('Accept-Language');
//Parse string and get language
//After parsing set the appropriate locale in `Zend_Locale`
//redirect the user/dispatch the request?
//THIS IS JUST AN EXAMPLE:
$request->setModuleName('home')
->setControllerName('registration')
->setDispatched(true);
}
Zend 1.x doesn't seem to have a built in class for this, Zend 2 does have the "Zend\Http\Header\AcceptLanguage" class.
I finally found the next solution on my question with a little help from Florent in Zend Framework: Redirect from action helper:
In my Language Plugin I added
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{...some code handling translate...
$url = $request->getRequestUri();
if ($url === '/') {
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
$redirector->gotoUrl($lang.'/home');
}
The routes I have them in a routes.ini so $lang.'/home' is routed to the indexController and indexAction of the Default module.

Symfony linking to an admin Table record edit page

kind of finding it difficult to wrap my head around this. For those who have used the Symfony admin generator extensively, for each module based of a backend module, there is an edit page for all the records. Typically this can be accessed like this:
module/primarykey/edit. (assume questions/1/edit)
which is strange because typically the primary key would be passed in as a URI parameter like:
questions/edit/1. Anyways, that maybe irrelevant. What is important is how do I manage to generate a link_to for the above URI. I am linking the editSuccess page through an external page which does not belong to the UI. The syntax I use is
link_to('Edit','questions/'.$primary_key.'/edit') // (where $primary_key = 1 as in this case)
However that auto modifies itself to :
/backend_dev.php/questions/1/action note the action instead of edit
No such action exists and it returns a 404 error stating that questions/action does not exist
To summarize, How do you link to an admin page that renders specifically for a record?
The url_for (and thus the link_to) helpers deal with internal urls, not external ones. The syntax is module/action?parameters. In your case this would be question/edit?id=$primarykey (assuming the action looks for the id parameter).
If you give a name to your route, that makes generating the link faster (hashtable lookup vs. linear search):
echo url_for("#question_edit?id=$primary_key");
If you set up your route as an sfDoctrineRoute, it gets even simpler:
echo url_for("question_edit", $question);
note how you need not pass the id, but the question object - the route class will fetch all neccessary parameters.

Customize Drupal URL by content type

I have set up a content type - cars. Is there a way to automatically add the prefix /cars/ before the id? So for example domain.com/cars/2. I may also have more content types which I need to do this for. Standard pages however need no prefix.
How can I change the URL format based on the content type?
The Pathauto module was built for exactly that:
The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users) without requiring the user to manually specify the path alias.
Use the pathauto module with token [content-type]/[node]

Resources