Extension ImageMap

Author Message

Felix Laate

Tuesday 15 March 2005 11:49:38 pm

Hi all!

I'm currently working on an ImageMap extension. So far I'm through the selecting og image and the plotting of the mappoint.

Now I need to put the info into the database. I've made a class (with the fields: text, x, y and link).

I have a module-file updatedb.php, but I'm not sure what to påut into it. I tried using something I found in the forum (http://ez.no/community/forum/developer/inserting_article_through_code_problem), but it gives me this:

Cannot redeclare ezdbcleanup() (previously declared in /home/enternett/ezpublish/index.php:184

Would be be with any hints or ideas!

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Eirik Alfstad Johansen

Wednesday 16 March 2005 12:46:16 am

Hi Felix,

First of all, due to the redeclare error, it seems that you are including one or more files several times (unless you have copied the declaration of the exdbcleanup function, of course). Try using include_once() instead of include().

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Felix Laate

Wednesday 16 March 2005 1:16:47 am

Hi Erik!

There's only one file included (ezscript.php) and it's done with an include_once. Removing it gives an "Undefined class name 'ezscript'" error, so i suppose it should be included.

I also tried to use the createFolderObject() function proposed in the above mentioned link, but that gives me an "Call to a member function on a non-object" error.

Thank you for helping!

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Eirik Alfstad Johansen

Wednesday 16 March 2005 1:51:20 am

Hi Felix,

Perhaps you could post the code which generates the error?

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Felix Laate

Wednesday 16 March 2005 2:00:08 am

Well, the code originates from the thread http://ez.no/community/forum/deve...erting_article_through_code_problem as mentioned:

include_once( 'kernel/classes/ezscript.php' );

$siteaccess = "pub";

$script =& eZScript::instance( array( 'debug-message' => '',
                                      'use-session' => true,
                                      'use-modules' => true,
                                      'use-extensions' => true ) );
$script->startup();
$script->setUseSiteAccess( $siteaccess );
$script->initialize();

$currentUser=& eZUser::currentUser();
$user_id = $currentUser->attribute('contentobject_id');
$parentNodeID = 118; // testing folder
$parentContentObjectTreeNode = eZContentObjectTreeNode::fetch($parentNodeID);
$parentContentObject = $parentContentObjectTreeNode->attribute('object');
$sectionID=$parentContentObject->attribute('section_id');
$class =& eZContentClass::fetch( 30 ); //mappoint
$contentObject =& $class->instantiate( $userID, $sectionID );
$nodeAssignment =& eZNodeAssignment::create( array(
        'contentobject_id' => $contentObject->attribute( 'id' ),
        'contentobject_version' => $contentObject->attribute( 'current_version' ),'parent_node' => 118,'is_main' => 1)
);

 // Set a status for the content object version
      $version =& $contentObject->version($contentObject->attribute( 'current_version' ) );
      $version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT);
      $version->store();


$contentObjectAttributes =& $version->contentObjectAttributes();

$loopLength = count($contentObjectAttributes);

// Adding content to fields

for($i=0;$i<$loopLength;$i++)
{
   srand(time()); //just a random number to add to fields
   $random = (rand()%9);

   $text = "sometext " . $random;

   $datatype = $contentObjectAttributes[$i]->datatype();
   if($datatype->attribute('data_type_string' ) == 'eztext' || $datatype->attribute('data_type_string' ) == 'ezstring'){ 
      $contentObjectAttributes[$i]->setContent($text);
      $contentObjectAttributes[$i]->store();
   }
}

$nodeAssignment->store();
$contentObject->store();
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject->attribute( 'id' ), 'version' => 1 ) );

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Eirik Alfstad Johansen

Wednesday 16 March 2005 7:23:17 am

Hi Felix,

As the error msg says, the function eZDBCleanup() is declared twice; once in index.php at around line 182 and then again in ezscript.php at around line 1096.

I think this problem occurs because you are trying to run your script as a view to a module in addition to including the ezscript.php file. If I'm not mistaking, files that include the ezscript.php file are meant to be run separately, outside the ez interface.

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

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 21:10:57
Script start
Timing: Jan 18 2025 21:10:57
Module start 'layout'
Timing: Jan 18 2025 21:10:57
Module start 'content'
Timing: Jan 18 2025 21:10:57
Module end 'content'
Timing: Jan 18 2025 21:10:57
Script end

Main resources:

Total runtime0.9681 sec
Peak memory usage4,096.0000 KB
Database Queries66

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0079 587.7969152.6094
Module start 'layout' 0.00790.0030 740.406339.4297
Module start 'content' 0.01090.9559 779.8359581.4063
Module end 'content' 0.96670.0013 1,361.242220.1875
Script end 0.9680  1,381.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.3521160.0002
Check MTime0.00130.1382160.0001
Mysql Total
Database connection0.00100.102510.0010
Mysqli_queries0.896992.6460660.0136
Looping result0.00070.0747640.0000
Template Total0.935096.620.4675
Template load0.00230.235720.0011
Template processing0.932796.347520.4664
Template load and register function0.00010.010410.0001
states
state_id_array0.00080.082510.0008
state_identifier_array0.00090.092020.0004
Override
Cache load0.00200.2101350.0001
Sytem overhead
Fetch class attribute can translate value0.00150.155520.0008
Fetch class attribute name0.00200.203080.0002
XML
Image XML parsing0.00080.087520.0004
class_abstraction
Instantiating content class attribute0.00000.0029120.0000
General
dbfile0.00110.1120220.0000
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs