Collapsed sections example:
The default of Mediawiki's Mobilefrontend is that sections are collapsed by default, they are uncollapsed when the user clicks on the section title.
I want to change it so that the uncollapsedness is the default.
What I have tried:
In all of MobileFrontend files, I found that "collaps" exists in these (and only these) files
MobileFrontend\javascripts\common\PageApi.js
MobileFrontend\less\common\enwp.less
MobileFrontend\less=common\reset.less
But I am unsure if these are related with what I try to do.
I tried to apply the guidelines in Manual:Collapsible_elements of mediawiki to those three files but it didn't work.
I searched "expandablesections" using 'Find in files' of Notepad++.
Then I found
MobileFrontend\includes\api\ApiParseExtender.php
Line 82: $mf->enableExpandableSections( !$params['mainpage'] );
MobileFrontend\includes\formatters\MobileFormatter.php
Line 23: protected $expandableSections = false;
Line 64: $formatter->enableExpandableSections( !$isMainPage && !$isSpecialPage );
Line 89: public function enableExpandableSections( $flag = true ) {
Line 90: $this->expandableSections = $flag;
MobileFrontend\includes\formatters\MobileFormatterHTML.php
Line 24: if ( $this->expandableSections ) {
MobileFrontend\tests\MobileFormatterTest.php
Line 24: $mf->enableExpandableSections();
I tried changing
$expandableSections = false;
to
$expandableSections = true;
but it didn't make the sections uncollapsed.
In LocalSettings.php: $wgMFCollapseSectionsByDefault = false;
Related
I have a script which calls functions from this script:
https://www.baselinesinc.com/dxl-repository/?filerepoaction=showpost&filepost_id=13
which is distributed under the LGPL. I have found several references to this script online, indicating that it works. For my own purposes, I removed the part of the code which executes on load (some 20 lines at the bottom of the file) and converted the file to an .inc, to serve as a library. I haven't done any other changes.
My own script has worked for a few months at this point. But now, all of a sudden, when I try to run it, I get these errors:
-E- DXL: <DOORSImporter\Import_From_Excel.inc:291> incorrect use of identifier (rtfValue)
-E- DXL: <DOORSImporter\Import_From_Excel.inc:292> incorrect use of identifier (nonRTFValue)
-E- DXL: <DOORSImporter\Import_From_Excel.inc:346> incorrect use of identifier (temp)
-E- DXL: <DOORSImporter\Import_From_Excel.inc:464> incorrect use of identifier (columnHeading)
-E- DXL: <DOORSImporter\Import_From_Excel.inc:1127> incorrect use of identifier (cellValue)
-I- DXL: All done. Errors reported: 5. Warnings reported: 0.
Below is a snippet of code which shows this error. I marked lines 291 and 292
bool richTextTruncated(int rowNumber, int columnNumber) {
Buffer rtfValue = create
Buffer nonRTFValue = create
rtfValue = ""
nonRTFValue = ""
rtfValue = copyRichTextFromCell(""intToCol(columnNumber) "" rowNumber"") // get the rich text
rtfValue = trimWhitespace(stripRichText(tempStringOf(rtfValue))) // strip off RTF formatting. <----- 291
nonRTFValue = trimWhitespace(getCellValue(rowNumber, columnNumber)) //<----- 292
if(tempStringOf(rtfValue) != tempStringOf(nonRTFValue)) { // if the two strings aren't equal
delete(rtfValue)
delete(nonRTFValue)
return true // return that text was truncated
}
delete(rtfValue)
delete(nonRTFValue)
return false
}
The function trimWhitespace itself is defined as
string trimWhitespace(string s) so it's OK to assign its output to a buffer.
So this is all very confusing because, like I said, this has worked and the code has not been changed (last check in of the file DOORSImporter\Import_From_Excel.inc is from last November, whereas I have used the script even in January.
Our IT department might have updated DOORS recently, I don't know. I checked the latest version of the dxl reference manual for any recent changes which might have caused this, but I couldn't find any change to the way buffers are handled.
To be fair, I have found working with buffers quite confusing. In my own code, I ended up discarding them altogether. However, the script Import_From_Excel has worked unchanged for a long time now.
Any support with this will be greatly appreciated.
********** Edit 27.02.2020 **************
The function copyRichTextFromCell is defined as below. Its sourced is from the link below.
https://www.baselinesinc.com/dxl-repository/?filerepoaction=showpost&filepost_id=10
string copyRichTextFromCell(string loc) {
if(!getCell(loc)) {
return("error");
}
if(!checkResult(oleMethod(objCell, cMethodSelect))) { // selects the cell
return("error");
}
if(!checkResult(oleMethod(objCell, cMethodCopy))) { // copies the contents of the cell to the clipboard
return("error");
}
return stringOf(richClip)
}
********** Edit 28.02.2020 **************
The function trimWhitespace is as below.
string trimWhitespace(string s) {
int first = 0;
int last = length(s) - 1;
while(last > 0 && (isspace(s[last]) || s[last] == '\n' || s[last] == '\r' || s[last] == '\t')) {
last--;
}
while(isspace(s[first]) && first < last) {
first++;
}
if(s[first:last] == " ") {
return("");
}
return(s[first:last]);
}
While playing around, I discovered that if I modify as below, one of the errors disappears. It is beyond me as to why that might happen, because the code is equivalent, as far as I can tell...
bool richTextTruncated(int rowNumber, int columnNumber) {
Buffer rtfValue = create
Buffer nonRTFValue = create
string fooString
rtfValue = ""
nonRTFValue = ""
rtfValue = copyRichTextFromCell(""intToCol(columnNumber) "" rowNumber"") // get the rich text
fooString = trimWhitespace(stripRichText(tempStringOf(rtfValue)))
rtfValue = fooString // strip off RTF formatting.
fooString = trimWhitespace(getCellValue(rowNumber, columnNumber))
nonRTFValue = fooString
if(tempStringOf(rtfValue) != tempStringOf(nonRTFValue)) { // if the two strings aren't equal
delete(rtfValue)
delete(nonRTFValue)
return true // return that text was truncated
}
delete(rtfValue)
delete(nonRTFValue)
return false
}
So the lines with fooString do not throw an error anymore. In the initial version, these lines were just e.g. rtfValue = trimWhitespace(stripRichText(tempStringOf(rtfValue))) and this would throw an error.
I am trying to program a simple pong program that uses arrow keys to navigate the player's paddle. I need to check instantaneous keycodes so I made a separate js file to parse the onkeydown and onkeyup events as booleans for the keycodes that I need. However, when I type the left arrow it turns on keycodes 37 and 39 together. This doesn't work for the right arrow but I have had it before confuse the space bar as an arrow key. The code basically looks like this:
var KeyPressed=
{
Left:false,
Right:false,
...
};
window.onkeydown =function(e) {
e = e || window.event;
var getKey = e.keyCode ? e.keyCode:e.charCode;
switch (getKey) {
case 37: KeyPressed.Left=true;
case 39: KeyPressed.Right=true;
...
}
};
window.onkeyup = function(e){
e = e || window.event;
var getKey = e.keyCode ? e.keyCode:e.charCode;
switch (getKey){
case 37: KeyPressed.Left=false;
case 39: KeyPressed.Right=false;
...
}
};
It looks like you're not resetting the left/right boolean status per press. So you should probably onkeyup set both to false regardless.
I'm having a huge problem when I've added content to a table (Lua), where all content in the table suddenly disappears.
The table in question holds the data for a banlist (608 entries at present) and is placed within the table by using table.insert, however the lead entry for the user is done as Umbra.Banlist[profileId] = {};. The Umbra.Banlist[profileId] = {}; table alone should mean that there's content within the Umbra.Banlist table.
I get no errors when running the code, and when using
if (#Umbra.Banlist == 0) then
System.LogAlways(Umbra.Tag.." The Banlist seems to be empty. It seems that some part of loading has failed.");
end
I get this:
I've looked on the web and on this site but there doesn't seem to be any related questions, so I'm posting it here.
This code is part of a server mod for Crysis Wars (see the whole function below), but has the entire Lua library at hand (so don't worry if you don't think your answer won't solve the problem).
The Code:
Umbra.ReadBans = function()
self = Umbra;
System.LogAlways(Umbra.Tag.." Starting banlist read.");
FileHnd, err = io.open(Root().."Mods/Infinity/System/Read/Banlst.lua", "r");
if (not FileHnd) then
System.LogAlways(Umbra.Tag.." Unable to find file 'Banlst.lua'.");
return;
end
for line in FileHnd:lines() do
local name, profile, ip, domain, reason, date, bannedby = line:match([[Umbra.BanSystem:Add%('(.-)', '(.+)', '(.+)', '(.+)', '(.+)', '(.+)', '(.-)'%);]]);
if (not name) then
System.LogAlways(Umbra.Tag.." Failed to read the banlist at line "..count or 0);
break;
end
System.LogAlways(Umbra.Tag.." Banlist; Name: [ "..name.." ], For: [ "..reason.." ], By: [ "..bannedby.." ]");
--local Msg, Date, Reason, Type, Domain = line:match([[User:Read%( "(.-)", { Date="(.+)"; Reason="(.+)"; Typ="(.+)"; Info="(.+)"; } %);]]);
--User:Read( "Banned", { Date="31.03.2011"; Reason="WEBSTREAM"; Typ="Inetnum"; Info="COMPUTER.SED.gg"; } );
--Umbra.BanSystem:Add('patryk', '258132298', '178.183.243.163', '178.183.243.163.dsl.dynamic.t-mobile.pl', 'flyhack', '08/11/2012 | 21:39:53', 'Anti-Noob');
Umbra.Banlist[profile] = {};
table.insert(Umbra.Banlist[profile], name);
table.insert(Umbra.Banlist[profile], ip);
table.insert(Umbra.Banlist[profile], domain);
table.insert(Umbra.Banlist[profile], reason);
table.insert(Umbra.Banlist[profile], date);
table.insert(Umbra.Banlist[profile], bannedby);
--[[Umbra.Banlist[profile].name = name;
Umbra.Banlist[profile].ip = ip;
Umbra.Banlist[profile].domain = domain;
Umbra.Banlist[profile].reason = reason;
Umbra.Banlist[profile].date = date;
Umbra.Banlist[profile].bannedby = bannedby;--]]
if not count then count = 0; end
count = count + 1;
end
Umbra.Bans = {};
Umbra.Bans.cnt = count;
System.LogAlways(Umbra.Tag.." Read "..count.." banned players (added into the Umbra Global Banlist)");
if (#Umbra.Banlist == 0) then
System.LogAlways(Umbra.Tag.." The Banlist seems to be empty. It seems that some part of loading has failed.");
end
count = nil; --Purge this one as well, again!
end
Edit:
I don't get the message that the code below should print if their profile doesn't exist in the table, so their profile does actually exist.
if (not Umbra.Banlist[profile]) then
System.LogAlways(Umbra.Tag.." Error in 'Umbra.Banlist': The profile does not exist.)");
break;
end
Another Edit:
Proof that the system can in fact get the 'ID' variable:
Near the end of your code you have #Umbra.Banlist == 0 but I don't see any item insertions into it by numeric keys. Here are some things to check to see if you're assumptions matches up with reality.
Check that profile isn't nil. It looks like in your use-case you're assuming it's a number. You can check this easily with:
assert(profile)
assert(type(profile) == 'number')
If profile is actually not a number type then checking Umbra.Banlist with # operator is faulty. Note # does not count the associative part of the table. If you only care whether Umbra.Banlist is empty or not you can use if next(Umbra.Banlist) then to check for it.
Just try to use this function to get count of items in table:
function count(t)
local c=0;
for i in pairs(t) do c=c+1; end
return c;
end
--...
if(count(Umbra.Banlist)==0)then
--...
end
The thing is, that # counts an array/table with number indexes, but you have table with string indexes. # is same like when you would replace "pairs" with "ipairs" in that count function. So and when you do #Umbra.Banlist, where all indexes are strings, it returns 0, because there are 0 integer indexes, but it does not mean, that table is empty.
Basic table, how they should be. But me need do it by function, how i can do that?
local mainMenu = {
caption = "Main Window",
description = "test window",
buttons = {
{ id = 1, value = "Info" },
{ id = 2, value = "Return" },
{ id = 3, value = "Ok" },
{ id = 4, value = "Cancel" }
},
popup = true
}
Table should be based on outside params, and code one table for each variable of options - not better way. I make a function for that, they should create basic options like caption or description and pop up, and insert values to buttons table (if option enabled - add button). But here the problem, they wont insert to tmp table, buttons table and their values for next options.
function createMenu()
tmp = {}
--buttons insert
if(config.info) then
table.insert(tmp, {buttons = {id = 1, value = "Info"}});
elseif(config.return) then
table.insert(tmp, {buttons = {id = 2, value = "Return"}});
end
--table main
table.insert(tmp, {
caption = "Main Window",
description = "test window",
popup = true
})
return tmp
end
How i can fixing them?
From looking at your createMenu function, two obvious problems stick out:
assigning to global tmp a new table every time createMenu is
called.
using the return keyword as a key in config.
One can be a problem if you use tmp somewhere else in your code outside the createMenu function. The obvious fix is to change it to:
local tmp = {}
For the second problem, you can use a lua keyword as a table key if you really want but you won't be able to use the . dot syntax to access this since Lua will parse this the wrong way. Instead, you need to change:
config.return
to
config["return"].
Edit: After reading your comment and checking the example table, it looks like only the button table is accessed by numerical index. In that case, you'll want to use table.insert only on button. If you want to create the table to have associative keys then you'll have to do something like this:
function createMenu()
local tmp =
{
--table main
caption = "Main Window",
description = "test window",
popup = true,
--button table
buttons = {}
}
--buttons insert
if config.info then
table.insert(tmp.buttons, {id = 1, value = "Info"});
elseif config['return'] then
table.insert(tmp.buttons, {id = 2, value = "Return"});
end
return tmp
end
This will produce the mainMenu table you're describing in your question.
I would like to disregard the first n items in a pager list of items. I.e. they are being used elsewhere in the design.
So my pager list needs to be as such:
Page 1: Items 8 - 17
Page 2: Items 18 - 27
Page 3: Items 28 - 37
...
However, setting an offset or limit in the criteria object does nothing. I presume they are used by the pager itself.
Is it possible to add a offset to the pager class in some other way?
Ok, I have got around the problem by modifying sfPropelPager.class.php and putting it into a new class file which I have named atPropelPagerOffset.class.php
It works in exactly the same way apart from it takes an extra parameter, $offset
So the top of the file looks like:
protected
$criteria = null,
$peer_method_name = 'doSelect',
$peer_count_method_name = 'doCount',
$offset = 0;
public function __construct($class, $maxPerPage = 10, $offset = 0)
{
parent::__construct($class, $maxPerPage);
$this->setCriteria(new Criteria());
$this->tableName = constant($class.'Peer::TABLE_NAME');
$this->offset = $offset;
}
Then I have made this tiny change around line 50
$c->setOffset($offset+$this->offset);
Works a treat!
Simpler solution would be a custom select method:
$pager->setPeerMethod('doSelectCustom');
and then put your logic in the model Peer Class:
public static function doSelectCustom($c)
{
$c2 = clone $c;
$offset = $c2->getOffset();
$limit = $c2->getLimit();
$someCustomVar = someClass::someMethod();
if ($offset == 0) // we are in the first page
{
$c2->setLimit($limit - $someCustomVar);
$c2->add(self::SOMECOLUMN, false);
} else $c2->setOffset($offset - $someCustomVar);
return self::doSelectRS($c2); // or doSelect if you wanna retrieve objects
}