Beispiel #1
0
 public static function classNameInstanceOfBaseObject($className)
 {
     $obj = Factory::createObject($className);
     if ($obj instanceof BaseObject === false) {
         throw new BaseException(TMS(BaseException::CLASS_NOT_INSTANCEOF_BASOBJECT, array('class' => $className)));
     }
 }
Beispiel #2
0
 /**
  * set a language for displaying
  *
  * @param $language
  * @throws BaseException
  */
 public function setSelectedLanguage($language)
 {
     if (in_array($language, $this->getPossibleLanguages()) === false) {
        throw new BaseException(TMS(BaseException::LANGUAGE_NOT_SUPPORTED, array('language' => $language)));
     }
     $this->selectedLanguage = $language;
 }
Beispiel #3
0
 /**
  * @throws base_exception_Validation
  */
 public function validateParams()
 {
     parent::validateParams();
     if (is_null($this->requestHelper->getParam('class'))) {
         throw new base_exception_Site(TMS(base_exception_Site::MISSING_PARAM, ['name' => 'class']));
     }
 }
Beispiel #4
0
 public function __construct(BaseObject $obj)
 {
     if ($this->checkObjClass($obj) == false) {
         throw new base_displayclass_Exception(TMS(base_displayclass_Exception::NOT_SUPPORTED_CLASS, array('class' => get_class($obj), 'displayClass' => get_class($this))));
     }
     $this->obj = $obj;
 }
Beispiel #5
0
 /**
  * @param $colName
  * @return base_database_Column
  * @throws base_database_Exception
  */
 public function getColumn($colName)
 {
     if ($this->existsColumn($colName) === false) {
         throw new base_database_Exception(TMS(base_database_Exception::TABLE_COLUMN_NOT_EXISTS, array('colName' => $colName, 'tableName' => $this->name)));
     }
     return $this->cols[$colName];
 }
Beispiel #6
0
 /**
  * set a new int value
  *
  * @param int $value
  * @throws base_database_Exception
  */
 public function setValue($value)
 {
     if (is_int($value) === false) {
         throw new base_database_Exception(TMS(base_database_Exception::NO_INT_VALUE, array('value' => $value)));
     }
     $this->int = $value;
 }
Beispiel #7
0
 /**
  * @throws base_exception_CMD
  */
 public function __construct()
 {
     if (!isset($GLOBALS['argv'])) {
         throw new base_exception_CMD(TMS(base_exception_CMD::NO_CMD_CALL));
     }
     $this->setParams();
     $this->model = $this->getModel();
 }
Beispiel #8
0
 /**
  * generate sql string
  * @return string
  * @throws base_database_Exception
  */
 public function toString()
 {
     if (empty($this->columns)) {
         throw new base_database_Exception(TMS(base_database_Exception::NO_COLS_ADDED, array('tableName', $this->name)));
     }
     $sql = 'CREATE TABLE IF NOT EXISTS ' . $this->name . ' (';
     $sql .= implode(', ', $this->columns) . ')';
     return $sql;
 }
Beispiel #9
0
 /**
  * @param array $data
  * @throws base_exception_BasePDF
  */
 public function setTableData(array $data)
 {
     foreach ($data as $obj) {
         if (!$obj instanceof BaseObject) {
             throw new base_exception_BasePDF(TMS(base_exception_BasePDF::DATA_NO_INSTANCEOF_BASEOBJECT));
         }
     }
     $this->data = $data;
 }
Beispiel #10
0
 /**
  * get a new instance of the given className
  *
  * @param $className
  * @return BaseObject
  * @throws BaseException
  */
 public static function createObject($className, BaseObject $obj)
 {
     Check::className($className);
     $dPObj = new $className($obj);
     if (!$dPObj instanceof DataPermission) {
         throw new base_exception_DataPermission(TMS(base_exception_DataPermission::FACTORY_NO_INSTANCE_OF_DP));
     }
     return $dPObj;
 }
Beispiel #11
0
    /**
     * @param $value
     * @param $expectedException
     * @throws base_database_Exception
     *
     * @test
     * @dataProvider toStringTestDataProvider
     */
    public function toStringTest($value, $expectedException)
    {
        if ($expectedException === true) {
            $this->setExpectedException('base_database_Exception', TMS(base_database_Exception::NO_INT_VALUE, array('value' => $value)));
        }

        $term = new base_database_term_Int();
        $term->setValue($value);

        $this->assertEquals($value, $term->toString());
    }
Beispiel #12
0
 /**
  * generate sql string
  *
  * @return string
  * @throws base_database_Exception
  */
 public function toString()
 {
     $result = 'DELETE FROM ';
     $result .= $this->table->getName();
     if (empty($this->where)) {
         throw new base_database_Exception(TMS(base_database_Exception::NO_WHERE_GIVEN));
     }
     $result .= ' WHERE ';
     $result .= $this->where->toString();
     return $result;
 }
Beispiel #13
0
function exception_handler(Exception $exception) {
    $div = Html::startTag('div', array('id' => 'exceptionBox'));
    $div .= Html::startTag('p', array('class' => 'h3')) . TMS(BaseException::HEADLINE) . Html::endTag('p');
    $div .= Html::startTag('hr');
    $div .= $exception->getMessage();
    $div .= Html::endTag('div');
    print($div);
    if ($exception instanceof BaseException) {
        $exception->debugOut();
    }
}
Beispiel #14
0
    /**
     * @param string $dbName
     * @throws base_database_Exception
     */
    public function __construct($dbName = '')
    {
        if (empty($dbName)) {
            $dbName = Configuration::get()->getEntry('dbName');
        }

        if (empty($dbName)) {
            throw new base_database_Exception(TMS(base_database_Exception::DB_DBNAME_MISSED));
        }

        $this->dbName = $dbName;
    }
Beispiel #15
0
 public function mapFieldValue($value)
 {
     $obj = Factory::createObject('vendor');
     $table = DB::table($obj->getTable());
     $where = DB::where($table->getColumn('name'), DB::term($value));
     $finder = Finder::create('vendor')->setWhere($where);
     $result = $finder->find(array($table->getColumn('LK')));
     if (count($result) > 1) {
         throw new base_exception_Mapper(TMS('medexchange.exception.mapper.vendorDuplicatedEntry'));
     }
     $lkArray = $result[0];
     return $lkArray['LK'];
 }
Beispiel #16
0
    /**
     * converts a given value to the specified structure
     *
     * @param $value
     * @return mixed
     * @throws base_database_Exception
     * @throws base_exception_Mapper
     */
    public function mapFieldValue($value)
    {
        $obj = Factory::createObject('TSMCollocgroup');
        $table = DB::table($obj->getTable());
        $where = DB::where($table->getColumn('name'), DB::term($value));
        $where->addAnd($table->getColumn('FK_tsmserver'), DB::term(TSMServerManager::get()->getActualTsmServerLK()));
        $finder = Finder::create('TSMCollocgroup')->setWhere($where);
        $result = $finder->find(array($table->getColumn('LK')));

        if (count($result) > 1) {
            throw new base_exception_Mapper(TMS('tsmviewer.exception.mapper.collocgroupDuplicatedEntry'));
        }

        $lkArray = current($result);

        return $lkArray['LK'];
    }
Beispiel #17
0
    /**
     * try to load the class definition of a given class name
     *
     * @param $className
     * @throws base_exception_Autoloader
     */
    public function loadClass($className)
    {
        if (strpos($className, '_') == true) {
            $filePath = $this->getClassFileByFolderStructure($className);
            if ($filePath !== self::CLASS_NOT_FOUND) {
                require_once($filePath);
                return;
            }
        }

        $filePath = $this->getClassFileFromPHPFolder($className);
        if ($filePath !== self::CLASS_NOT_FOUND) {
            require_once($filePath);
        } else {
            throw new base_exception_Autoloader(TMS(base_exception_Autoloader::CLASS_NOT_FOUND, array('class' => $className)));
        }
    }
