Open skybluesofa opened 9 years ago
Hmm have you tried uninstalling and re-installing the plugin? I know there are some errors that are happening on install but the plugin should still work. Are you creating your elements in site/elements/
?
There were no active system events for the plugin. I ticked the 'OnManagerPageBeforeRender' event and it started working. I'm betting this isn't the right event, though. What's the best event to activate?
Oh, and I had to name the chunk with a .tpl extension. Is this the correct extension? Can I use any extension for any element?
Great thanks for working that out, I'll try to get that fixed soon. You should be using the OnWebPageInit
and OnManagerPageInit
events.
You can create your element files with whatever extension you like and it should work, however when ElementHelper comes across an element in the manager that doesn't have a static file assigned it will create one using .tpl for chunks and templates. Snippets and plugins will be created with .php.
I found your code while trying to figure out ways to not need to reinvent the wheel with each new site I create. When I installed 2.0.0a, I got the errors below. New elements don't seem to get created. Not sure if the errors are correlated or cause this.
Any help would be appreciated.
Console running... Attempting to install package with signature: elementhelper-2.0.0-alpha-1 Package found...now preparing to install. Grabbing package workspace... Workspace environment initiated, now installing package... INSERT INTO
modx_site_plugins
(id
,source
,property_preprocess
,name
,description
,editor_type
,category
,cache_type
,plugincode
,locked
,disabled
,moduleguid
,static
,static_file
) VALUES (:id, :source, :property_preprocess, :name, :description, :editor_type, :category, :cache_type, :plugincode, :locked, :disabled, :moduleguid, :static, :static_file) Array ( [/:id\b/] => 1 [/:source\b/] => 0 [/:property_preprocess\b/] => 0 [/:name\b/] => 'ElementHelper' [/:description\b/] => 'Creates elements automatically from static files.' [/:editor_type\b/] => 0 [/:category\b/] => 0 [/:cache_type\b/] => 0 [/:plugincode\b/] => '\$default_core_path = \$modx->getOption(\'core_path\') . \'components/elementhelper/\';\r\n\$core_path = \$modx->getOption(\'elementhelper.core_path\', null, \$default_core_path);\r\n\r\n\$usergroups = explode(\',\', \$modx->getOption(\'elementhelper.usergroups\', null, \'Administrator\'));\r\n\r\n// Return if the user isn\'t part of one of the allowed usergroups \r\nif ( ! \$modx->user->isMember(\$usergroups))\r\n{\r\n return;\r\n}\r\n\r\n// Load in our classes\r\n\$modx->loadClass(\'FileHelper\', \$core_path . \'model/\', true, true);\r\n\$modx->loadClass(\'Element\', \$core_path . \'model/\', true, true);\r\n\$modx->loadClass(\'ElementHelper\', \$core_path . \'model/\', true, true);\r\n\$modx->loadClass(\'ElementSync\', \$core_path . \'model/\', true, true);\r\n\r\n// Path to the element sync json file\r\n\$element_sync_file = MODX_BASE_PATH . \$modx->getOption(\'elementhelper.element_sync_file_path\', null, \'site/elements/element_sync.json\');\r\n\r\n// Initialize the classes\r\n\$element_helper = new ElementHelper(\$modx);\r\n\$element_sync = new ElementSync(\$modx, \$element_sync_file);\r\n\r\n\$element_types = array(\r\n \'modTemplate\' => \$modx->getOption(\'elementhelper.template_path\', null, \'site/elements/templates/\'),\r\n \'modChunk\' => \$modx->getOption(\'elementhelper.chunk_path\', null, \'site/elements/chunks/\'),\r\n \'modSnippet\' => \$modx->getOption(\'elementhelper.snippet_path\', null, \'site/elements/snippets/\'),\r\n \'modPlugin\' => \$modx->getOption(\'elementhelper.plugin_path\', null, \'site/elements/plugins/\')\r\n);\r\n\r\n// Loop through the element types\r\nforeach (\$element_types as \$type => \$type_path)\r\n{\r\n \$log_prefix = sprintf(\'[ElementHelper] %s: \', \$type);\r\n \$file_list = FileHelper::get_directory_file_list(MODX_BASE_PATH . \$type_path);\r\n\r\n // Move onto the next element type if it has no files\r\n if (empty(\$file_list))\r\n {\r\n \$modx->log(MODX_LOG_LEVEL_INFO, \$log_prefix . \'No files.\');\r\n\r\n continue;\r\n }\r\n\r\n // Process the files for this element type\r\n foreach (\$file_list as \$file_path)\r\n {\r\n \$file = FileHelper::get_file_meta(\$file_path);\r\n \$element = Element::get(\$modx, \$type, \$file[\'name\']);\r\n\r\n // If the file is not in the sync\r\n if ( ! \$element_sync->has_element(\$type, \$file[\'name\']))\r\n {\r\n // If the element doesn\'t exist\r\n if ( ! \$element)\r\n {\r\n // Create the element\r\n \$element = Element::create(\$modx, \$type, \$file[\'name\']);\r\n\r\n // If the element is created successfully set it\'s properties and then add it to the sync\r\n if (\$element)\r\n {\r\n \$properties = \$element_helper->get_file_element_properties(\$type_path, \$file_path);\r\n\r\n if (\$element->set_properties(\$properties))\r\n {\r\n \$element_sync->add_element(\$type, \$file[\'name\'], \$file[\'mod_time\']);\r\n }\r\n }\r\n }\r\n else\r\n {\r\n \$modx->log(MODX_LOG_LEVEL_INFO, \$log_prefix . \'An element with the name [\' . \$file[\'name\'] . \'] already exists. Unable to sync the file and element.\');\r\n }\r\n }\r\n else\r\n {\r\n // If the element doesn\'t exist\r\n if ( ! \$element)\r\n {\r\n // Delete the file and remove it from the sync if successful\r\n if (unlink(\$file_path))\r\n {\r\n \$element_sync->remove_element(\$type, \$file[\'name\']);\r\n }\r\n }\r\n else\r\n {\r\n // If file has been updated, update the element and sync\r\n if (\$file[\'mod_time\'] > \$element_sync->get_element_mod_time(\$type, \$file[\'name\']))\r\n {\r\n \$properties = \$element_helper->get_file_element_properties(\$type_path, \$file_path);\r\n\r\n if (\$element->set_properties(\$properties))\r\n {\r\n \$element_sync->add_element(\$type, \$file[\'name\'], \$file[\'mod_time\']);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Process the elements for this element type\r\n foreach (\$modx->getCollection(\$type) as \$element_object)\r\n {\r\n \$element = Element::insert(\$element_object);\r\n \$name = \$element->get_property(\'name\');\r\n \$category = \$element->get_property(\'category\');\r\n \$file_path = \$element_helper->build_element_file_path(\$type, \$type_path, \$name, \$category);\r\n\r\n // If a file with this element name doesn\'t exist\r\n if ( ! file_exists(\$file_path))\r\n {\r\n // If the element is not in the sync\r\n if ( ! \$element_sync->has_element(\$type, \$name)) \r\n {\r\n \$properties = \$element_helper->get_element_static_file_properties(\$element, \$file_path);\r\n\r\n if (\$element->set_properties(\$properties))\r\n {\r\n \$file_mod_time = filemtime(\$file_path);\r\n \$element_sync->add_element(\$type, \$name, \$file_mod_time);\r\n }\r\n }\r\n else\r\n {\r\n // Remove the element and remove it from the sync if successful\r\n if (\$element->remove())\r\n {\r\n \$element_sync->remove_element(\$type, \$name);\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n\$log_prefix = \'[ElementHelper] modTemplateVar: \';\r\n\$tv_file_path = MODX_BASE_PATH . \$modx->getOption(\'elementhelper.tv_file_path\', null, \'site/elements/template_variables.json\');\r\n\r\nif (file_exists(\$tv_file_path))\r\n{\r\n \$tv_file_contents = file_get_contents(\$tv_file_path);\r\n \$tv_file_mod_time = filemtime(\$tv_file_path);\r\n \$tvs = (\$tv_file_contents !== \'\' ? json_decode(\$tv_file_contents) : array());\r\n \$flagged_tvs = array();\r\n\r\n // Loop through the template variables in the file\r\n foreach (\$tvs as \$i => \$tv)\r\n {\r\n \$element = Element::get(\$modx, \'modTemplateVar\', \$tv->name);\r\n\r\n // If the element is not in the sync\r\n if ( ! \$element_sync->has_element(\'modTemplateVar\', \$tv->name))\r\n {\r\n // If the tv doesn\'t exist\r\n if ( ! \$element)\r\n {\r\n // Create the element\r\n \$element = Element::create(\$modx, \'modTemplateVar\', \$tv->name);\r\n\r\n // If the element is created successfully \r\n if (\$element)\r\n {\r\n \$properties = \$element_helper->get_tv_element_properties(\$tv);\r\n\r\n if (isset(\$tv->template_access))\r\n {\r\n \$element_helper->setup_tv_template_access(\$element->get_property(\'id\'), \$tv->template_access);\r\n }\r\n\r\n // Set the tv properties and then add it to the sync\r\n if (\$element->set_properties(\$properties))\r\n {\r\n \$element_sync->add_element(\'modTemplateVar\', \$tv->name, \$tv_file_mod_time);\r\n }\r\n }\r\n }\r\n else\r\n {\r\n \$modx->log(MODX_LOG_LEVEL_INFO, \$log_prefix . \'An element with the name [\' . \$tv->name . \'] already exists. Unable to sync the element.\');\r\n }\r\n }\r\n else\r\n {\r\n // If the tv doesn\'t exist\r\n if ( ! \$element)\r\n {\r\n // Flag the tv for removal after we\'ve checked all tvs in the file\r\n \$flagged_tvs[] = \$i;\r\n }\r\n else\r\n {\r\n // If the template variable file has been updated update the tv element and sync\r\n if (\$tv_file_mod_time > \$element_sync->get_element_mod_time(\'modTemplateVar\', \$tv->name))\r\n {\r\n \$properties = \$element_helper->get_tv_element_properties(\$tv);\r\n\r\n if (isset(\$tv->template_access))\r\n {\r\n \$element_helper->setup_tv_template_access(\$element->get_property(\'id\'), \$tv->template_access);\r\n }\r\n\r\n // Set the tv properties and then add it to the sync\r\n if (\$element->set_properties(\$properties))\r\n {\r\n \$element_sync->add_element(\'modTemplateVar\', \$tv->name, \$tv_file_mod_time);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Remove any flagged tvs\r\n if (count(\$flagged_tvs) > 0)\r\n {\r\n \$updated_tvs = \$tvs;\r\n\r\n foreach (\$flagged_tvs as \$i)\r\n {\r\n unset(\$updated_tvs[\$i]);\r\n }\r\n\r\n // Update the template variable file and remove the tvs from the sync if successfull\r\n if (\$element_helper->update_tv_file(\$updated_tvs))\r\n {\r\n foreach (\$flagged_tvs as \$i)\r\n {\r\n \$element_sync->remove_element(\'modTemplateVar\', \$tvs[\$i]->name);\r\n }\r\n }\r\n }\r\n\r\n // Process the template variable elements\r\n foreach (\$modx->getCollection(\'modTemplateVar\') as \$element_object)\r\n {\r\n // Check if the tv exists in the template variables file\r\n \$element = Element::insert(\$element_object);\r\n \$name = \$element->get_property(\'name\');\r\n \$tv_file_has_tv = false;\r\n\r\n // Loop through the tvs to check if it exists in the template variables file\r\n foreach (\$tvs as \$i => \$tv)\r\n {\r\n if (\$tv->name === \$name)\r\n {\r\n \$tv_file_has_tv = true;\r\n }\r\n }\r\n\r\n // If the tv doesn\'t exist in the template variables json file\r\n if (\$tv_file_has_tv === false)\r\n {\r\n // If the element is not in the sync\r\n if ( ! \$element_sync->has_element(\'modTemplateVar\', \$name))\r\n {\r\n // Collect the tv element properties\r\n \$new_tv= array(array(\r\n \'name\' => \$name,\r\n \'caption\' => \$element->get_property(\'caption\'),\r\n \'type\' => \$element->get_property(\'type\'),\r\n \'description\' => \$element->get_property(\'description\'),\r\n \'category\' => (\$element->get_property(\'category\') !== 0 ? \$element->get_property(\'category\') : null),\r\n \'locked\' => \$element->get_property(\'locked\'),\r\n \'elements\' => \$element->get_property(\'elements\'),\r\n \'rank\' => \$element->get_property(\'rank\'),\r\n \'display\' => \$element->get_property(\'display\'),\r\n \'default_text\' => \$element->get_property(\'default_text\'),\r\n \'properties\' => \$element->get_property(\'properties\'),\r\n \'input_properties\' => \$element->get_property(\'input_properties\'),\r\n \'output_properties\' => \$element->get_property(\'output_properties\')\r\n ));\r\n\r\n // Fix migx json properties\r\n if (isset(\$new_tv[0][\'input_properties\'][\'formtabs\']))\r\n {\r\n \$new_tv[0][\'input_properties\'][\'formtabs\'] = json_decode(\$new_tv[0][\'input_properties\'][\'formtabs\']);\r\n \$new_tv[0][\'input_properties\'][\'columns\'] = json_decode(\$new_tv[0][\'input_properties\'][\'columns\']);\r\n }\r\n\r\n \$updated_tvs = array_merge(\$tvs, \$new_tv);\r\n\r\n // Update the template variables file and add the tv to the sync\r\n if (\$element_helper->update_tv_file(\$updated_tvs))\r\n {\r\n \$tv_file_mod_time = filemtime(\$tv_file_path);\r\n \$element_sync->add_element(\'modTemplateVar\', \$name, \$tv_file_mod_time);\r\n }\r\n }\r\n else\r\n {\r\n // Remove the element and remove it from the sync if successful\r\n if (\$element->remove())\r\n {\r\n \$element_sync->remove_element(\'modTemplateVar\', \$name);\r\n }\r\n }\r\n }\r\n }\r\n}' [/:locked\b/] => 0 [/:disabled\b/] => 0 [/:moduleguid\b/] => '' [/:static\b/] => 0 [/:static_file\b/] => '' ) Error 23000 executing statement: INSERT INTOmodx_site_plugins
(id
,source
,property_preprocess
,name
,description
,editor_type
,category
,cache_type
,plugincode
,locked
,disabled
,moduleguid
,static
,static_file
) VALUES (1, 0, 0, 'ElementHelper', 'Creates elements automatically from static files.', 0, 0, 0, '$default_core_path = $modx->getOption(\'core_path\') . \'components/elementhelper/\';\r\n$core_path = $modx->getOption(\'elementhelper.core_path\', null, $default_core_path);\r\n\r\n$usergroups = explode(\',\', $modx->getOption(\'elementhelper.usergroups\', null, \'Administrator\'));\r\n\r\n// Return if the user isn\'t part of one of the allowed usergroups \r\nif ( ! $modx->user->isMember($usergroups))\r\n{\r\n return;\r\n}\r\n\r\n// Load in our classes\r\n$modx->loadClass(\'FileHelper\', $core_path . \'model/\', true, true);\r\n$modx->loadClass(\'Element\', $core_path . \'model/\', true, true);\r\n$modx->loadClass(\'ElementHelper\', $core_path . \'model/\', true, true);\r\n$modx->loadClass(\'ElementSync\', $core_path . \'model/\', true, true);\r\n\r\n// Path to the element sync json file\r\n$element_sync_file = MODX_BASE_PATH . $modx->getOption(\'elementhelper.element_sync_file_path\', null, \'site/elements/element_sync.json\');\r\n\r\n// Initialize the classes\r\n$element_helper = new ElementHelper($modx);\r\n$element_sync = new ElementSync($modx, $element_sync_file);\r\n\r\n$element_types = array(\r\n \'modTemplate\' => $modx->getOption(\'elementhelper.template_path\', null, \'site/elements/templates/\'),\r\n \'modChunk\' => $modx->getOption(\'elementhelper.chunk_path\', null, \'site/elements/chunks/\'),\r\n \'modSnippet\' => $modx->getOption(\'elementhelper.snippet_path\', null, \'site/elements/snippets/\'),\r\n \'modPlugin\' => $modx->getOption(\'elementhelper.plugin_path\', null, \'site/elements/plugins/\')\r\n);\r\n\r\n// Loop through the element types\r\nforeach ($element_types as $type => $type_path)\r\n{\r\n $log_prefix = sprintf(\'[ElementHelper] %s: \', $type);\r\n $file_list = FileHelper::get_directory_file_list(MODX_BASE_PATH . $type_path);\r\n\r\n // Move onto the next element type if it has no files\r\n if (empty($file_list))\r\n {\r\n $modx->log(MODX_LOG_LEVEL_INFO, $log_prefix . \'No files.\');\r\n\r\n continue;\r\n }\r\n\r\n // Process the files for this element type\r\n foreach ($file_list as $file_path)\r\n {\r\n $file = FileHelper::get_file_meta($file_path);\r\n $element = Element::get($modx, $type, $file[\'name\']);\r\n\r\n // If the file is not in the sync\r\n if ( ! $element_sync->has_element($type, $file[\'name\']))\r\n {\r\n // If the element doesn\'t exist\r\n if ( ! $element)\r\n {\r\n // Create the element\r\n $element = Element::create($modx, $type, $file[\'name\']);\r\n\r\n // If the element is created successfully set it\'s properties and then add it to the sync\r\n if ($element)\r\n {\r\n $properties = $element_helper->get_file_element_properties($type_path, $file_path);\r\n\r\n if ($element->set_properties($properties))\r\n {\r\n $element_sync->add_element($type, $file[\'name\'], $file[\'mod_time\']);\r\n }\r\n }\r\n }\r\n else\r\n {\r\n $modx->log(MODX_LOG_LEVEL_INFO, $log_prefix . \'An element with the name [\' . $file[\'name\'] . \'] already exists. Unable to sync the file and element.\');\r\n }\r\n }\r\n else\r\n {\r\n // If the element doesn\'t exist\r\n if ( ! $element)\r\n {\r\n // Delete the file and remove it from the sync if successful\r\n if (unlink($file_path))\r\n {\r\n $element_sync->remove_element($type, $file[\'name\']);\r\n }\r\n }\r\n else\r\n {\r\n // If file has been updated, update the element and sync\r\n if ($file[\'mod_time\'] > $element_sync->get_element_mod_time($type, $file[\'name\']))\r\n {\r\n $properties = $element_helper->get_file_element_properties($type_path, $file_path);\r\n\r\n if ($element->set_properties($properties))\r\n {\r\n $element_sync->add_element($type, $file[\'name\'], $file[\'mod_time\']);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Process the elements for this element type\r\n foreach ($modx->getCollection($type) as $element_object)\r\n {\r\n $element = Element::insert($element_object);\r\n $name = $element->get_property(\'name\');\r\n $category = $element->get_property(\'category\');\r\n $file_path = $element_helper->build_element_file_path($type, $type_path, $name, $category);\r\n\r\n // If a file with this element name doesn\'t exist\r\n if ( ! file_exists($file_path))\r\n {\r\n // If the element is not in the sync\r\n if ( ! $element_sync->has_element($type, $name)) \r\n {\r\n $properties = $element_helper->get_element_static_file_properties($element, $file_path);\r\n\r\n if ($element->set_properties($properties))\r\n {\r\n $file_mod_time = filemtime($file_path);\r\n $element_sync->add_element($type, $name, $file_mod_time);\r\n }\r\n }\r\n else\r\n {\r\n // Remove the element and remove it from the sync if successful\r\n if ($element->remove())\r\n {\r\n $element_sync->remove_element($type, $name);\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n$log_prefix = \'[ElementHelper] modTemplateVar: \';\r\n$tv_file_path = MODX_BASE_PATH . $modx->getOption(\'elementhelper.tv_file_path\', null, \'site/elements/template_variables.json\');\r\n\r\nif (file_exists($tv_file_path))\r\n{\r\n $tv_file_contents = file_get_contents($tv_file_path);\r\n $tv_file_mod_time = filemtime($tv_file_path);\r\n $tvs = ($tv_file_contents !== \'\' ? json_decode($tv_file_contents) : array());\r\n $flagged_tvs = array();\r\n\r\n // Loop through the template variables in the file\r\n foreach ($tvs as $i => $tv)\r\n {\r\n $element = Element::get($modx, \'modTemplateVar\', $tv->name);\r\n\r\n // If the element is not in the sync\r\n if ( ! $element_sync->has_element(\'modTemplateVar\', $tv->name))\r\n {\r\n // If the tv doesn\'t exist\r\n if ( ! $element)\r\n {\r\n // Create the element\r\n $element = Element::create($modx, \'modTemplateVar\', $tv->name);\r\n\r\n // If the element is created successfully \r\n if ($element)\r\n {\r\n $properties = $element_helper->get_tv_element_properties($tv);\r\n\r\n if (isset($tv->template_access))\r\n {\r\n $element_helper->setup_tv_template_access($element->get_property(\'id\'), $tv->template_access);\r\n }\r\n\r\n // Set the tv properties and then add it to the sync\r\n if ($element->set_properties($properties))\r\n {\r\n $element_sync->add_element(\'modTemplateVar\', $tv->name, $tv_file_mod_time);\r\n }\r\n }\r\n }\r\n else\r\n {\r\n $modx->log(MODX_LOG_LEVEL_INFO, $log_prefix . \'An element with the name [\' . $tv->name . \'] already exists. Unable to sync the element.\');\r\n }\r\n }\r\n else\r\n {\r\n // If the tv doesn\'t exist\r\n if ( ! $element)\r\n {\r\n // Flag the tv for removal after we\'ve checked all tvs in the file\r\n $flagged_tvs[] = $i;\r\n }\r\n else\r\n {\r\n // If the template variable file has been updated update the tv element and sync\r\n if ($tv_file_mod_time > $element_sync->get_element_mod_time(\'modTemplateVar\', $tv->name))\r\n {\r\n $properties = $element_helper->get_tv_element_properties($tv);\r\n\r\n if (isset($tv->template_access))\r\n {\r\n $element_helper->setup_tv_template_access($element->get_property(\'id\'), $tv->template_access);\r\n }\r\n\r\n // Set the tv properties and then add it to the sync\r\n if ($element->set_properties($properties))\r\n {\r\n $element_sync->add_element(\'modTemplateVar\', $tv->name, $tv_file_mod_time);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Remove any flagged tvs\r\n if (count($flagged_tvs) > 0)\r\n {\r\n $updated_tvs = $tvs;\r\n\r\n foreach ($flagged_tvs as $i)\r\n {\r\n unset($updated_tvs[$i]);\r\n }\r\n\r\n // Update the template variable file and remove the tvs from the sync if successfull\r\n if ($element_helper->update_tv_file($updated_tvs))\r\n {\r\n foreach ($flagged_tvs as $i)\r\n {\r\n $element_sync->remove_element(\'modTemplateVar\', $tvs[$i]->name);\r\n }\r\n }\r\n }\r\n\r\n // Process the template variable elements\r\n foreach ($modx->getCollection(\'modTemplateVar\') as $element_object)\r\n {\r\n // Check if the tv exists in the template variables file\r\n $element = Element::insert($element_object);\r\n $name = $element->get_property(\'name\');\r\n $tv_file_has_tv = false;\r\n\r\n // Loop through the tvs to check if it exists in the template variables file\r\n foreach ($tvs as $i => $tv)\r\n {\r\n if ($tv->name === $name)\r\n {\r\n $tv_file_has_tv = true;\r\n }\r\n }\r\n\r\n // If the tv doesn\'t exist in the template variables json file\r\n if ($tv_file_has_tv === false)\r\n {\r\n // If the element is not in the sync\r\n if ( ! $element_sync->has_element(\'modTemplateVar\', $name))\r\n {\r\n // Collect the tv element properties\r\n $new_tv= array(array(\r\n \'name\' => $name,\r\n \'caption\' => $element->get_property(\'caption\'),\r\n \'type\' => $element->get_property(\'type\'),\r\n \'description\' => $element->get_property(\'description\'),\r\n \'category\' => ($element->get_property(\'category\') !== 0 ? $element->get_property(\'category\') : null),\r\n \'locked\' => $element->get_property(\'locked\'),\r\n \'elements\' => $element->get_property(\'elements\'),\r\n \'rank\' => $element->get_property(\'rank\'),\r\n \'display\' => $element->get_property(\'display\'),\r\n \'default_text\' => $element->get_property(\'default_text\'),\r\n \'properties\' => $element->get_property(\'properties\'),\r\n \'input_properties\' => $element->get_property(\'input_properties\'),\r\n \'output_properties\' => $element->get_property(\'output_properties\')\r\n ));\r\n\r\n // Fix migx json properties\r\n if (isset($new_tv[0][\'input_properties\'][\'formtabs\']))\r\n {\r\n $new_tv[0][\'input_properties\'][\'formtabs\'] = json_decode($new_tv[0][\'input_properties\'][\'formtabs\']);\r\n $new_tv[0][\'input_properties\'][\'columns\'] = json_decode($new_tv[0][\'input_properties\'][\'columns\']);\r\n }\r\n\r\n $updated_tvs = array_merge($tvs, $new_tv);\r\n\r\n // Update the template variables file and add the tv to the sync\r\n if ($element_helper->update_tv_file($updated_tvs))\r\n {\r\n $tv_file_mod_time = filemtime($tv_file_path);\r\n $element_sync->add_element(\'modTemplateVar\', $name, $tv_file_mod_time);\r\n }\r\n }\r\n else\r\n {\r\n // Remove the element and remove it from the sync if successful\r\n if ($element->remove())\r\n {\r\n $element_sync->remove_element(\'modTemplateVar\', $name);\r\n }\r\n }\r\n }\r\n }\r\n}', 0, 0, '', 0, '') Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '1' for key 'PRIMARY' ) plugin_err_createArray Error saving vehicle object of class modPlugin; criteria: Array ( [name] => ElementHelper ) Error 42S22 executing statement: Array ( [0] => 42S22 [1] => 1054 [2] => Unknown column 'modPluginEvent.name' in 'where clause' ) Error 42S22 executing statement: Array ( [0] => 42S22 [1] => 1054 [2] => Unknown column 'modPluginEvent.name' in 'where clause' ) INSERT INTOmodx_site_plugin_events
(pluginid
,event
,priority
,propertyset
) VALUES (:pluginid, :event, :priority, :propertyset) Array ( [/:pluginid\b/] => 5 [/:event\b/] => '' [/:priority\b/] => 0 [/:propertyset\b/] => 0 ) Error 23000 executing statement: INSERT INTOmodx_site_plugin_events
(pluginid
,event
,priority
,propertyset
) VALUES (5, '', 0, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '5-' for key 'PRIMARY' ) Error saving vehicle object of class modPluginEvent; criteria: Array ( [name] => ) Could not install related objects with locally owned keys for vehicle object of class modPlugin; criteria: Array ( [name] => ElementHelper ) Successfully installed package elementhelper-2.0.0-alpha-1