TYPO3 website multilanguage configuration - configuration

I want to configure a multi language TYPO3 website. I tried to put this code to Page TSConfig
config {
linkVars = L
sys_language_uid = 0
sys_language_overlay = 1
sys_language_mode = content_fallback
language = sq
locale_all = sq_AL.UTF-8
htmlTag_setParams = lang="sq" dir="ltr" class="no-js"
}
[globalVar = GP:L = 1]
config {
sys_language_uid = 1
language = en
locale_all = en_US.UTF-8
htmlTag_setParams = lang="en" dir="ltr" class="no-js"
}
[global]
[globalVar = GP:L = 2]
config {
sys_language_uid = 2
language = it
locale_all = it_IT.UTF-8
htmlTag_setParams = lang="it" dir="ltr" class="no-js"
}
[global]
but when attaching the L parameter with sys_language_uid to the page URL, nothing happens. My template is :
#about
ABOUT = CONTENT
ABOUT {
table = tt_content
select {
where = colPos=1
languageField = sys_language_uid
}
}
I Have translated the content in Page Module.
Am I using this right or not? How can I properly configure the languages?

The Code you have shown above goes to TypoScript Setup. Not in the Page TS Config in the page properties.
Use the "Template" module on the left as admin in your TYPO3 backend. When you edit the template, it has two parts for code: Constants and Setup. Use that code in setup and clear the cache.

Related

dataExplorer::create_report produces html file that is blank

I am trying to create a HTML report from the DataExplorer::create_report(). The code is as follows
DataExplorer::create_report(iris, config = list(add_plot_qq = FALSE, global_ggtheme = quote(theme_minimal(base_size = 14))))
The code creates "report.html", which is blank when I open it in any browser. I am using the DataExplorer version 0.8.0
Nick's answer is correct. I made some updates in v0.8 to simplify report customization, i.e., #87. However, I would like to use this section to provide a little more information on that. Please do not accept this as an answer.
configure_report helps you write less code in terms adding/removing sections, as well as editing themes. However, the output is no different from the list output from previous versions. If you want, you can still make your own list files and pass it to create_report. The template is here:
config <- list(
"introduce" = list(),
"plot_intro" = list(),
"plot_str" = list(
"type" = "diagonal",
"fontSize" = 35,
"width" = 1000,
"margin" = list("left" = 350, "right" = 250)
),
"plot_missing" = list(),
"plot_histogram" = list(),
"plot_qq" = list(sampled_rows = 1000L),
"plot_bar" = list(),
"plot_correlation" = list("cor_args" = list("use" = "pairwise.complete.obs")),
"plot_prcomp" = list(),
"plot_boxplot" = list(),
"plot_scatterplot" = list(sampled_rows = 1000L)
)
After that, you can just call create_report as usual:
create_report(iris, config = config)
Hope this helps!
For those searching for the answer use: config = configure_report() instead of config = list()
DataExplorer::create_report(iris,
config = configure_report(add_plot_qq = FALSE,
global_ggtheme = quote(theme_minimal(base_size = 14))))

Need help in scraping the img src from a website; below is my code