Beispiel #18
0
 /**
  * @param $identifier
  * @throws base_exception_SelectionList
  */
 public function load($identifier)
 {
     $table = DB::table($this->table);
     $where = DB::where($table->getColumn('identifier'), DB::stringTerm($identifier));
     $select = new base_database_statement_Select();
     $select->setTable($table);
     $select->setWhere($where);
     $result = $select->fetchDatabase();
     if (count($result) > 1) {
         throw new base_exception_SelectionList(TMS(base_exception_SelectionList::DUPLICATED_IDENTIFIER));
     }
     if (!empty($result)) {
         foreach ($result[0] as $propName => $value) {
             $this->$propName = $value;
         }
         $this->_loadEntries();
     }
 }
Beispiel #19
0
    public function toInternalValue($value)
    {
        if (is_float($value)) {
            return $value;
        }

        $floatParts = explode(',', $value);
        if (count($floatParts) == 1) {
            return $floatParts[0] . '.00';
        }
        if (count($floatParts) != 2 && !is_int($floatParts[0]) && !is_int($floatParts[1])) {
            throw new base_exception_Validation(TMS(base_exception_Validation::WRONG_FLOAT_FORMAT));
        }

        $value = $floatParts[0] . '.' . $floatParts[1];

        return $value;
    }
Beispiel #20
0
$od = new OutputDevice();

base_ui_Site::displayHead($od);
base_ui_Site::displayTop($od);
base_ui_Site::displayNavigation($od);
base_ui_Site::startMainContent($od);

print $od->toString();
$od->flush();

$requestHelper = new RequestHelper();

$class = $requestHelper->getParam('class');

if (is_null($class)) {
    throw new base_exception_Site(TMS(base_exception_Site::PARAM_MISSING, array('param' => 'class')));
}

$object = Factory::createObject($class);

$user = Flat::user();

if (!User::isLoggedIn() || !$user->isEntitled($object->getPermissionForViewMode(DisplayClass::VIEW))) {
    $od->addContent('Sie verfügen nicht über die benötigten Rechte, um diese Datenkategorie zu betrachten. Bitte wenden Sie sich an den Support');
    base_ui_Site::endMainContent($od);
    base_ui_Site::displayBottom($od);

    print $od->toString();
    exit();
}
Beispiel #21
0
 /**
  * @param string $rowType
  * @throws base_html_model_Exception
  */
 public function setRowType($rowType)
 {
     if (!in_array($rowType, array(self::ROWTAG_BODY, self::ROWTAG_HEAD))) {
         throw new base_html_model_Exception(TMS(base_html_model_Exception::NO_VALID_ROWTYPE, array('type' => $rowType)));
     }
     $this->rowType = $rowType;
 }
Beispiel #22
0
 /**
  * validate the condition operator
  *
  * @param $operator
  * @throws base_database_Exception
  * @return bool
  */
 private function _validateOperator($operator)
 {
     if (in_array($operator, [self::EQUAL, self::GREATER, self::SMALLER, self::LIKE]) === false) {
         throw new base_database_Exception(TMS(base_database_Exception::NO_VALID_OPERATOR, array('operator' => $operator)));
     }
 }
Beispiel #23
0
 /**
  * @param string $method
  * @throws base_form_Exception
  */
 public function setMethod($method)
 {
     if (!in_array($method, array(self::METHOD_GET, self::METHOD_POST))) {
         throw new base_form_Exception(TMS(base_form_Exception::NO_VALID_FORM_METHOD));
     }
     $this->method = $method;
 }
