1
I spend a fair amount of time building the links database, and find myself regularly cutting and pasting between browser tabs (thank you Firefox) from a cool page to the XOOPS "new link" admin form.
I thought it would be useful if I'd be able to select some text off a page, then have a javascript link paste the page url, title and selected text into the link form.
I looked at the WordPress example, and modified it to do something like this (line breaks inserted for readability, in reality the entire code below needs to fit in one line starting with js without the spaces, and be saved as a bookmark in your browser):
j a v a s c r i p t:if(navigator.userAgent.indexOf('Safari' >= 0){
Q=getSelection();
}else{
Q=document.selection
?document.selection.createRange().text
:window.getSelection();
}
void(window.open(
'http://my.xoops.site/modules/mylinks/index.php'
+'?op=linksConfigMenu'
+'&popuptext='+escape(Q)
+'&popupurl='+escape(location.href)
+'&popuptitle='+escape(document.title),
'xoops bookmarklet',
'scrollbars=yes,
width=600,
height=460,
left=100,
top=150,
status=yes'));
Passing data into the forms in file
/modules/mylinks/admin/index.php (function linksConfigMenu) is just a matter of replacing (around line 185):
echo "";
echo "right" nowrap>"._MD_SITEURL." | "; echo "http://">"; echo " |
";
echo "right" nowrap>"._MD_CATEGORYC." | "; $mytree->makeMySelBox("title", "title"); echo "right" valign="top" nowrap>"._MD_DESCRIPTIONC." | n"; xoopsCodeTarea("description",60,8); with: echo ".$_GET['popuptitle'].">"; /* CHANGE */ echo "
| right" nowrap>"._MD_SITEURL." | "; echo "$_GET['popupurl']."">"; /* CHANGE */ echo " | "; echo "right" nowrap>"._MD_CATEGORYC." | "; $mytree->makeMySelBox("title", "title"); echo "right" valign="top" nowrap>"._MD_DESCRIPTIONC." | n"; xoopsCodeTarea("description",60,8,null,stripslashes($_GET['popuptext'])); /* CHANGE */ Passing the selected text involves modifying file /include/xoopscode.php, adding a $textarea_content parameter: function xoopsCodeTarea($textarea_id, $cols=60, $rows=15, $suffix=null, $textarea_content='') then replacing (around line 72): $areacontent = isset( $GLOBALS[$textarea_id] ) ? $GLOBALS[$textarea_id] : ''; with: $areacontent = isset( $GLOBALS[$textarea_id] ) ? $GLOBALS[$textarea_id] : $textarea_content;
Presumably, no one would even be able to access the admin add/modify links page without having signed in with proper admin credentials, but I would appreciate if you'd put in your 2 cents and let me know whether the above hack introduces vulnerability.
Thanks, Eric
P.S. Code wasn't tested under Safari.
373 user(s) are online (259 user(s) are browsing Support Forums)
Members: 0
Guests: 373
more...
Stats |
Goal: |
$100.00 |
Due Date: |
Nov 30 |
Gross Amount: |
$0.00 |
Net Balance: |
$0.00 |
Left to go: |
$100.00 |
|
| | |