Below is my web scraping code for a website; it clicks a form which redirects to a page. From that page I need to extract [img] src url and export it into csv in a text form. I used the code below to extract a content from a td tag. When I run the same code it doesn't work because the td tag has no content but only a img tag. Any help will be appreciated. I am new to web-scraping. Thanks in Advance.
browser.find_element_by_css_selector(".textinput[value='APPLY']").click()
#select_finder = "//tr[contains(text(), 'NB')]//a"
select_finder = "//td[text()='NB')]/../td[2]/a"
browser.find_element_by_css_selector(".content a").click()
assert "Application Details" in browser.title
file_data = []
try:
assert "Application Details" in browser.title
enlargement = browser.find_element_by_xpath("/html/body/center/table[15]/tbody/tr[3]/td[2]/b").text
enlargement_answer1 = browser.find_element_by_xpath("/html/body/center/table[15]/tbody/tr[4]/td[2]").text
enlargement_answer2 = browser.find_element_by_xpath("/html/body/center/table[15]/tbody/tr[4]/td[3]").text
enlargement_text = enlargement + enlargement_answer1 + enlargement_answer2
considerations = browser.find_element_by_xpath("/html/body/center/table[16]/tbody/tr[4]/td[2]/b").text
considerations_answer = browser.find_element_by_xpath("/html/body/center/table[16]/tbody/tr[4]/td[3]").text
considerations_text = considerations + considerations_answer
alteration = browser.find_element_by_xpath("/html/body/center/table[16]/tbody/tr[4]/td[6]/b").text
alteration_answer = browser.find_element_by_xpath("/html/body/center/table[16]/tbody/tr[4]/td[7]").text
alteration_text = alteration + alteration_answer
units = browser.find_element_by_xpath("/html/body/center/table[16]/tbody/tr[5]/td[3]/b").text
units_answer = browser.find_element_by_xpath("/html/body/center/table[15]/tbody/tr[5]/td[4]").text
units_text = units + units_answer
occupancy = browser.find_element_by_xpath("/html/body/center/table[16]/tbody/tr[6]/td[3]/b").text
occupancy_answer = browser.find_element_by_xpath("/html/body/center/table[16]/tbody/tr[6]/td[4]").text
occupancy_text = occupancy + occupancy_answer
coo = browser.find_element_by_xpath("/html/body/center/table[16]/tbody/tr[7]/td[3]/b").text
coo_answer = browser.find_element_by_xpath("/html/body/center/table[16]/tbody/tr[7]/td[4]").text
coo_text = coo + coo_answer
floors = browser.find_element_by_xpath("/html/body/center/table[16]/tbody/tr[8]/td[3]/b").text
floors_answer = browser.find_element_by_xpath("/html/body/center/table[16]/tbody/tr[8]/td[4]").text
floors_text = floors + floors_answer
except (NoSuchElementException, AssertionError) as e:
floors_text.append("No Zoning Characteristics Present")
coo_text.append("n/a")
occupancy_text.append("n/a")
units_text.append("n/a")
alteration_text.append("n/a")
considerations_text.append("n/a")
enlargement_text.append("n/a")
with open('DOB.csv', 'a') as f:
wr = csv.writer(f, dialect='excel')
wr.writerow((block_number, lot_number, houseno, street, condo_text,
vacant_text, city_owned_text, file_data, floors_text, coo_text, occupancy_text, units_text, alteration_text,
considerations_text, enlargement_text ))
browser.close()
As you stated you are new to web scraping I encourage you to read up a bit: http://selenium-python.readthedocs.io/locating-elements.html
You are using XPath exclusively and in ways that are not recommended.
From the docs: "You can use XPath to either locate the element in absolute terms (not advised), or relative to an element that does have an id or name attribute."
Try using other locators to get your image.
for example: driver.find_element_by_css_selector("img[src='images/box_check.gif']")

Read DB entries dynamically in TypoScript

I have the following setup for my Typo3 installation:
TypoScript:
lib.responsiveImage = IMAGE
lib.responsiveImage {
default = IMAGE
default{
file {
import.current = 1
treatIdAsReference = 1
}
altText.data = DB:sys_file_reference:26:alternative
titleText.data = current
}
}
Which produces the following output Tag (unneccessary content deleted; important is the alt and the title tag):
<img class="img-responsive" srcset="XY.jpg" alt="AltText" title="26" sizes="(min-width: 1200px) 1100px">
As you can see, current delivers the correct uid of "26". The database query via DB:sys_file_reference:26:alternative delivers the correct "AltText".
However -> How could i achieve that dynamically?
I tried something like this
DB:sys_file_reference:{current}:alternative
but this doesnt worked. current should be the uid of an FileReference
(Also altText.data = file:current:alternative gives me an Error: No File Object)
Maybe the use of the FILES element is safer:
lib.responsiveImage = FILES
lib.repsonsiveImage {
references.current = 1
renderObj = IMAGE
renderObj {
file.import.data = file:current:uid
file.treatIdAsReference = 1
altText.data = file:current:alternative
titleText.data = file:current:title
emptyTitleHandling = useAlt
}
}
Luckily i found a solution:
default = IMAGE
default{
file {
import.current = 1
treatIdAsReference = 1
}
sourceCollection < tt_content.image.20.1.sourceCollection
layout < tt_content.image.20.1.layout
layoutKey = srcset
altText.data.dataWrap = DB:sys_file_reference:{current}:alternative
altText.wrap = |
}
If you use dataWrap the {current}works as expected!

Taking a screenshot of a page in InDesign Extension Builder

