Ejemplo n.º 1
0
    /**
     * Provides data items for the list of available places.
     *
     * @param array[] $items any pre-filled data (may be empty)
     * @param array $unused unused
     * @param tx_ameosformidable $formidable the FORMidable object
     *
     * @return array[] $items with additional items from the places table
     *               as an array with the keys "caption" (for the title)
     *               and "value" (for the UID)
     */
    public function populateListPlaces(array $items, $unused = NULL, tx_ameosformidable $formidable = NULL)
    {
        $result = $items;
        /** @var tx_seminars_Mapper_Place $placeMapper */
        $placeMapper = tx_oelib_MapperRegistry::get('tx_seminars_Mapper_Place');
        $places = $placeMapper->findByPageUid($this->getPidsForAuxiliaryRecords(), 'title ASC');
        if ($formidable !== NULL) {
            $editButtonConfiguration =& $formidable->_navConf($formidable->aORenderlets['editPlaceButton']->sXPath);
        }
        $frontEndUser = self::getLoggedInUser();
        $showEditButton = $this->isFrontEndEditingOfRelatedRecordsAllowed(array('relatedRecordType' => 'Places')) && is_object($formidable);
        /** @var tx_seminars_Model_Place $place */
        foreach ($places as $place) {
            $frontEndUserIsOwner = $place->getOwner() === $frontEndUser;
            // Only shows places which have no owner or where the owner is the
            // currently logged in front-end user.
            if ($place->getOwner() && !$frontEndUserIsOwner) {
                continue;
            }
            if ($showEditButton && $frontEndUserIsOwner) {
                $editButtonConfiguration['name'] = 'editPlaceButton_' . $place->getUid();
                $editButtonConfiguration['onclick']['userobj']['php'] = '
					require_once(t3lib_extMgm::extPath(\'oelib\') . \'class.tx_oelib_Autoloader.php\');
					return tx_seminars_FrontEnd_EventEditor::showEditPlaceModalBox($this, ' . $place->getUid() . ');
					';
                $editButton = $formidable->_makeRenderlet($editButtonConfiguration, $formidable->aORenderlets['editPlaceButton']->sXPath);
                $editButton->includeScripts();
                $editButtonHTML = $editButton->_render();
                $result[] = array('caption' => $place->getTitle(), 'value' => $place->getUid(), 'labelcustom' => 'id="tx_seminars_pi1_seminars_place_label_' . $place->getUid() . '"', 'wrapitem' => '|</td><td>' . $editButtonHTML['__compiled']);
            } else {
                $result[] = array('caption' => $place->getTitle(), 'value' => $place->getUid(), 'wrapitem' => '|</td><td>&nbsp;');
            }
        }
        return $result;
    }