/**
  * Return the "toggle visibility" button
  * @param array
  * @param string
  * @param string
  * @param string
  * @param string
  * @param string
  * @return string
  */
 public function toggleIcon($row, $href, $label, $title, $icon, $attributes)
 {
     if (strlen(\Input::get('tid'))) {
         $this->toggleVisibility(\Input::get('tid'), \Input::get('state') == 1, @func_get_arg(12) ?: null);
         \Backend::redirect(\Controller::getReferer());
     }
     $href .= '&tid=' . $row['id'] . '&state=' . ($row['published'] ? '' : 1);
     if (!$row['published']) {
         $icon = 'invisible.gif';
     }
     return '<a href="' . \Backend::addToUrl($href) . '" title="' . specialchars($title) . '"' . $attributes . '>' . \Image::getHtml($icon, $label) . '</a> ';
 }
 /**
  * Generate module
  */
 protected function compile()
 {
     // Create files
     if (\Input::post('FORM_SUBMIT') == 'tl_entity_import') {
         $objModel = EntityImportConfigModel::findByPk($this->objDc->id);
         if ($objModel === null) {
             return;
         }
         if (class_exists($objModel->importerClass)) {
             // use a particular importer (e.g. NewsImporter)
             \Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_entity_import_config']['importerInfo'], $objModel->importerClass));
             $importer = new $objModel->importerClass($objModel);
         } else {
             \Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_entity_import_config']['importerInfo'], 'Importer'));
             $importer = new Importer($objModel);
         }
         if ($importer->run(\Input::post('dry-run'))) {
             // Confirm and reload
             $strMessage = $GLOBALS['TL_LANG']['tl_entity_import_config']['confirm'];
             if (\Input::post('dry-run')) {
                 $strMessage = $GLOBALS['TL_LANG']['tl_entity_import_config']['confirmDry'];
             }
             \Message::addConfirmation($strMessage);
             \Controller::reload();
         }
     }
     $this->Template->base = \Environment::get('base');
     $this->Template->href = \Controller::getReferer(true);
     $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']);
     $this->Template->action = ampersand(\Environment::get('request'));
     $this->Template->selectAll = $GLOBALS['TL_LANG']['MSC']['selectAll'];
     $this->Template->button = $GLOBALS['TL_LANG']['MSC']['backBT'];
     $this->Template->message = \Message::generate();
     $this->Template->submit = specialchars($GLOBALS['TL_LANG']['tl_entity_import_config']['import'][0]);
     $this->Template->dryRun = specialchars($GLOBALS['TL_LANG']['tl_entity_import_config']['dryRun'][0]);
     $this->Template->headline = sprintf($GLOBALS['TL_LANG']['tl_entity_import_config']['headline'], \Input::get('id'));
     $this->Template->explain = $GLOBALS['TL_LANG']['tl_entity_import_config']['make'][1];
     $this->Template->label = $GLOBALS['TL_LANG']['tl_entity_import_config']['label'];
 }
 /**
  * @param Event\GenerateEvent $objEvent
  * @param array $arrConfig
  * @param bool $blnStop
  *
  * @return bool
  */
 public static function toggleIcon(Event\GenerateEvent $objEvent, array $arrConfig = array(), $blnStop = true)
 {
     if (strlen(\Input::get('tid'))) {
         static::toggleState($objEvent, $arrConfig, \Input::get('tid'), \Input::get('state') == 1);
         \Controller::redirect(\Controller::getReferer());
     }
     $objEvent->setOutput(null);
     /** @var \BackendUser $objUser */
     $objUser = \BackendUser::getInstance();
     /** @var \DcaTools\Component\Operation\View $objView */
     $objView = $objEvent->getView();
     /** @var \DcaTools\Definition\DataContainer $objController */
     $objDataContainer = Definition::getDataContainer($objEvent->getModel()->getProviderName());
     $arrRow = $objEvent->getModel()->getPropertiesAsArray();
     $strTable = isset($arrConfig['table']) ? $arrConfig['table'] : $objDataContainer->getName();
     $strProperty = isset($arrConfig['property']) ? $arrConfig['property'] : 'published';
     $blnVisible = isset($arrConfig['inverted']) ? $arrRow[$strProperty] : !$arrRow[$strProperty];
     // Check permissions AFTER checking the tid, so hacking attempts are logged
     if ($objUser->isAdmin && !$objUser->hasAccess($strTable . '::' . $strProperty, 'alexf')) {
         if ($blnStop) {
             $objEvent->stopPropagation();
         }
         return false;
     }
     $strHref = $objView->getHref();
     $strHref .= '&amp;id=' . $arrRow['pid'] . '&amp;tid=' . $arrRow['id'] . '&amp;state=' . ($blnVisible ? 1 : '');
     $objView->setHref($strHref);
     $objEvent->setConfigAttribute('id', false);
     if ($blnVisible) {
         $objView->setIcon(isset($arrConfig['icon']) ? $arrConfig['icon'] : 'invisible.gif');
     }
     return true;
 }
Example #4
0
 /**
  * @param $arrButtons
  * @return string
  */
 public function addAliasButton($arrButtons)
 {
     if (\Input::post('FORM_SUBMIT') == 'tl_select' && isset($_POST['alias'])) {
         // init objects
         $objSession = \Session::getInstance();
         $objDataBase = \Database::getInstance();
         $session = $objSession->getData();
         $ids = $session['CURRENT']['IDS'];
         $strTable = \Input::get('table');
         if (!$strTable || !$objDataBase->tableExists($strTable)) {
             return $arrButtons;
         }
         foreach ($ids as $id) {
             $objData = $objDataBase->prepare('SELECT id, alias, title FROM ' . $strTable . ' WHERE id=?')->limit(1)->execute($id);
             if (!$objData->count()) {
                 continue;
             }
             $arrData = $objData->row();
             $strAlias = \StringUtil::generateAlias($arrData['title']);
             if ($strAlias == $arrData['alias']) {
                 continue;
             }
             $objAlias = $objDataBase->prepare('SELECT id FROM ' . $strTable . ' WHERE alias = ?')->execute($strAlias);
             if ($objAlias->numRows > 1) {
                 $strAlias .= '-' . $arrData['id'];
             }
             // Initialize the version manager
             $objVersions = new \Versions($strTable, $id);
             $objVersions->initialize();
             $objDataBase->prepare('UPDATE ' . $strTable . ' SET alias=? WHERE id=?')->execute($strAlias, $id);
             $objVersions->create();
         }
         \Controller::redirect(\Controller::getReferer());
     }
     $arrButtons['alias'] = '<input type="submit" name="alias" id="alias" class="tl_submit" accesskey="a" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['aliasSelected']) . '"> ';
     return $arrButtons;
 }