Forums / Extensions / eZ Flow / Change the priority in the list valid of block manual

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

eZ debug

Timing: Jan 18 2025 02:56:17
Script start
Timing: Jan 18 2025 02:56:17
Module start 'content'
Timing: Jan 18 2025 02:56:17
Module end 'content'
Timing: Jan 18 2025 02:56:17
Script end

Main resources:

Total runtime0.1437 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 587.9844180.7578
Module start 'content' 0.00700.0063 768.7422103.1484
Module end 'content' 0.01330.1303 871.8906547.1719
Script end 0.1436  1,419.0625 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00362.5282200.0002
Check MTime0.00171.1719200.0001
Mysql Total
Database connection0.00100.668110.0010
Mysqli_queries0.097868.04911410.0007
Looping result0.00120.86941390.0000
Template Total0.130090.510.1300
Template load0.00070.480310.0007
Template processing0.129390.004910.1293
Override
Cache load0.00040.303410.0004
Sytem overhead
Fetch class attribute can translate value0.00070.484410.0007
XML
Image XML parsing0.00030.204610.0003
General
dbfile0.00463.2355200.0002
String conversion0.00000.005630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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