For my current assignment I need to make an extension for Adobe InDesign using Adobe Creative Suit Extension Builder and Flash Builder. I guess this is more of a question for ones that know Extension Builder and InDesign API.
The point of this extension is to load some data and send some data to a server. I need to make a screenshot of a page, then send it in jpg to a server. But, there are no (or at least i couldnt find any) ways to create a bitmap(to cast it on a object seems impossible, because this Objects are just Objects, and not DisplayObjects).
I managed to silently export pages as jpegs, now I'm thinking about loading them and sending but that will require building an AIR app to handle it all, so this will be a bit bulky.
So to sum up the question, how to take a screencapture of all elements on a page in InDesign using CS Ext.Builder?
what is the problem with export to JPG ? You can choose to export the page or the objects themselves.
Here is a snippet I wrote in a recent project. Hope it helps.
public static function getFilePath():String {
var app:com.adobe.indesign.Application = InDesign.app;
var sel:* = app.selection, oldResolution:Number, oldColorSpace:JpegColorSpaceEnum, groupItems:Array = [], i:int = 0, n:int = sel.length;
if (!sel || !n )
{
Alert.show("Pas de selection !", "title", Alert.OK, Sprite(mx.core.Application.application));
return "";
}
for ( i = 0 ; i < n ; i ++ )
{
groupItems [ groupItems.length ] = sel[i];
}
sel = ( sel.length > 1 )? app.activeDocument.groups.add ( sel ) : sel[0] ;
var tempFolder:File = File.createTempDirectory();
AppModel.getInstance().jpgFolder = tempFolder;
var jpgFile:File = new File ();
jpgFile.nativePath = tempFolder.nativePath + "/temp.jpg";
oldResolution = app.jpegExportPreferences.exportResolution;
app.jpegExportPreferences.exportResolution = 72;
oldColorSpace = app.jpegExportPreferences.jpegColorSpace;
app.jpegExportPreferences.jpegColorSpace = JpegColorSpaceEnum.GRAY;
sel.exportFile ( ExportFormat.jpg, jpgFile );
app.jpegExportPreferences.jpegColorSpace = oldColorSpace;
app.jpegExportPreferences.exportResolution = oldResolution;
if ( sel is Group )
{
sel.ungroup();
app.select ( groupItems );
}
return jpgFile.nativePath;
}

Sending information via ajax partially working/failing

I am trying to send information about the user browser to a mysql database via ajax and this method that used to work perfectly on another site is now working partially, meaning that the data about the screen and browser width/ height, the color and pixel depth don't appear in my database and the information collected via php are sent/ saved.
Here is what I have in my index.html file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html lang="en">
<head>
<title>Welcome</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script type="text/javascript">
function ajax_post() {
var hr = new XMLHttpRequest();
var url = "st.php";
var sw = screen.width;
var sh = screen.height;
var bw = document.documentElement.clientWidth;
var bh = document.documentElement.clientHeight;
var cd = screen.colorDepth;
var pd = screen.pixelDepth;
var vars = "sw="+sw+"&sh="+sh+"&bw="+bw+"&bh="+bh+"&cd="+cd+"&pd="+pd;
hr.open("POST", url, true);
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
hr.onreadystatechange = function() {
if(hr.readyState == 4 && hr.status == 200) {
var return_data = hr.responseText;
}
}
hr.send(vars);
};
ajax_post();
</script>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
My content here
</body>
</html>
and here is the content of the st.php file used to collect information via php and to send/ seve it to the database:
<?php
$dnt = date(DATE_COOKIE);
$ip = $_SERVER['REMOTE_ADDR'];
$rh = gethostbyaddr($ip);
$re = $_SERVER['HTTP_REFERER'];
$ua = $_SERVER['HTTP_USER_AGENT'];
$al = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$sw = $_POST['sw'];
$sh = $_POST['sh'];
$bw = $_POST['bw'];
$bh = $_POST['bh'];
$cd = $_POST['cd'];
$pd = $_POST['pd'];
$db_host = ********; // the host
$db_user = ********; // the user
$db_password = ***********; // the password
$connection = mysql_connect($db_host, $db_user, $db_password) or die(mysql_error());
mysql_select_db(*******) or die(mysql_error());
$query = "INSERT INTO *********(dnt, ip, rh, re, ua, al, sw, sh, bw, bh, cd, pd)
VALUES ('".mysql_real_escape($dnt)."','".mysql_real_escape($ip)."','".mysql_real_escape($rh)."','".mysql_real_escape($re)."','".mysql_real_escape($ua)."','".mysql_real_escape($al)."','".mysql_real_escape($sw)."','".mysql_real_escape($sh)."','".mysql_real_escape($bw)."','".mysql_real_escape($bh)."','".mysql_real_escape($cd)."','".mysql_real_escape($pd)."')";
mysql_query($query) or die(mysql_error());
?>
I checked that I wasn't blocking any script (deactivated noscript), I tried it on Firefox and Chrome and Epiphany without any success: no data about the screen and browser width/ height, the color and pixel depth.
I don't have any idea why this is not working as I used exactly the same code one week ago on a website on the same host and it worked perfectly.
Thank you for your help.
----- EDIT -----
Thanks to #PiTheNumber I checked the Firebug Console and tracked the origin of the problem
Problem solved
Waiting 6 more hours to be able to answer my own question since I have less than 100 points of reputation and therefore cannot answer it right now.
This is very nice for mysql injection!
Use mysql_real_escape() with your insert:
$query = "INSERT INTO *********(dnt, ip, rh, re, ua, al, sw, sh, bw, bh, cd, pd)
VALUES ('".mysql_real_escape($dnt)."'...)";
Thanks to #PiTheNumber I checked the Firebug Console and tracked the problem to the rewriting/ redirecting of .php files that were breaking part of the POSTing of the the screen and browser width/ height, the color and pixel depth.