Example #1
0
 /**
  * @test
  */
 public function selectColumnForMultipleForTwoMatchReturnsArrayWithColumnContents()
 {
     $uid1 = $this->testingFramework->createRecord('tx_oelib_test', array('title' => 'foo'));
     $uid2 = $this->testingFramework->createRecord('tx_oelib_test', array('title' => 'bar'));
     $result = Tx_Oelib_Db::selectColumnForMultiple('title', 'tx_oelib_test', 'uid = ' . $uid1 . ' OR uid = ' . $uid2);
     sort($result);
     self::assertSame(array('bar', 'foo'), $result);
 }
Example #2
0
 /**
  * Creates an m:n relation using an m:n table.
  *
  * Note: This doesn't work for the reverse direction of bidirectional
  * relations yet.
  *
  * @param array &$data
  *        the model data to process, will be modified
  * @param string $key
  *        the key of the data item for which the relation should be created, must not be empty
  * @param Tx_Oelib_Model $model the model to create the relation for
  *
  * @return void
  */
 private function createMToNRelation(array &$data, $key, Tx_Oelib_Model $model)
 {
     /** @var Tx_Oelib_List $list */
     $list = t3lib_div::makeInstance('Tx_Oelib_List');
     $list->setParentModel($model);
     if ($data[$key] > 0) {
         $mapper = Tx_Oelib_MapperRegistry::get($this->relations[$key]);
         $relationConfiguration = $this->getRelationConfigurationFromTca($key);
         $mnTable = $relationConfiguration['MM'];
         if (!isset($relationConfiguration['MM_opposite_field'])) {
             $relationUids = Tx_Oelib_Db::selectColumnForMultiple('uid_foreign', $mnTable, 'uid_local = ' . $data['uid'], '', 'sorting');
         } else {
             $relationUids = Tx_Oelib_Db::selectColumnForMultiple('uid_local', $mnTable, 'uid_foreign = ' . $data['uid'], '', 'uid_local');
         }
         foreach ($relationUids as $relationUid) {
             $list->add($mapper->find($relationUid));
         }
     }
     $data[$key] = $list;
 }
Example #3
0
 /**
  * Checks whether a configuration value either is empty or contains a
  * comma-separated list of PIDs that specify pages or a given type.
  *
  * @param string $fieldName
  *        TS setup field name to extract, must not be empty
  * @param bool $canUseFlexforms
  *        whether the value can also be set via flexforms (this will be
  *        mentioned in the error message)
  * @param string $sheet
  *        flexforms sheet pointer, eg. "sDEF", will be ignored if
  *        $canUseFlexforms is set to FALSE
  * @param string $explanation
  *        a sentence explaining what that configuration value is needed for,
  *        must not be empty
  * @param string $typeCondition
  *        a comparison operator with a value that will be used in a SQL
  *        query to check for the correct page types, for example "<199" or
  *        "=254", must not be empty
  *
  * @return void
  */
 protected function checkPageTypeOrEmpty($fieldName, $canUseFlexforms, $sheet, $explanation, $typeCondition)
 {
     $this->checkIfPidListOrEmpty($fieldName, $canUseFlexforms, $sheet, $explanation);
     if ($this->objectToCheck->hasConfValueString($fieldName, $sheet)) {
         $pids = $this->objectToCheck->getConfValueString($fieldName, $sheet);
         $offendingPids = Tx_Oelib_Db::selectColumnForMultiple('uid', 'pages', 'uid IN (' . $pids . ') AND NOT (doktype' . $typeCondition . ')' . Tx_Oelib_Db::enableFields('pages'));
         $dbResultCount = count($offendingPids);
         if ($dbResultCount > 0) {
             $pageIdPlural = $dbResultCount > 1 ? 's' : '';
             $bePlural = $dbResultCount > 1 ? 'are' : 'is';
             $message = 'The TS setup variable <strong>' . $this->getTSSetupPath() . $fieldName . '</strong> contains the page ID' . $pageIdPlural . ' <strong>' . implode(',', $offendingPids) . '</strong> ' . 'which ' . $bePlural . ' of an incorrect page type. ' . $explanation . '<br />';
             $this->setErrorMessageAndRequestCorrection($fieldName, $canUseFlexforms, $message);
         }
     }
 }