*/ /** * Custom fields * * This module provides custom fields for Gallery items. * * @package CustomField */ class CustomFieldModule extends GalleryModule { function CustomFieldModule() { global $gallery; $this->setId('customfield'); $this->setName($gallery->i18n('Custom Fields')); $this->setDescription($gallery->i18n('Create custom data fields for Gallery items')); $this->setVersion('1.0.6'); $this->setGroup('data', $gallery->i18n('Extra Data')); $this->setCallbacks('registerEventListeners|getSiteAdminViews|getItemSummaries'); $this->setRequiredCoreApi(array(7, 0)); $this->setRequiredModuleApi(array(3, 0)); } /** * @see GalleryModule::upgrade() */ function upgrade($currentVersion) { global $gallery; if (!empty($currentVersion) && version_compare($currentVersion, '1.0.1', '<')) { $storage =& $gallery->getStorage(); $ret = $storage->configureStore($this->getId(), array('CustomFieldMap:1.0')); if ($ret) { return $ret->wrap(__FILE__, __LINE__); } } return null; } /** * @see GalleryModule::registerEventListeners() */ function registerEventListeners() { GalleryCoreApi::requireOnce('modules/customfield/classes/CustomFieldHelper.class'); GalleryCoreApi::registerEventListener('GalleryEntity::delete', new CustomFieldHelper()); } /** * @see GalleryModule::getSiteAdminViews() */ function getSiteAdminViews() { return array(null, array(array('name' => $this->translate('Custom Fields'), 'view' => 'customfield.CustomFieldSiteAdmin'))); } /** * @see GalleryModule::getItemSummaries() */ function getItemSummaries($items, $permissions) { GalleryCoreApi::requireOnce('modules/customfield/classes/CustomFieldHelper.class'); GalleryCoreApi::requireOnce('lib/smarty_plugins/modifier.markup.php'); $summaries = array(); list ($ret, $data) = CustomFieldHelper::fetchFieldValues($items, 'summary'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } foreach ($data as $itemId => $fields) { $list = array(); foreach ($fields as $field => $value) { $list[] = $field . ': ' . smarty_modifier_markup($value); } if (!empty($list)) { $summaries[$itemId] = implode("
\n", $list); } } return array(null, $summaries); } /** * @see GalleryModule::performFactoryRegistrations() */ function performFactoryRegistrations() { /* Register our item edit plugin */ $ret = GalleryCoreApi::registerFactoryImplementation( 'ItemEditPlugin', 'CustomFieldItemEdit', 'CustomFieldItemEdit', 'modules/customfield/CustomFieldItemEdit.inc', 'customfield', null); if ($ret) { return $ret->wrap(__FILE__, __LINE__); } /* Register interface implementation */ $ret = GalleryCoreApi::registerFactoryImplementation( 'CustomFieldInterface_1_0', 'CustomFieldHelper', 'CustomField', 'modules/customfield/classes/CustomFieldHelper.class', 'customfield', null); if ($ret) { return $ret->wrap(__FILE__, __LINE__); } /* Register search implementation */ $ret = GalleryCoreApi::registerFactoryImplementation( 'GallerySearchInterface_1_0', 'CustomFieldSearch', 'CustomField', 'modules/customfield/classes/CustomFieldSearch.class', 'customfield', null); if ($ret) { return $ret->wrap(__FILE__, __LINE__); } return null; } } ?>