/**
  * Checks whether the UID provided as the second argument when starting the
  * CLI script actually exists in the "pages" table. If the page UID is
  * valid, defines this UID as the one where to take the configuration from,
  * otherwise throws an exception.
  *
  * @throws InvalidArgumentException if no page UID or an invalid UID was provided
  *
  * @return void
  */
 public function setConfigurationPage()
 {
     if (!isset($_SERVER['argv'][1])) {
         throw new InvalidArgumentException('Please provide the UID for the page with the configuration for the CLI module.', 1333292959);
     }
     $uid = (int) $_SERVER['argv'][1];
     if ($uid == 0 || tx_oelib_db::selectSingle('COUNT(*) AS number', 'pages', 'uid = ' . $uid) != array('number' => 1)) {
         throw new InvalidArgumentException('The provided UID for the page with the configuration was ' . $_SERVER['argv'][1] . ', which was not found to be a UID of an existing page. Please provide the UID of an existing page.', 1333292966);
     }
     tx_oelib_PageFinder::getInstance()->setPageUid($uid);
 }
예제 #2
0
 /**
  * Returns the name of the requested country from the static info tables.
  * If the country with this ISO code could not be found in the database,
  * an empty string is returned instead.
  *
  * @param string $isoCode the ISO 3166-1 alpha-2 code of the country, must not be empty
  *
  * @return string the short local name of the country or an empty
  *                string if the country could not be found
  */
 public function getCountryNameFromIsoCode($isoCode)
 {
     // Sanitizes the provided parameter against SQL injection as this
     // function can be used for searching.
     $isoCode = $GLOBALS['TYPO3_DB']->quoteStr($isoCode, 'static_countries');
     try {
         $dbResultRow = tx_oelib_db::selectSingle('cn_short_local', 'static_countries', 'cn_iso_2 = "' . $isoCode . '"');
         $countryName = $dbResultRow['cn_short_local'];
     } catch (tx_oelib_Exception_EmptyQueryResult $exception) {
         $countryName = '';
     }
     return $countryName;
 }
예제 #3
0
파일: Event.php 프로젝트: Konafets/seminars
 /**
  * Returns the next upcoming event.
  *
  * @return tx_seminars_Model_Event the next upcoming event
  *
  * @throws tx_oelib_Exception_NotFound
  */
 public function findNextUpcoming()
 {
     $whereClause = $this->getUniversalWhereClause() . ' AND cancelled <> ' . tx_seminars_seminar::STATUS_CANCELED . ' AND object_type <> ' . tx_seminars_Model_Event::TYPE_TOPIC . ' AND begin_date > ' . $GLOBALS['SIM_ACCESS_TIME'];
     try {
         $row = tx_oelib_db::selectSingle($this->columns, $this->tableName, $whereClause, '', 'begin_date ASC');
     } catch (tx_oelib_Exception_EmptyQueryResult $exception) {
         throw new tx_oelib_Exception_NotFound();
     }
     return $this->getModel($row);
 }
예제 #4
0
 /**
  * Retrieves the number of objects this bag would hold if the LIMIT part of
  * the query would not have been used.
  *
  * @return int the total number of objects in this bag without any
  *                 limit, may be zero
  */
 public function countWithoutLimit()
 {
     if ($this->hasCountWithoutLimit) {
         return $this->countWithoutLimit;
     }
     $dbResultRow = tx_oelib_db::selectSingle('COUNT(*) AS number ', $this->dbTableName . $this->additionalTableNames, $this->queryParameters . $this->enabledFieldsQuery);
     $this->countWithoutLimit = $dbResultRow['number'];
     $this->hasCountWithoutLimit = TRUE;
     return $this->countWithoutLimit;
 }