laravel return View::make in new tab - php

How can I return a View::make (from "route") to be displayed in a new tab using Laravel? I have tried to achieve this with the following code however it is not opening the view in a new tab:
return View::make('reports.cars')->with('cont', $u);

You do not need to modify controller code, just use target="_blank":
example.com
_blank opens the linked document in a new window or tab
https://www.w3schools.com/tags/att_a_target.asp

There is no way to to what you are asking from the server side. Tab controls are client side only and handled by the browser.
You can do for example:
Open in a new tab

Related

How to set PDF page title from Symfony Controller?

Here is my method in a Controller:
/**
* #Route("/bilgi/agr", name="user_agreement")
*/
public function agr(): Response
{
$response = new BinaryFileResponse(__DIR__ . '/../../public/docs/User_Agreement.pdf');
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $response->getFile()->getFileName());
return $response;
}
I'm expecting to see Page title as User_Agreement.pdf, but instead it is agr. Which is not appropriate. I can't change the route because it is being used on several other classes/files.
Is there any way I can set a custom title or at least the file name? When I save the file I see the file name as User_Agreement.pdf so the file name is also correct.
If that is not possible is there workaround to show it in twig/html?
You can't. <title>" is an HTML element, not a PDF one.
If a browser renders a PDF directly (as many/most do nowadays), the only thing they could use for a "title" is the URL for the request. agr in your case.
It's basically something the server side has no control of. It just sends the response, and the browser decides how to show it, and what to show in the space usually reserved for the <title> element.
With the Content-Disposition header you can hint the browser about what name they should suggest for the file to the end-user, but that's all.
If you absolutely need this, yes, you could send a regular HTML response and somehow show the PDF inlined/embedded on the page.

Vscode open classes reference in New tab

You suppose we used some class in current class and now wen I want to open class reference by holding ctrl and pressing left click I expect class reference should be opened in new tab but that show in bottom of class like with below screen shot. However that's not bad but I want to show that in new tab
Please check whether “Preview Mode” is in effect.
For VScode, to stop files from going into preview mode, and always open a new tab go to File -> Preferences -> Settings (or Ctrl + ,)
And try adding the following to “Users Settings”
"workbench.editor.enablePreview": false
Please include a comma if there’s other settings as it has to be a valid json

Open new tab in chrome using Selenium Facebook PHP Webdriver

So the basic spiel, "I am new to this thing" called Selenium using Facebook's PHP Webdriver (https://github.com/facebook/php-webdriver) and I cannot find anything that matches "How to open a new tab in chrome" using this particular technology. Any help will be very much appreciated.
A virtual cup of coffee to you, kind programmer!
New way to do it since php-webdriver 1.10.0:
// Default behavior, without specifying window type
$driver->switchTo()->newWindow();
// Open new window
$driver->switchTo()->newWindow(WebDriverTargetLocator::WINDOW_TYPE_WINDOW);
// Open new tab
$driver->switchTo()->newWindow(WebDriverTargetLocator::WINDOW_TYPE_TAB);
$driver->switchTo()->window($driver->getWindowHandles()[1]);
See doucmentation for more examples.
You can go with JS solution like:
$webdriver->executeScript("window.open('". $url ."','_blank');", array());
Something like this should work:
$driver = RemoteWebDriver::create($host, DesiredCapabilities::chrome());
$driver->get('http://mine.com');
// Via driver: http://facebook.github.io/php-webdriver/classes/RemoteWebDriver.html#property_keyboard
$kbd = $driver->getKeyboard();
$kbd->sendKeys(WebDriverKeys.CONTROL,'t');
// Via an element: http://facebook.github.io/php-webdriver/classes/WebDriverElement.html#method_sendKeys
$element = $driver->findElement(WebDriverBy::id('somethingOnScreen'));
$element->sendKeys(WebDriverKeys.CONTROL,'t');
$driver->getKeyboard()->sendKeys(
array(WebDriverKeys::CONTROL, 't'),
);

How do I resolve link problems mask PHP /"////"//"/"

I have a website, using tiny_mce backoffice.
My website works well on my server, but I have to change the host server and suddenly I see this problem:
For example:
If I want to save text with links, for wikipedia.org for example... And I save on backoffice (with open new window propertie _target)
-Then in website interface, I click on wikipedia text link
and and instead of opening a new window, I have somethinfg like this :
mysite.com//"//"////"http://wikipedia.org/"////"//"/"
Is that normal?
Last server never happen that
And in this new server he creates somethink like a mask
anyone knows how to resolve that?
thanks
best regards
You should use stripslashes();
http://php.net/manual/en/function.stripslashes.php
EXAMPLE
<textarea class="tiny_mce"><?php echo stripslashes(); ?></textarea>

Switching between frames in Selenium 2 with PHP-Webdriver

I currently use Selenium 2 with a local Selenium web server and the PHP-Webdriver written by Facebook.
Now I want to write an automated test for the Facebook Like Button. Because this Button is loaded through an iframe, I first select this frame via $driver->frame(array('id' => 1)) (I Found out, that Facebook loads normally two frames and the second frame is the Like Button). After clicking the Like Button a new Frame is loaded, where the user also can send a comment to his wall. Unfortunately the focus is still on the Like Button Frame so that I have to switch to the second frame. How can I do this?
Because I do not use Selenium RC there is no Selenium.SelectFrame("relative=top") method. I also cannot use the method driver.switchTo().defaultContent() because I do not use the Java webdriver. It seems that I just can use methods specified in the JsonWireProtocol. How can I switch between frames or change the focus back to the top frame?
Python webdriver client has these methods for switching between iframes, windows and pop ups:
switch_to_active_element
switch_to_alert
switch_to_default_content
switch_to_frame
switch_to_window
switch_to_default_content is the one you need. Find its analog for php client.
UPDATE:
Since you mentioned JasonWireProtocol:
http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/frame
POST /session/:sessionId/frame
Change focus to another frame on the page.
If the frame ID is null, the server should switch to the page's default content.
I had this same problem. The issue I discovered, that the "frame" in the PHP webdrivers only switches to frames below the current one. So if you want to switch to a different frame that is above the current frame, you are out of luck. I had to select the main window, which essentially reset me to the top frame. From there I was able to select the correct frame.
//putting a sleep so the page can load
sleep(SLEEPTIME + 5);
//getting a list of windows on the page
$windows = $webdriver->getWindows(); // function below
//switching to the
$webdriver->selectWindow($windows[0]);
$webdriver->focusFrame('cpAppFrame');
public function getWindows() {
$request = $this->requestURL . "/window_handles";
$response = $this->execute_rest_request_GET($request);
return $this->extractValueFromJsonResponse($response);
}

Categories