[CWB] [ cwb-Feature Requests-2821058 ] CQPweb: support for user CQP macros

SourceForge.net noreply at sourceforge.net
Sat Jan 23 19:38:57 CET 2010


Feature Requests item #2821058, was opened at 2009-07-14 02:40
Message generated for change (Comment added) made by andrewhardie
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=722306&aid=2821058&group_id=131809

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: CQPweb
Group: None
>Status: Closed
Priority: 6
Private: No
Submitted By: Andrew Hardie (andrewhardie)
Assigned to: Andrew Hardie (andrewhardie)
Summary: CQPweb: support for user CQP macros

Initial Comment:
Macros are an advanced syntax of CQP but the current one-command-per-process does not allow their use through the CQPweb interface. It would be nice to support this feature.

Outline solution:
-- Have a "Create / Edit Macros" option under "User controls" in the index menu
-- Use this to update a table called "user_macros" whicvh has two fields, the username and the text of the command that must be passed to CQP to create the macro
-- add a public method to the CQP object, $cqp->register_macro($macro_text), which in turn calls $this->execute()
-- add a function, user_macros_to_cqp, in user_settings.inc.php as follows:

function user_macrtos_to_cqp()
{
global $mysql_link.;
global $cqp;
global $username;

$sql_query = "SELECT macro_text FROM user_macros WHERE user='$username'";
$result = mysql_query($sql_query);
// standard error catching code here ...

while ( ($r = mysql_fetch_row($result)) !== false)
$cqp->$register_macro($r[0]);
}
/* note that all macros are thus available across all corpora */

Things to doublecheck: how does loading macros interact with setting the corpus / setting the datadir?

A nice UI improvement would then be to have a JavaScript control box next to the query-box in (index.php?thisQ=simple|restricted) with buttons for inserting the user's macros, if any have been set, at the cursor point in the text box.

(Question: can this be done using the DOM? ie assuming we can get the textarea by its idNo, is there some way of accessing cursor position?)

All due credit to H-M Lehmann who suggested this in a conversation we had at ICAME-30!

----------------------------------------------------------------------

>Comment By: Andrew Hardie (andrewhardie)
Date: 2010-01-23 18:38

Message:
Done (the macro-saving aspect that is, I haven't done the javascript insert
yet and won't unless there is call for it) --  in v2.12 but documentation
does not yet exist so it's for advanced users only.

----------------------------------------------------------------------

Comment By: Andrew Hardie (andrewhardie)
Date: 2009-07-14 02:56

Message:
Maybe also have in "User settings" a Hide / show advanced functions option,
for the Macro Create/Edit page and for other future developments, since
most users will not know what to do with the macro control as it has no
parallel from BNCweb.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=722306&aid=2821058&group_id=131809


More information about the CWB mailing list