Change the priority in the list valid of block manual

Author Message

Bin LIU

Friday 18 April 2008 6:31:56 am

In the version now, When we published the bloc manual, i can't change the priority of articles in the block list.

So, if you want change the priority, do like this :

a. In the end of extension/ezflow/design/ezflow/templates/content/datatype/edit/ezpage.tpl
add :

<script type="text/javascript"><!--
{literal}
YAHOO.namespace( "liubin" );
(function() {

var Dom = YAHOO.util.Dom;
var Event = YAHOO.util.Event;
var DDM = YAHOO.util.DragDropMgr;

{/literal}
// app

YAHOO.liubin.DDApp = {ldelim}
    init: function() {ldelim}
{foreach $attribute.content.zones as $zone_id => $zone}
    {if and( is_set( $zone.blocks ), $zone.blocks|count() )}
    {foreach $zone.blocks as $block_id => $block}
      
         new YAHOO.util.DDTarget("z:{$zone_id}_b:{$block_id}_o");
        {foreach $block.valid as $item}
            dd{$zone_id}{$block_id}{$item.object_id} = new YAHOO.liubin.DDList("z:{$zone_id}_b:{$block_id}_i:{$item.object_id}");

            dd{$zone_id}{$block_id}{$item.object_id}.setHandleElId("z:{$zone_id}_b:{$block_id}_i:{$item.object_id}_h");
        {/foreach}
        
    {/foreach}
    {/if}
{/foreach}

    {rdelim}

{rdelim};
{literal}
// custom drag and drop implementation

YAHOO.liubin.DDList = function(id, sGroup, config) {

    YAHOO.liubin.DDList.superclass.constructor.call(this, id, sGroup, config);

    this.logger = this.logger || YAHOO;
    var el = this.getDragEl();
    Dom.setStyle(el, "opacity", 0.67); // The proxy is slightly transparent

    this.goingUp = false;
    this.lastY = 0;
};

YAHOO.extend(YAHOO.liubin.DDList, YAHOO.util.DDProxy, {

    startDrag: function(x, y) {
        this.logger.log(this.id + " startDrag");

        // make the proxy look like the source element
        var dragEl = this.getDragEl();
        var clickEl = this.getEl();
        Dom.setStyle(clickEl, "visibility", "hidden");

        dragEl.innerHTML = clickEl.innerHTML;

        Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
        Dom.setStyle(dragEl, "backgroundColor", Dom.getStyle(clickEl, "backgroundColor"));
        Dom.setStyle(dragEl, "border", "2px solid gray");
    },

    endDrag: function(e) {

        var srcEl = this.getEl();
        var proxy = this.getDragEl();

        // Show the proxy element and animate it to the src element's location
        Dom.setStyle(proxy, "visibility", "");
        var a = new YAHOO.util.Motion( 
            proxy, { 
                points: { 
                    to: Dom.getXY(srcEl)
                }
            }, 
            0.2, 
            YAHOO.util.Easing.easeOut 
        )
        var proxyid = proxy.id;
        var thisid = this.id;

        // Hide the proxy and show the source element when finished with the animation
        a.onComplete.subscribe(function() {
                Dom.setStyle(proxyid, "visibility", "hidden");
                Dom.setStyle(thisid, "visibility", "");
            });
        a.animate();

        var url;
        var tableBody = srcEl.parentNode;
        var postData = "";
        var items = tableBody.getElementsByTagName("tr");
        for (i=0;i<items.length;i=i+1) {
            postData += "Items%5B%5D=" + items[i].id + "&";
        }

        var tableID = tableBody.parentNode.id;
{/literal}
alert(tableID);
        postData += 'Block=' + tableID + '&ContentObjectAttributeID=' + {$attribute.id} + '&Version=' + {$attribute.version};
        url = "{'/ezflow/request'|ezurl(no)}";
        YAHOO.util.Connect.asyncRequest( 'POST', url, false, postData );
{literal}

    },

    onDragDrop: function(e, id) {

        // If there is one drop interaction, the li was dropped either on the list,
        // or it was dropped on the current location of the source element.
        if (DDM.interactionInfo.drop.length === 1) {

            // The position of the cursor at the time of the drop (YAHOO.util.Point)
            var pt = DDM.interactionInfo.point; 

            // The region occupied by the source element at the time of the drop
            var region = DDM.interactionInfo.sourceRegion; 

            // Check to see if we are over the source element's location.  We will
            // append to the bottom of the list once we are sure it was a drop in
            // the negative space (the area of the list without any list items)
            if (!region.intersect(pt)) {
                var destEl = Dom.get(id);
                var destDD = DDM.getDDById(id);
                destEl.appendChild(this.getEl());
                destDD.isEmpty = false;
                DDM.refreshCache();
            }

        }
    },

    onDrag: function(e) {

        // Keep track of the direction of the drag for use during onDragOver
        var y = Event.getPageY(e);

        if (y < this.lastY) {
            this.goingUp = true;
        } else if (y > this.lastY) {
            this.goingUp = false;
        }

        this.lastY = y;
    },

    onDragOver: function(e, id) {
    
        var srcEl = this.getEl();
        var destEl = Dom.get(id);

        // We are only concerned with list items, we ignore the dragover
        // notifications for the list.
        if (destEl.nodeName.toLowerCase() == "tr") {
            var orig_p = srcEl.parentNode;
            var p = destEl.parentNode;

            if (this.goingUp) {
                p.insertBefore(srcEl, destEl); // insert above
            } else {
                p.insertBefore(srcEl, destEl.nextSibling); // insert below
            }

            DDM.refreshCache();
        }
    }
});

Event.onDOMReady(YAHOO.liubin.DDApp.init, YAHOO.liubin.DDApp, true);

})();



