CVS edit link for Qwaygon

hello, i want to maintain a module called QMenu (name isnt important and a subject to change if you with to) that allow users to create menu entries and map some content to them, for now it can be a node, view or regular drupal path, the difference between this module and [admin/build/menu] it that my module allow your items to be localtasks... well basicly it IS the main goal, to map some content to local tasks, additionaly content that will be attached to menu item can be parametrised with some default parametres or wildcards (% chunks from original menu destination), basicly it allow user to use power of hook_menu without writing own code.

I guess glance view on working site will give you more information than a walls of text explaining every single feature, but before do that lets see on check-list here http://drupal.org/node/59
i will shrink some base text

1. Your module shows no hint of Coding Standards.

No it do respect them, i try to follow drupal coding standard as closely as i can, and always use coder-module as a polisher to my code.

2. Your module outputs a lot of HTML but there's not a theme function in to be found in the code anywhere.

it does not output any html tag due to its logic, but i always use hook_theme for all custom output and templates for parts that end-user will see

3. Your module has a lot of string literals but not a hint of t()?

all string that user will see run through t() directly or indirectly via other built-in functions, i supose i can miss some but its totaly an exception that must be fixed as soon as i find such thing.

4. Some security advice. One of the first checks is to count how many times you have used check_plain() and how often %d appears in you module.

all user input that is goin to be displayed is run through check_plain() and all queries are made through according placeholders

5. Your module pulls in a lot of JavaScript code in-line without a hint of jQuery involvement.

this module does not use js, but rely on my other two supporting modules, witch all a following this check list, one of them extend standart ahah capabilities overriding built-in drupal ahah file, that functionality as i planing will be moved from it to another standalone module extending and easing ahah and ajax routine for me and maybe others, but this is another story.

6. Many people write good motivation messages and then mess it up right at the end with "here's a link to my contribution, it's about 75% done".

module's logic is complete, and its future depend on either it goes to CVS and i will write good coments and docs, or it does not and i leave it as is in second case it 100% complete.

ok now lets see how it works, well i was inspired by Matt Petrowsky from GotDrupal.com when in one of his video (http://gotdrupal.com/videos/drupal-views-arguments) he says that how it would be cool if drupal have such functionality in menu UI to create menu items and map them with % to some content... well that my module is doing! so in case you see that video i was building demo site in the almost same envierment.

so we have
a) site here http://test.in-place.org.ua/
b) user "JOE BLOGGER" with password "testQmenu" (log in to see it in action)
c) role BLOGGER that can blog AND have premission "administer qmenu" so you can see how it look like when you administrating them, obviously "JOE BLOGGER" has assigned to this role
d) as i mention earlier there currently 3 types of source content supported - node, view, path. as you login as JOE BLOGGER and click "my account" you will notice 4 additional tabs (LOCAL_TASKS) on your screen, first 3 are represent each of source type, but before you click them, let me briefly explain what you can expect

first: # Blogger`s check list (node) - is a standart node (Page type) created by root and mapped to this local task, this can be some quick reference, or check list, or reminder or whatever should be always by the hand (i'm planning to create bookmar module and that could be on that page too, but thats again another story) depending on what content available on site

second: # Blog posts (view test) - this is what Matt Petrowsky want to have in drupal, that tab linked to a view that display users blog posts, and user argument extracted from an URL and mapped to a view as parametr

third: # QMenu (path test) - this is actualy 3 mapped path as this task has 2 subtasks. this is a mapped interface for managing QMenu where you can see how it organised, what parameters can be added for different source types and test some features. here is another way of use this module - display same pages in more than one places, from a module-designer view i want this manage QMenu interface was near standart Menu in adnim/build but poorly JOE blogger cant see that even if he has "administer qmenu" premisison, so i mapped that into his "my account" page.

fourth: this was created by root and point to admin/build where JOE BLOGGER should not have access click it (JOE BLOGGER cant even create such links to places where he have not access)

well all after it's up to you - try to create some mapping also try to map something that you shouldn't have access like "admin"

and few words on security, in addition to access premissions that you can set for the menu item itself following will apply
for node: node_access('view', $node)
for path: all security checks that that path would normaly check
for view: well it up to view designer check incoming paramenres

p.s. to create an entry first press preview and if you have access to that source type - submit button will apear withing prebiew of source content

with best regard, and thank you for even reading all this.. if you of course do :)

CommentFileSizeAuthor
#4 send.zip9.32 KBqwaygon
#2 modules2.zip22.27 KBqwaygon
#1 qmenu.zip18.58 KBqwaygon

Comments

qwaygon’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new18.58 KB

this is the module

qwaygon’s picture

StatusFileSize
new22.27 KB