Beispiel #24
0
    /**
     * validates the given values for the properties
     *
     * @throws base_exception_BaseConnectionObject
     */
    private function _validateNeededInformation()
    {
        $properties = ['classLeft', 'classRight', 'lkLeft', 'lkRight'];
        foreach ($properties as $property) {
            if (!isset($this->$property)) {
                throw new base_exception_BaseConnectionObject(TMS(base_exception_BaseConnectionObject::PROPERTY_NOT_SET, array('property' => $property)));
            }
        }

        if (is_null(Factory::loadObject($this->classLeft, $this->lkLeft))) {
            throw new base_exception_BaseConnectionObject(TMS(base_exception_BaseConnectionObject::OBJECT_NOT_EXISTS, array('class' => $this->classLeft, 'lk' => $this->lkLeft)));
        }

        if (is_null(Factory::loadObject($this->classRight, $this->lkRight))) {
            throw new base_exception_BaseConnectionObject(TMS(base_exception_BaseConnectionObject::OBJECT_NOT_EXISTS, array('class' => $this->classRight, 'lk' => $this->lkRight)));
        }

        $select = new base_database_statement_Select();
        $table = DB::table($this->table);
        $select->setTable($table);
        $where = DB::where($table->getColumn('classLeft'), DB::term($this->classLeft));
        $where->addAnd($table->getColumn('classRight'), DB::term($this->classRight));
        $where->addAnd($table->getColumn('lkRight'), DB::term($this->lkRight));
        $where->addAnd($table->getColumn('lkLeft'), DB::term($this->lkLeft));
        $select->setWhere($where);
        $result = $select->fetchDatabase();
        if (!empty($result)) {
            return self::SAVE_OBJECT_ALREADY_EXISTS;
        }
        return self::SAVE_VALIDATION_SUCCESSFULL;
    }
Beispiel #25
0
 /**
  * validate the value
  *
  * @param  mixed $value
  * @return bool
  * @throws base_exception_Validation
  */
 final public function validate($value)
 {
     if ($this->fi->isMandatory() && empty($value) && $value != $this->fi->getDefaultValue()) {
         throw new base_exception_Validation(TMS(base_exception_Validation::MANDATORY_FIELD_EMPTY, array('fieldName' => $this->fi->getFieldLabel())));
     }
     $this->validateValue($value);
 }
Beispiel #26
0
 /**
  * @param $type
  * @return $this
  * @throws base_database_Exception
  */
 public function setType($type)
 {
     if (!in_array($type, array(self::INT, self::FLOAT, self::BOOL, self::VARCHAR, self::TEXT, self::DATETIME))) {
         throw new base_database_Exception(TMS(base_database_Exception::NO_VALID_COLTYPE, array('colType' => $type)));
     }
     $this->type = $type;
     return $this;
 }
Beispiel #27
0
 /**
  * @param int $rowSpan
  * @throws base_html_model_Exception
  */
 public function setRowSpan($rowSpan)
 {
     if (!is_int($rowSpan)) {
         throw new base_html_model_Exception(TMS(base_html_model_Exception::NO_INT_VALUE));
     }
     $this->colSpan = $rowSpan;
 }
Beispiel #28
0
 /**
  */
 public function getPageDescription()
 {
     return TMS('base.setup.startPageDescription');
 }
Beispiel #29
0
    public function getPermissionForViewMode($viewMode)
    {
        if (!in_array($viewMode, array(DisplayClass::EDIT, DisplayClass::VIEW))) {
            throw new base_displayclass_Exception(TMS(base_displayclass_Exception::NOT_SUPPORTED_MODE));
        }

        if ($viewMode == DisplayClass::VIEW) {
            return $this->getReadPermissionName();
        }

        if ($viewMode == DisplayClass::EDIT) {
            return $this->getWritePermissionName();
        }
    }
Beispiel #30
0
 /**
  * check the value to be int
  *
  * @param $integer
  * @throws base_database_Exception
  */
 private function _isInt($integer)
 {
     if (is_int($integer) === false) {
         throw new base_database_Exception(TMS(base_database_Exception::NO_INT_VALUE, array('value' => $integer)));
     }
 }