Forums / Developer / Online Editor Extension - internal link list

Online Editor Extension - internal link list

Author Message

andreas spahr

Friday 28 November 2003 3:55:40 am

Hi all,

I want to improve the OE function "insert link". There should be the possibility to insert an internal link out of the own website. This is a very important feature for customers in general and is until now missing in the OE.
I publish my first draft and I hope, that some of you can help to improve it.

I modified two files: extension/ezdhtml/modules/ezdhtml/insertlink.php
and
extension/ezdhtml/design/standard/templates/ezdhtml/insertlink.tpl

Because of the large modifications in the insertlink.php I make a complete excerpt:
-----------------------------------------
<?php
//
//
// Copyright (C) 1999-2002 eZ systems as. All rights reserved.
//

if ( $VisualViewVersion == 2 )
{
ob_end_clean();
$HelpMode = "enabled";
include_once( "classes/eztemplate.php" );
$t = new eZTemplate( "extension/xmleditor/dhtml/design/standard/templates/ezdhtml/",
"ezarticle/admin/intl/", "en_GB", "medialist.php");

$t->set_file( "popup", "insertlink.tpl" );
$t->pparse( "output", "popup" );
}
else
{
include_once( "kernel/common/template.php" );
include_once( "lib/ezutils/classes/ezini.php" );

$ini =& eZINI::instance( 'content.ini' );
$classList =& $ini->variable( 'link', 'AvailableClasses' );

$Module =& $Params["Module"];

$http =& eZHttpTool::instance();

$Module->setTitle( "Insert Link" );

$tpl =& templateInit();

$tpl->setVariable( "class_list", $classList );
$tpl->setVariable( "module", $Module );

// Here starts internalLinkList
// Fetch the tree node with the root ID
$node = eZContentObjectTreeNode::fetch(1);
$node->dataMap();
// get the children from root
$children = $node->children();
$res = getInternalLinkListInfo($children, $ret);

$erg = array();
$internalLinkListInfo_i = 0;
$my_path_prefix = '/index.php/news/content/view/full/';
$internalLinkList = simplifyInternalLinkListArray($res, &$internalLinkListInfo_i, $erg, $my_path_prefix);


$tpl->setVariable( "internal_Link_List", $internalLinkList );

$Result = array();
$Result['content'] =& $tpl->fetch( "design:ezdhtml/insertlink.tpl" );
$Result['path'] = array( array( 'url' => '/ezdhtml/insertlink/',
'text' => 'Insert link' ) );
}

/*!
Retrieves info from the treenode members
Name, Class ID, Node ID of the object
*/
function getInternalLinkListInfo($children, $ret)
{
$i = 0;

foreach($children as $child)
{
// Get the object ID of the child and fetch it
$objID = $child->attribute("contentobject_id");
$obj = eZContentObject::fetch($objID);

// Load the object's datamap
$obj->dataMap();
$dataMap =& $obj->attribute( "data_map" );

// Get the class id
$clsID = $obj->attribute("contentclass_id");

$ret[$i]["NodeID"] = $child->attribute("node_id");
$ret[$i]["NodeName"] = $obj->attribute( "name" );

// The class ID of Folders == 1
// If the current child is a Folder, loop through its children
// This makes this function recursive. It'll loop through _every_ child of the glossary root
if($clsID == 1)
{
$children2 =& $child->children();
$res = getInternalLinkListInfo($children2);

$ret[$i]["Children"] = $res;
}
else
{
$ret[$i]["Children"] = null;
}

$i++;
}
// Return the result
return $ret;
}


function simplifyInternalLinkListArray( $myArrayTree, &$internalLinkListInfo_i, $erg, $my_path_prefix ) {
foreach ($myArrayTree as $item) {
while (list($key, $value) = each ($item)) {
switch($key) {
case 'ClassID':
break;
case 'NodeID':
$erg[$internalLinkListInfo_i]['NodeID'] = $my_path_prefix . $value;
break;
case 'NodeName':
$erg[$internalLinkListInfo_i++]['NodeName'] = $value;
break;
case 'Children':
if (isset($value)) {
$erg = simplifyInternalLinkListArray($value, &$internalLinkListInfo_i, $erg, $my_path_prefix);
}
break;
}
}
}
return $erg;
}
?>
-----------------------------------------

And this are the changes in the insertlink.tpl file:
-----------------------------------------
<tr>
<td>Internal Links:</td>
<td>
<select name="interneLinkListe" align="left" onchange="javascript:linkUrl.value=this.value">
<option value="">Select an internal link
{section name=internalLinkList loop=$internal_Link_List}
<option value="{$internalLinkList:item.NodeID}">{$internalLinkList:item.NodeName}</option>
{/section}
</select>
</td>
</tr>
-----------------------------------------

As you can see, my programming is not the best eZ-style, please improve it! Also the variable $my_path_prefix in the php-file is unacceptable, but I hope someone can improve it. Small peaces are copied out of the contribution 'glossary'.

eZ debug

Timing: Jan 31 2025 05:59:57
Script start
Timing: Jan 31 2025 05:59:57
Module start 'content'
Timing: Jan 31 2025 05:59:57
Module end 'content'
Timing: Jan 31 2025 05:59:57
Script end

Main resources:

Total runtime0.1471 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.0052 588.0625180.8125
Module start 'content' 0.00520.0051 768.875097.8203
Module end 'content' 0.01040.1367 866.6953541.3750
Script end 0.1471  1,408.0703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00332.2387200.0002
Check MTime0.00130.9068200.0001
Mysql Total
Database connection0.00080.528810.0008
Mysqli_queries0.097966.52491410.0007
Looping result0.00130.88461390.0000
Template Total0.136192.510.1361
Template load0.00080.541710.0008
Template processing0.135391.991510.1353
Override
Cache load0.00050.350010.0005
Sytem overhead
Fetch class attribute can translate value0.00080.540410.0008
XML
Image XML parsing0.00030.183410.0003
General
dbfile0.01057.1098200.0005
String conversion0.00000.003230.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