time past, and supported ahah (qtools_ahah) module that was suposed to fit the needs of QMenu become the real essence of my desires, and probably more valuable than QMenu itself, i DO belive that it worth at least looking at becouse as for me it so useful and flexible that i will definetly use it to the rest of my life, even that it only provide some api, it is well self-documented clean and coder say its ok, it pass all checks here http://drupal.org/node/59. i don't write separate example module but QMenu is used its features so QMenu can be an example module

so here is a question what should i do since QMenu forms manipulation significally changed in backend according to qtools_ahah new features:

a) add reworked code to this issue with (the changes does not affect any functionality or logic, only form ahah handling part, it become more secure, more clean, more flexible and less coded) (i will actually do this)

b) write here an appication for qtools_ahah moving to CVS (i'd be happy to maintain both, but dont want abuse CVS, so if i have to choose with one is more important for me and community i belive its "qtools_ahah") from its name you can think that its just another "ahah_helper" module but i saw code for ahah_helper, and this module much more than that, so much that if i want to comaintain "ahah_helper" it will has to be rewriting from scratch, here i use completly different way, much more flexible, richer, and secure. since qtools_ahah module is well self documented - please glance on it and if you thinks that it "might" be ok for CVS - i will write complete application here or create a new one . from now "qtools_ahah" dont have any dependencies, and completly 100% finished standalone module, QMenu included in this acrhive is an example of using "qtools_ahah" module, if you decide to give it a chance - start straight from qtools_ahah.module there is a dosens of comment there (grammar may be horroble and a lot of typo in coments, but if this goes to CVS its obviouse will be fixed)

p.s. i don't mean any harm for "ahah_helper" its just accomplish different goals

avpaderno’s picture

Status: Needs review » Needs work
/**
 * this file contain a replacenet for [Drupal.ahah.prototype.success] in [ahah.js] 
 * extending it functionality to replace multiply different parts of html
 */

It seems that the file is duplicating code already present in misc/ahah.js, rather than extending it.

qwaygon’s picture

StatusFileSize
new9.32 KB

whell mostly yes for now, the reason it is so - its becouse i can't just extend Drupal.ahah.prototype.success function without changing original drupal files (and that would be not in drupal way) so i have to cut whole function in to my file to inject a little loop for each "extra" piece, at the time of this writings injection also allow evaluting js on client side and look like this

    //================================================================================QTOOLS_AHAH_EXTRA
    //================================================================================
    //================================================================================
    //======================== start loop
if (response.qtools_ahah_targets){
    //alert(response.qtools_ahah_targets);
    for (var key in response.qtools_ahah_targets){
        //======================== opening iteration, presetting our variables
        qt_target = response.qtools_ahah_targets[key];
        //alert(qt_target);
        var qt_element = eval('response.'+qt_target);
		if (qt_element.type == 'script')
		{
			if ((qt_element.prefix != null) && (qt_element.suffix != null)){
				str = qt_element.prefix + 'qt_element.data'+qt_element.suffix;
			}
			else {
				str = qt_element.data;
			}
			//alert(qt_element.type);
			eval(str);
			continue;
		}
        //alert(qt_element.target);
        //alert(qt_element.data);
        var wrapper = $(qt_element.target);
        var new_content = $('<div></div>').html(qt_element.data);
        //======================== drupl code

doesn't look very shiny but do its job and future is depend on eaither it goes to CVS

with this feature comes i've change a 4.4 part of qtools_ahah_page_callback doc

  4.4) calling all <callback> = 'output' with list of params ($output, $tmp_extra, $form, $form_state, $ahah_key)
 * this is where modules can actualy set a respond that will be sended to browser $form, $form_state, $ahah_key
 * is self explained, lets look at $output
 *  this is associative array where module should add a key corresponding to module name and a value that will be 
 * converted to json, for example $output['test_module'] = drupal_render($form['changed part']); after this callback
 * the actual output will be $output = implode('', $output); and the imploded output will be send as 
 * assigned to 'data' json key
 *
 * $extras - this is what this module all about! you probably shoudn't use this module unless you need to use extra, but if
 * you do - you probably will leave $output blank and set '#ahah' target to unexisting id, managing all ahah trough extras
 * $output is only here for capability purpose and easing rebuilding existing forms for use with this module
 *   $extra is an associative array, where each module should add keys (if needed of course) according to module name, 
 *   and the value should be an array of extras that module should output, with following parametres, example
 *   for extra html chunk (like default ahah aoutput)
 *
 *   $extra['test_module'][<delta>] = array( //<delta is just a key, no actual using anywhere>
 *       'target' => '#target_extra_id', //(data will be put in shis selector container)
 *       'data' => 'data' //(this is the same meaning as output data, here should be html that must be inserted into 'target' selector)
 *   )
 *
 *   for extra js
 *
 *   $extra['test_module'][<delta>] = array( //<delta is just a key, no actual using anywhere>
 *       'type' => 'script', //(flag this extra as js extra)
 *       'data' => 'data', //(in case you didnt specify 'prefix' or 'suffix' fields this vill be eval'ed at the client side)
 *       'prefix' => //if is set and 'suffix' is set the evaled string vill be as follow: preffix+'data'+suffix, so you can pass data as a parametr to some function without escaping quotas and control charasters
 *       'suffix' => 'see prefix above'
 *   )
 *   JS Over AHAH is another cool feature of this module that gives you complete control over page displayed,
 *   however while you can print any script through this feature - its design and purpose was to let you send 
 *   a little pieses of js that will gives your clientside scripts and objects a clue about what hapened, 
 *   as an example jcarousel, you can rewrite <li>'s with your content but you probably want to tell jcarousel
 *   to readjust size or reset its content before inserting new one, becouse if you dont - it will be looks broken in many cases
 ... so with this module its all is essential as a part of comunicating with a browser.
 * after all extras are sullpied upper two levels of array will be merged with $extra_key = ['test_module'.'_'.<delta>]

and just in case we have switched from QMenu to qtools_ahah here are demo site for you
url: http://dp.in-place.org.ua/
user: barefoot
pass: but.smart

nevermind about what happening on the site since it was a demo for my friend, BUT it also uses all features of qtools_ahah to aka "server side" managing of jcarousel
when you in, go to http://dp.in-place.org.ua/node/14/manage there will be managing interface for my implementation for galleries and images , what we are interesting about is bottom 2 regions
1st - QImage already attached to this gallery...
2nd - QImage that are not attached to any QGallery

so lets see qtools_ahah in action
a) select some images in 2nd region and press attach, qtools_ahah will refresh 4 separated div-s (2 selects for paging and 2 ul-s from jcarousels) this is multiply extras test, the target on actual button's '#ahah' property is set to unexisted ID and all 4 pieses goes trough extras

and after you do that you will note that 1st region while contain added images looks broken, thats becouse we just print content inside a carousel but the initial size of carousel stay unchanged and result in "vertical row" of images

b) attach ALL images to the gallery (so the 2nd region become empty) and refresh the page, now 2nd regions jcarousel size is set to 1 (ther are single message)... now select some images from 1st region and press detach. This time items goes to the bottom jcarousel and all looks fine, becouse in this time we add another 2 extras

    $extra['qgallery'][] = array(
        'type' => 'script',
        'data' => " Drupal.settings.jcarousel['#detached-list-target'].jcarousel.size(". $count .");",
    );
    $extra['qgallery'][] = array(
        'type' => 'script',
        'data' => "Drupal.settings.jcarousel['#detached-list-target'].jcarousel.reset();",
    );

that tels our carousel that we going to manipulate images so it can rearange itself.

in attachment you will find current qtools_ahah used module on that site and a part from qgallery module that contain complete hook_qtools_ahah_access(); implemenation for whole page, and handling AHAH key = 'qgallery/manage/detach/%' section (as you can note both "detach" and "attach" buttons use same function for refreshing page).

p.s. qtools_ahah.module doesn't have many changes, just add a hook_perm and extend coments for main function

qwaygon’s picture

Status: Needs work » Needs review
avpaderno’s picture

i can't just extend Drupal.ahah.prototype.success

I have seen some JavaScript functions that has been copied as they are from the file ahah.js. If you need to change a function, there isn't the need to copy the functions that are not changed.

qwaygon’s picture

yes but it IS changed... hm... i downloaded modules2.zip from #2 post just to check , unpack and look at qtools_ahah.js it contain changed part that hard to be missed with huge coment

    //================================================================================QTOOLS_AHAH_EXTRA
    //================================================================================
    //================================================================================
    //======================== start loop
if (response.qtools_ahah_targets){
    //alert(response.qtools_ahah_targets);
    for (var key in response.qtools_ahah_targets){
        //======================== opening iteration, presetting our variables
        qt_target = response.qtools_ahah_targets[key];
        //alert(qt_target);
        var qt_element = eval('response.'+qt_target);
        //alert(qt_element.target);
        //alert(qt_element.data);
        var wrapper = $(qt_element.target);
        var new_content = $('<div></div>').html(qt_element.data);
        //======================== drupl code

the send.zip from #4 have even more changed text (see first code snippet in #4 coment) while that are not "1000 lines of chage" they ARE nessesary (nvm for all comented alerts)

so i don't realy understand what do you mean by "there isn't the need to copy the functions that are not changed." while that clearly has a point :) it does not apply to this case, becouse this function definetly CHANGED in qtools_ahah.js

avpaderno’s picture

Status: Needs review » Fixed

Thank you for your contribution! I am going to update your account.

These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

avpaderno’s picture

Component: Miscellaneous » new project application
Assigned: Unassigned » avpaderno
Issue summary: View changes