Posts Tagged ‘fix’

Concrete 5 SQL errors during installation

Friday, February 3rd, 2012

We have seen this error with Concrete 5.5.1

You try to setup Concrete 5, and get strange SQL errors during the installation:

If installing with an empty site, like this

c5-nosample-content-chosen

you get:

c5-mysql-error

mysql error: [1048: Column 'uID' cannot be null] in EXECUTE("INSERT INTO Config (cfKey,cfValue,uID) VALUES ('NEWSFLOW_LAST_VIEWED','FIRSTRUN',NULL)")

If installing with Sample content with Blog:

c5 with sample content

The error you get is:

Catchable fatal error: Argument 1 passed to ContentImporter::importPageAreas() must be an instance of Page, boolean given, called in /concrete/libraries/content/importer.php on line 75 and defined in /concrete/libraries/content/importer.php on line 197.

 

Solution:

You don't run Varnish by any chance, do you? We do, and we had it set up to … dispose of some cookies. The solution is, in Varnish' case, to enable pass-through for the host you are installing on.

You want to enable cookies.

 

Explanation:

The code which breaks is located in concrete5.5.1\concrete\models\package\starting_point.php

Config::save('SITE', SITE);
Config::save('SITE_APP_VERSION', APP_VERSION);
$u = new User();
$u->saveConfig('NEWSFLOW_LAST_VIEWED', 'FIRSTRUN');

As you see, this is the first time a User is created and used.

The User class is defined in concrete5.5.1\concrete\models\user.php

if (isset($_SESSION['uID'])) {
$this->uID = $_SESSION['uID'];
$this->uName = $_SESSION['uName'];
$this->uTimezone = $_SESSION['uTimezone'];
if (isset($_SESSION['uDefaultLanguage'])) {
$this->uDefaultLanguage = $_SESSION['uDefaultLanguage'];
}
$this->superUser = ($_SESSION['uID'] == USER_SUPER_ID) ? true : false;
} else {
$this->uID = null;
$this->uName = null;
$this->superUser = false;
$this->uDefaultLanguage = null;
$this->uTimezone = null;
}
$this->uGroups = $this->_getUserGroups();
if (!isset($args[2])) {
$_SESSION['uGroups'] = $this->uGroups;
}
}

The constructor checks in the Session for a valid user ID. If no user ID is found, it is set to zero. This happens if you throw away the cookies! Because the session is stored in them.

HTH. Feel free to comment on similar errors and solutions.

Ubuntu Sprache mit der Konsole wechseln

Tuesday, January 10th, 2012

Mein Bruder hat auf seinem Ubuntu Notebook chinesisch als Hauptsprache installiert. Klar, wir sprechen alle Chinesisch … nicht!

Jetzt hatte er mich gebeten etwas für ihn daran zu machen. Also musste erst Chinesisch durch z.b. Englisch ersetzt werden.

Leider müsste man in der GUI auch erkennen, welche chinesichen Zeichen denn jetzt dafür stehen, dass man die Sprache konfigurieren kann. Ich habe probeweise ein paar angeklickt, es kamen jedoch immer irgendwelche Dialoge mit noch mehr Chinesisch (im wahrsten Sinne des Wortes!).

Nach einer Internetrecherche, dank dieser Seite die Lösung:

  • eine Konsole aufrufen (die erkennt man an dem Konsolen-Icon)
  • sudo nano /etc/default/locale
  • ggf. User-passwort eingeben
  • eintragen:

LANG="en_GB"
LANGUAGE="en_GB:en"

  • speichern (Ctrl + O)
  • schließen (Ctrl + X)
  • System neustarten ( sudo reboot )

Nach dem Neustart sind wichtige Teile des Systems – bspw. die Menüleiste ganz oben – in Englisch. Das sollte es einem ermöglichen auch den Rest umzustellen … falls notwendig.

Andere Teile, bspw. FireFox bleiben allerdings in Chinesisch, und sind daher verteufelt schwer zu bedienen … so muss sich ein Analphabet vorkommen!

Finestra

Wednesday, January 4th, 2012

Running Windows 7? For a working Finestra (with correct Z-Order) use Version 1.1.

Version 1.2 messes up the Z-Order, and Version 2.0 and Version 2.1 both crash when hitting Win + Z to display the window overview (known bug). Sometimes the newest version is not the best one :-)

About Finestra

Finestra is a Virtual Desktop Manager for Windows. Freeware, fast switching, graphical indication to which desktop it switches.

Ability to drag windows to other desktops (using Win + Z to show the preview). Also useful for recovering windows which have been moved to outside your monitor by accident (believe me, it happens. Especially when using different monitor setups on notebooks)

Compiling with ruby and closure

Tuesday, November 1st, 2011

Here's some code to call closure (which is renamed closure.jar) from a ruby script:

def optimize_js(target)
#get all files in this folder, recurse over them
filecounter = 0
modifiedcounter = 0
Dir.glob(target + '*.js').each do|f|
puts "Processing #{f}"
filecounter += 1
my_js = `java -jar closure.jar –charset iso-8859-1 –js #{f}`
File.open(f, "w"){|con_file|
con_file.write(my_js)
}
end

puts "\n\t # JS Optimization: Done. Modified #{filecounter} files."
end

This code will overwrite the js files, so please be sure to operate on a copy of your files!

It is a function which takes a directory (target) and processes all files with the ending .js, replacing them in place with the optimized JS output. You need to put closure.jar in the same directory as the ruby script.

Note, that I also use the –charset iso-8859-1 option. This option ensures that closure reads the file in that iso charset, instead of assuming UTF-8. UTF-8 as default will work ok, until you have special characters from foreign languages, i.e. ä ö ü ß or á or whatever. Think Spanisch, French, German.

Internet Explorer, position fixed and strict mode

Wednesday, September 14th, 2011

You want to use fixed positioning with CSS

If you want to make use of the simple CSS position:fixed; to display an element static to the viewport, you will run into problems with the Internet Explorer.

position:fixed is only supported since Internet Explorer 7

I tested this solution with IE 7.0.5730.13 on Windows XP. IE 6 does not support fixed positioning.

You need to enforce strict mode

Internet Explorer will default to "quirky rendering mode", if you don't add special tags to your HTML document:

<!DOCTYPE html>
<HTML>
<HEAD>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Progress Test</title>
<meta http-equiv= "X-UA-Compatible"content="IE=Edge">
<script language = "JavaScript" src="../head.min.js"></script>
[...]

Both are essential! If you try IE 9 on the page without having added the meta tag X-UA-Compatible, it will render the page in quirky mode. And in quirky mode, it will ignore your position:fixed, and render your element where you have put it in the flow of the document.

Please note: I have read that this meta tag actually is not valid for this DOCTYPE.

It still does not work? I am testing with local documents!

Internet Explorer also takes into account where the element is being served from. This solution will work, if you upload your test documents to a server and access them over the Internet. It will not work (see note below) for local files, even if you use a local webserver to serve up the files (i.e. XAMPP). Internet Explorer will render your document in quirky mode, in this case.

Note: actually it does work offline (opening a document from the harddrive) in Internet Explorer 9 after fiddling somewhat with the document. I removed a IE compatibility script (not shown above), which I had included from Google previously. Check if you have one of those, and remove it!

.pages and Free Opener

Thursday, September 1st, 2011

What are .pages files?

They are files created with Pages, a part of the iWork productivity suite for Mac OS X.

How can I open them?

There is no known software which can open .pages natively on Windows or Linux.

But, there's a kind of a workaround which lets you access the content of the .pages files.

The workaround

The file is actually a .zip archive! If you have 7-zip right-click the file to extract it. If not, you may rename the file to filename.zip and extract it with your favorite ZIP application. (Windows can do it from Windows XP upwards).

The folder / files which you obtain from the .pages file contains different files and folders.

  • index.xml – if you are truly desperate, the text is in here and can be extracted with a lot of patience, I guess. Also theoretically someone could write a parser for this file sometime.
  • QuickLook – this folder contains preview versions of your .pages file. If it is present – sometimes it is not (if the creator of the file did not include a preview!)

What about QuickLook & the preview files?

There's two types (I know of):

  • PDF files – you're lucky, it contains your .pages in a format suitable for reading and further processing
  • JPG images – this is a low-resolution screenshot of the .pages file, you can still read it, but … well no copy'n'paste here.

What about Free Opener from freeopener.com?

The guys over at fileinfo.com claim that Free Opener can open .pages. Well, it's just doing the preview files thing from above. Meaning – if you only have a low-res JPEG preview image, that's all you get from Free Opener. No text, I'm sorry to say.

I like the installer – I think more installers should be built like theirs, BUT – it seems to install along with it many programs which you actually did not want in the first place, if you are not careful. Also there are rumours about it installing Adware (see WOT).

I would at this point advise against installing Free Opener to open .pages files. Use the manual method.

Are there other solutions to open .pages files?

  • Google Docs is supposed to be able to open them
  • Ask your friend / colleague / … to send you a PDF file, or to export to Word-readable formats (formatting may be lost with the latter option)
  • Buy a Mac.

Can InDesign access .pages files?

Not on Windows to my knowledge. Tested with InDesign CS5 + Windows 7 64bit without any extensions, by trying to place a .pages file. "No filter could be found".

Head.js working unreliably

Monday, August 8th, 2011

What is head.js

From the same author as the fabulous JQuery Tools libraryhead.js is "the only script in your head". You include it in your HTML output, and write code for it to include and run other JS files. It also offers some extensions for CSS, for instance you can optimize for different screen resolutions or fix glitches in different browsers.

Why should you include your files via head.js?

Well, the browser will load in a blocking manner – that is, it will load the resources it encounters first, and then continue loading the other resources. If you have a bunch of JS files, they might take a while to load (think of the HTTP request overhead, and of network latency!), thus blocking images, CSS files and other content on your site.

Head.js is only one (small) JS file to include, which will take care of loading your JS files asynchronously and simultaneously in the background. Once they are ready, you can execute code using the head.ready() method.

The result is – your webpage display significantly faster!

Problem

Sometimes, the scripts you load via head.js will work, sometimes they won't – i.e. features of the site additionally coded by you will not show up constantly and predictably.

Solution

The problem may be a race condition. Head.js loads the scripts asynchronously, so sometimes the other code on your site gets executed before the JS files included via head.js are executed, and sometimes afterwards.

Example: you are passing some information to your script via a variable which differs from page to page.

Your code is something like this (actually I moved the call to head.js() to the head.min.js file itself, which may contribute to the problem!):

<script language = "JavaScript" src="includes/head.min.js"></script>
<script type="text/javascript">
head.js('includes/jquery.tools.min.js','includes/custom-script.js');

… lots of code inbetween …

var variable_to_pass = 'some value';
</script>

and in your custom-script.js you rely on variable_to_pass like this:

var i_rely = variable_to_pass;

Sometimes your variable_to_pass will get set up before head.js has loaded your custom-script, and sometimes not. In the first case, all will go well, in the latter case, your code will fail. In Google Chrome, for instance, silently, unless you activate the JavaScript console to see the error stated.

This is called a race condition. The solution to this condition is to rely on external variables only once the whole page has loaded and is scriptable, which you have to test for, extra.

For instance you could use JQuery's $(function() {]); method for this, setting up the dependent variable or using the passed variable inside the function.

Another possibility is to check if the variable is as of yet undefined, and to give it a default value.

if (typeof(variable_to_pass) === 'undefined') {
variable_to_pass = 'some default value';

}

(not writing var before the variable will make it global).

Enable and fix Lectora titles for the Opera browser

Friday, June 17th, 2011

Problem: If you publish a title with Lectora, and try to view it from Opera, instead of the title you see an error message

Your browser does not support dynamic html. Please download a current version of either Microsoft'" DESIGNTIMESP=18189>Microsoft Internet Explorer or Mozilla'" DESIGNTIMESP=18192>Mozilla Firefox and try visiting our site again. Thank You.

Solution: You have to modify trivantis.js in line 353 and line 355. The modifications are displayed in bold

this.ns = (name=="ns" && this.v>=4)||(navigator.userAgent.indexOf("Opera")!=-1)
this.ns4 = (this.ns && this.v==4)
this.ns5 = (this.ns && this.v==5)||(navigator.userAgent.indexOf("Opera")!=-1)

IMPORTANT: WordPress fucks up the quotation marks above, fix them by hand!!!

This tells Lectora's code to treat Opera like Netscape Navigator and its derivates. For the title we are developing for the WHO (ICF eLearning tool) it works flawlessly.

This fix is taken from this Lectora forum message, posted by ssneg.

(ssneg also explains why it is not possible to override this.min and set it to true – because Lectora only includes code for IE or NS to display the title contents, like buttons, later on. Thus we need for Opera to "pretend" that it is Navigator. The code works.)

Do you know any other browsers incompatible with Lectora? Please post a comment, and we might find a solution :-)!

 

Privoxy rules to unblock Concrete 5 editing

Friday, May 20th, 2011

In Concrete 5, TinyMCE is used as an editor for Content blocks. If you have Privoxy installed with the default settings, crucial parts of this editor will be blocked, and you would be unable to edit the Content block properly. (no editor appears, you see a small box with the HTML instead).

You can verify that it's indeed Privoxy which is doing it, by checking the Network tab of Dragonfly or Firebug in Opera or FireFox, Privoxy will add a status message to files which have been blocked.

To fix this problem, edit your user.action file (located in the application's toplevel directory), and add a new line under the { fragile } section:

{ fragile }
#.forbes.com
/concrete/js/tiny_mce/plugins/.*
/updates/concrete.*

This should unblock all Concrete 5 – based sites.

Update (23.10.2011): The fix now works with updated Concrete 5 sites.

Fix for weird bug

Sunday, April 3rd, 2011

Lectora inserts anchors (<A name=""> elements) which sometimes can break things!

I have programmed exercises with a sliding animation from "page" to "page" of exercises using the Scrollable from JQuery Tools. It would work fine in an older FireFox, but broke apparently in the newest version, it newer worked in Chrome, but it works in IE. The exercises would jump to the last page, skipping over everything in between.

After one hour of debugging I found out that an additional <A></A> element had to be inserted in each "page" of the exercises. (I do it programmaticaly using PHP.) Now all items show up … with an additional item (depending on the browser).

This additional item is an anchor inserted by Lectora. There's no use putting code to take it out again to run on page load, as Lectora's code seems to run later. You have to run your code as soon, as the user triggers an action, just at the beginning of it to clean up.

//fixing Lectora interfering with our code …
$("#exercise > .items > a").remove();

A simple fix for a complex problem … Lectora does require a lot of workarounds.