{/literal}
--></script>

b. in the extension/ezflow/modules/ezflow/request.php line 49

change

	    foreach( $block->getWaitingItems() as $blockItem )
	    {
	        if( $blockItem->attribute( 'object_id' ) == $itemParams['i'] )
	        {
	                if( $blockItem->toBeAdded() )
		            {
		                $blockItem->setAttribute( 'priority', $key + 1 );
		                $items[] = $blockItem;
		            }
		            else
		            {
		                $tmpItem =& $block->addItem( new eZPageBlockItem() );
		                $tmpItem->setAttribute( 'priority', $key + 1 );
		                $tmpItem->setAttribute( 'object_id', $blockItem->attribute( 'object_id' ) );
		                $tmpItem->setAttribute( 'ts_publication', $blockItem->attribute( 'ts_publication' ) );
		                $tmpItem->setAttribute( 'action', 'modify' );
		                $items[] = $tmpItem;
		            }
	        }
	    }

by

    /************added by LIU Bin for move the bloc valid begin****/
    if(array_key_exists("o",$blockParams))
    {
        foreach( $block->getValidItems() as $blockItem )
    	{
	        if( $blockItem->attribute( 'object_id' ) == $itemParams['i'] )
	        {
	
	                $tmpItem =& $block->addItem( new eZPageBlockItem() );
	                $tmpItem->setAttribute( 'priority', $key + 1 );
	                $tmpItem->setAttribute( 'object_id', $blockItem->attribute( 'object_id' ) );
	                $tmpItem->setAttribute( 'action', 'modify' );
	                $items[] = $tmpItem;
	
	        }
    	}
    }
    else
    {
    	 /************added by LIU Bin for move the bloc valid end****/
	    foreach( $block->getWaitingItems() as $blockItem )
	    {
	        if( $blockItem->attribute( 'object_id' ) == $itemParams['i'] )
	        {
	                if( $blockItem->toBeAdded() )
		            {
		                $blockItem->setAttribute( 'priority', $key + 1 );
		                $items[] = $blockItem;
		            }
		            else
		            {
		                $tmpItem =& $block->addItem( new eZPageBlockItem() );
		                $tmpItem->setAttribute( 'priority', $key + 1 );
		                $tmpItem->setAttribute( 'object_id', $blockItem->attribute( 'object_id' ) );
		                $tmpItem->setAttribute( 'ts_publication', $blockItem->attribute( 'ts_publication' ) );
		                $tmpItem->setAttribute( 'action', 'modify' );
		                $items[] = $tmpItem;
		            }
	        }
	    }
 /************added by LIU Bin for move the bloc valid begin****/
    }
 /************added by LIU Bin for move the bloc valid end****/

c. the line 777 in extension/ezflow/datatypes/ezpage/ezpagetype.php

after :

 $db->query( "UPDATE ezm_pool SET ts_publication='" . $item->attribute( 'ts_publication' ) . "'
                                                               WHERE object_id='" . $item->attribute( 'object_id' ) . "'" );

add code :

 /************added by LIU Bin for move the bloc valid****/
                                        	$sql =  "UPDATE ezm_pool SET priority='" . $item->attribute( 'priority' ) . "'
                                                WHERE object_id='" . $item->attribute( 'object_id' ) . "' and  block_id='$blockID'" ;
                                        	$db->query($sql);

Then, we can drag and drop in the block valid list.

And By a way, for the block manual. the order of the list in ezflow edition is contrary order in the front. it's a bug. i reverse the array $block.valid in the template front

I think it will be fixed in the futur version

=== Lagardère Active ===

Fetch random
http://projects.ez.no/la_fetch_random
LA Static Cache
http://projects.ez.no/lastaticcache
LA Bookmarks (jquery)
http://projects.ez.no/labookmark
LA Calendar (jquery)
http://projects.ez.no/lacalendar

My site ez
http://lingping.info

Łukasz Serwatka

Wednesday 09 July 2008 11:32:14 pm

Implemented in ezflow 1.0-1 and ezflow 1.1-0 (next version).

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 04:16:52
Script start
Timing: Jan 18 2025 04:16:52
Module start 'layout'
Timing: Jan 18 2025 04:16:52
Module start 'content'
Timing: Jan 18 2025 04:16:52
Module end 'content'
Timing: Jan 18 2025 04:16:52
Script end

Main resources:

Total runtime0.0140 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 589.3047152.6563
Module start 'layout' 0.00520.0031 741.960939.5078
Module start 'content' 0.00830.0038 781.468898.5703
Module end 'content' 0.01210.0019 880.039142.3047
Script end 0.0140  922.3438 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002316.6907140.0002
Check MTime0.00117.7326140.0001
Mysql Total
Database connection0.00075.125010.0007
Mysqli_queries0.003323.323530.0011
Looping result0.00000.086710.0000
Template Total0.001611.410.0016
Template load0.00085.917110.0008
Template processing0.00085.425910.0008
Override
Cache load0.00064.191810.0006
General
dbfile0.00011.018280.0000
String conversion0.00000.071440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs