Exemplo n.º 1
0
 /**
  * Mire legyenek helyettesítve az ismeretlen, vagy a whitespace karakterek.
  *
  * @param string $defaultReplacement Helyettesítő string
  * @return string Aktuális helyettesítő értéke.
  */
 public static function defaultReplacement($defaultReplacement = null)
 {
     if (!is_null($defaultReplacement)) {
         self::$_defaultReplacement = (string) $defaultReplacement;
     }
     return self::$_defaultReplacement;
 }
Exemplo n.º 2
0
function randomize_symbols($text, $file_name)
{
    $symbols = load_symbols($file_name);
    $all_symbols = array();
    $symbols_hash = array();
    foreach ($symbols as $val) {
        foreach ($val as $v) {
            $symbols_hash[$v] = $val;
            if ($res = array_search($v, $all_symbols)) {
                throw new Exception("Symbol \"{$v}\"(char code " . ord($v) . ") already exist on position {$res}");
            }
        }
        $all_symbols = array_merge($all_symbols, $val);
    }
    Replacer::$all_symbols = $all_symbols;
    Replacer::$symbols_hash = $symbols_hash;
    return preg_replace_callback('/[' . join($all_symbols) . ']/', array('Replacer', 'replace_symbol'), $text);
}
Exemplo n.º 3
0
<?php

defined('CORE_PATH') or die('No direct script access.');
/**
 * @file    start.php
 * @author  Daniel Becker   <*****@*****.**>
 * @date    27.02.2015
 * @package game_core
 * @subpackage views
 *
 * @description
 * The first start-view file of the game
 *
 */
Replacer::addnav('Titel 1');
Replacer::addnav('Link 1', BASE_URL);
Replacer::addnav('Titel 2');
Replacer::output('Testcontent 1');
Replacer::output('Testcontent 2');
Replacer::addcharstat('stat_title_vital');
Replacer::addcharstat('stat_value_health', 'Rechte Seite 1');
Replacer::addcharstat('Status');
Replacer::addcharstat('stat_value_attack', 'Rechte Seite 2');
 /**
  * indexFieldNow
  * @param GenericElementField $objField
  * @param string $strField
  * @param integer $intFieldType
  * @param string|array|object $mixedFieldValue
  * @param Zend_Search_Lucene_Document $objDoc
  * @return void
  * @author Thomas Schedler <*****@*****.**>
  */
 protected final function indexFieldNow($objField, $strField, $intFieldType, $mixedFieldValue, Zend_Search_Lucene_Document &$objDoc)
 {
     try {
         $strValue = '';
         $strValueIds = '';
         if ($objField->typeId == GenericSetup::FIELD_TYPE_ID_TAG) {
             $mixedValue = $mixedFieldValue;
             if (is_object($mixedValue) || is_array($mixedValue)) {
                 foreach ($mixedValue as $objTag) {
                     $strValue .= $objTag->title . ', ';
                     $strValueIds .= '[' . $objTag->id . ']';
                 }
                 $strValue = rtrim($strValue, ', ');
             }
         } elseif (!is_object($mixedFieldValue) && $objField->sqlSelect != '') {
             $sqlSelect = $objField->sqlSelect;
             $arrIds = array();
             if (is_array($mixedFieldValue)) {
                 $arrIds = $mixedFieldValue;
             } else {
                 if ($mixedFieldValue != '') {
                     if (strpos($mixedFieldValue, '[') !== false) {
                         $mixedFieldValue = trim($mixedFieldValue, '[]');
                         $arrIds = explode('][', $mixedFieldValue);
                     } else {
                         $arrIds = array($mixedFieldValue);
                     }
                 }
             }
             if (is_array($arrIds)) {
                 if (count($arrIds) > 0) {
                     $strReplaceWhere = '';
                     foreach ($arrIds as $strId) {
                         $strReplaceWhere .= $strId . ',';
                     }
                     $strReplaceWhere = trim($strReplaceWhere, ',');
                     $objReplacer = new Replacer();
                     $sqlSelect = $objReplacer->sqlReplacer($sqlSelect, $this->setup->getLanguageId(), $this->setup->getRootLevelId(), ' AND tbl.id IN (' . $strReplaceWhere . ')');
                     $objCategoriesData = $this->core->dbh->query($sqlSelect)->fetchAll(Zend_Db::FETCH_OBJ);
                     if (count($objCategoriesData) > 0) {
                         foreach ($objCategoriesData as $objCategories) {
                             $strValue .= $objCategories->title . ', ';
                             $strValueIds .= '[' . $objCategories->id . ']';
                         }
                         $strValue = rtrim($strValue, ', ');
                     }
                 }
             }
         } else {
             $strValue = html_entity_decode($mixedFieldValue, ENT_COMPAT, $this->core->sysConfig->encoding->default);
         }
         if (is_string($strValue) && $strValue != '') {
             if ($intFieldType == GenericSetup::FILE_FIELD) {
                 $objFiles = $this->getModelFiles()->loadFilesById($strValue);
                 $arrValues = array();
                 if (count($objFiles) > 0) {
                     foreach ($objFiles as $objFile) {
                         $arrValues[] = array('path' => $objFile->path, 'filename' => $objFile->filename, 'version' => $objFile->version);
                     }
                 }
                 $strValueIds = $strValue;
                 $strValue = serialize($arrValues);
             }
             if ($strValueIds != '') {
                 $objDoc->addField(Zend_Search_Lucene_Field::unIndexed($strField . 'Ids', $strValueIds, $this->core->sysConfig->encoding->default));
             }
             $this->core->logger->debug($strField . ': ' . $strValue);
             switch ($objField->idSearchFieldTypes) {
                 case Search::FIELD_TYPE_KEYWORD:
                     $objDoc->addField(Zend_Search_Lucene_Field::keyword($strField, $strValue, $this->core->sysConfig->encoding->default));
                     break;
                 case Search::FIELD_TYPE_UNINDEXED:
                     $objDoc->addField(Zend_Search_Lucene_Field::unIndexed($strField, $strValue, $this->core->sysConfig->encoding->default));
                     break;
                 case Search::FIELD_TYPE_BINARY:
                     $objDoc->addField(Zend_Search_Lucene_Field::binary($strField, $strValue, $this->core->sysConfig->encoding->default));
                     break;
                 case Search::FIELD_TYPE_TEXT:
                     $objDoc->addField(Zend_Search_Lucene_Field::text($strField, $strValue, $this->core->sysConfig->encoding->default));
                     break;
                 case Search::FIELD_TYPE_UNSTORED:
                     $objDoc->addField(Zend_Search_Lucene_Field::unStored($strField, strip_tags($strValue), $this->core->sysConfig->encoding->default));
                     break;
             }
         }
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
 /**
  * addToIndex
  * @param string $strIndexPath
  * @param string $strKey
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 protected final function addToIndex($strIndexPath, $strKey)
 {
     try {
         if (!is_object($this->objIndex) || !$this->objIndex instanceof Zend_Search_Lucene) {
             if (count(scandir($strIndexPath)) > 2) {
                 $this->objIndex = Zend_Search_Lucene::open($strIndexPath);
             } else {
                 $this->objIndex = Zend_Search_Lucene::create($strIndexPath);
             }
         }
         $objDoc = new Zend_Search_Lucene_Document();
         $objDoc->addField(Zend_Search_Lucene_Field::keyword('key', $strKey));
         $objDoc->addField(Zend_Search_Lucene_Field::unIndexed('date', $this->setup->getPublishDate('d.m.Y')));
         $objDoc->addField(Zend_Search_Lucene_Field::unIndexed('rootLevelId', $this->setup->getRootLevelId()));
         /**
          * index fields
          */
         foreach ($this->setup->FieldNames() as $strField => $intFieldType) {
             $objField = $this->setup->getField($strField);
             if (is_object($objField) && $objField->idSearchFieldTypes != Search::FIELD_TYPE_NONE) {
                 $strValue = '';
                 if (is_array($objField->getValue()) && $objField->sqlSelect != '') {
                     $arrIds = $objField->getValue();
                     $sqlSelect = $objField->sqlSelect;
                     if (is_array($arrIds)) {
                         if (count($arrIds) > 0) {
                             $strReplaceWhere = '';
                             foreach ($arrIds as $strId) {
                                 $strReplaceWhere .= $strId . ',';
                             }
                             $strReplaceWhere = trim($strReplaceWhere, ',');
                             $objReplacer = new Replacer();
                             $sqlSelect = $objReplacer->sqlReplacer($sqlSelect, $this->setup->getLanguageId(), $this->setup->getRootLevelId(), ' AND tbl.id IN (' . $strReplaceWhere . ')');
                             $objCategoriesData = $this->core->dbh->query($sqlSelect)->fetchAll(Zend_Db::FETCH_OBJ);
                             if (count($objCategoriesData) > 0) {
                                 foreach ($objCategoriesData as $objCategories) {
                                     $strValue .= $objCategories->title . ', ';
                                 }
                                 $strValue = rtrim($strValue, ', ');
                             }
                         }
                     }
                 } else {
                     $strValue = $objField->getValue();
                 }
                 if ($strValue != '') {
                     switch ($objField->idSearchFieldTypes) {
                         case Search::FIELD_TYPE_KEYWORD:
                             $objDoc->addField(Zend_Search_Lucene_Field::keyword($strField, $strValue, $this->core->sysConfig->encoding->default));
                             break;
                         case Search::FIELD_TYPE_UNINDEXED:
                             $objDoc->addField(Zend_Search_Lucene_Field::unIndexed($strField, $strValue, $this->core->sysConfig->encoding->default));
                             break;
                         case Search::FIELD_TYPE_BINARY:
                             $objDoc->addField(Zend_Search_Lucene_Field::binary($strField, $strValue, $this->core->sysConfig->encoding->default));
                             break;
                         case Search::FIELD_TYPE_TEXT:
                             $objDoc->addField(Zend_Search_Lucene_Field::text($strField, $strValue, $this->core->sysConfig->encoding->default));
                             break;
                         case Search::FIELD_TYPE_UNSTORED:
                             $objDoc->addField(Zend_Search_Lucene_Field::unStored($strField, strip_tags($strValue), $this->core->sysConfig->encoding->default));
                             break;
                     }
                 }
             }
         }
         // Add document to the index.
         $this->objIndex->addDocument($objDoc);
         $this->objIndex->optimize();
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
 /**
  * addField
  * @param GenericElementField $objField
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.2
  */
 public function addField(GenericElementField &$objField, $intRegionId, $strNameExtension = '', $intRegionInstanceId = null, $blnEmpty = false)
 {
     try {
         $sqlStmt = array();
         $arrOptions = array();
         /**
          * get array options for select output if sqlSelect is in database
          */
         if ($objField->sqlSelect != '' && $objField->sqlSelect) {
             $objReplacer = new Replacer();
             $sqlSelect = $objReplacer->sqlReplacer($objField->sqlSelect, array('LANGUAGE_ID' => $this->objGenericForm->Setup()->getFormLanguageId(), 'ROOTLEVEL_LANGUAGE_ID' => $this->objGenericForm->Setup()->getLanguageId()), $this->objGenericForm->Setup()->getRootLevelId());
             $sqlStmt = $this->core->dbh->query($sqlSelect)->fetchAll();
             if ($objField->idFieldTypeGroup == GenericSetup::FIELD_TYPE_SELECT_ID) {
                 $arrOptions[''] = $this->core->translate->_('Please_choose', false);
             }
             foreach ($sqlStmt as $arrSql) {
                 if (array_key_exists('depth', $arrSql)) {
                     $arrOptions[$arrSql['id']] = array('title' => $arrSql['title'], 'depth' => $arrSql['depth']);
                 } else {
                     $arrOptions[$arrSql['id']] = $arrSql['title'];
                 }
             }
         }
         if ($objField->type == GenericSetup::FIELD_TYPE_TEMPLATE) {
             $objField->defaultValue = $this->objGenericForm->Setup()->getTemplateId();
         }
         if (!is_null($intRegionInstanceId)) {
             $mixedValue = $objField->getInstanceValue($intRegionInstanceId);
         } else {
             $mixedValue = $objField->getValue();
         }
         if ($blnEmpty == true) {
             $mixedValue = null;
         }
         $strCssClass = '';
         if ($objField->isKeyField) {
             $strCssClass = ' keyfield';
         }
         /**
          * add field to form
          */
         $this->addElement($objField->type, $objField->name . $strNameExtension, array('value' => $mixedValue, 'label' => $objField->title, 'description' => $objField->description, 'decorators' => array($objField->decorator), 'fieldId' => $objField->id, 'columns' => $objField->columns, 'class' => $objField->type . $strCssClass, 'height' => $objField->height, 'isGenericSaveField' => $objField->isSaveField, 'isCoreField' => $objField->isCoreField, 'MultiOptions' => $arrOptions, 'LanguageId' => $this->objGenericForm->Setup()->getLanguageId(), 'FormLanguageId' => $this->objGenericForm->Setup()->getFormLanguageId(), 'isEmptyField' => $blnEmpty == true ? 1 : 0, 'required' => $objField->isKeyField == 1 ? true : false));
         $this->getElement($objField->name . $strNameExtension)->regionId = $intRegionId;
         $this->getElement($objField->name . $strNameExtension)->regionExtension = $strNameExtension;
         $this->getElement($objField->name . $strNameExtension)->formTypeId = $this->objGenericForm->Setup()->getFormTypeId();
         if (count($objField->getProperties()) > 0) {
             foreach ($objField->getProperties() as $strProperty => $mixedPropertyValue) {
                 if (in_array($strProperty, self::$FIELD_PROPERTIES_TO_IMPART)) {
                     $this->getElement($objField->name . $strNameExtension)->{$strProperty} = $mixedPropertyValue;
                 }
             }
         }
         if (!is_null($intRegionInstanceId)) {
             if (count($objField->getInstanceProperties($intRegionInstanceId)) > 0) {
                 foreach ($objField->getInstanceProperties($intRegionInstanceId) as $strProperty => $mixedPropertyValue) {
                     if (in_array($strProperty, self::$FIELD_PROPERTIES_TO_IMPART)) {
                         $this->getElement($objField->name . $strNameExtension)->{$strProperty} = $mixedPropertyValue;
                     }
                 }
             }
         }
         /**
          * template specific addons
          */
         if ($objField->type == GenericSetup::FIELD_TYPE_TEMPLATE) {
             $this->getElement($objField->name . $strNameExtension)->isStartElement = $this->objGenericForm->Setup()->getIsStartElement(false);
             $this->getElement($objField->name . $strNameExtension)->intFormTypeId = $this->objGenericForm->Setup()->getFormTypeId();
             $this->getElement($objField->name . $strNameExtension)->intElementTypeId = $this->objGenericForm->Setup()->getElementTypeId();
             $this->getElement($objField->name . $strNameExtension)->intParentTypeId = $this->objGenericForm->Setup()->getParentTypeId();
         }
         $this->objGenericForm->fieldAddedToSubform($this->intId, $objField->name);
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
 /**
  * Sets class name and original code for this replacer (immutable).
  * @param string $code
  * @param string $className
  */
 public function __construct($code, $className)
 {
     $this->className = $className;
     parent::__construct($code);
 }
Exemplo n.º 8
0
 /**
  * getCategoriesValues
  * @param string $strFieldName
  * @return object $objCategoriesData
  * @author Cornelius Hansjakob <*****@*****.**>
  * @version 1.0
  */
 public function getCategoriesValues($strFieldName)
 {
     try {
         if (!array_key_exists($strFieldName, $this->arrCategoriesData)) {
             $this->arrCategoriesData[$strFieldName] = null;
             $mixedIds = self::getFieldValue($strFieldName);
             $sqlSelect = $this->objGenericData->Setup()->getField($strFieldName)->sqlSelect;
             if (is_array($mixedIds)) {
                 if (count($mixedIds) > 0) {
                     $strReplaceWhere = '';
                     foreach ($mixedIds as $strValue) {
                         $strReplaceWhere .= $strValue . ',';
                     }
                     $strReplaceWhere = trim($strReplaceWhere, ',');
                     $objReplacer = new Replacer();
                     $sqlSelect = $objReplacer->sqlReplacer($sqlSelect, $this->intLanguageId, $this->objGenericData->Setup()->getRootLevelId(), ' AND tbl.id IN (' . $strReplaceWhere . ')');
                     $this->arrCategoriesData[$strFieldName] = $this->core->dbh->query($sqlSelect)->fetchAll(Zend_Db::FETCH_OBJ);
                 }
             } else {
                 if ($mixedIds != '') {
                     $objReplacer = new Replacer();
                     $sqlSelect = $objReplacer->sqlReplacer($sqlSelect, $this->intLanguageId, $this->objGenericData->Setup()->getRootLevelId(), ' AND tbl.id = ' . $mixedIds);
                     $this->arrCategoriesData[$strFieldName] = $this->core->dbh->query($sqlSelect)->fetchAll(Zend_Db::FETCH_OBJ);
                 }
             }
         }
         return $this->arrCategoriesData[$strFieldName];
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
Exemplo n.º 9
0
 /**
  * Method for the installation-step-0
  */
 private function step_0()
 {
     \Replacer::addnav('Steps');
     \Replacer::addnav(__('install_common_step', 'install') . ' 0 ' . __('install_common_title_step_0', 'install'), BASE_URL);
     \Replacer::addnav(__('install_common_step', 'install') . ' 1 ' . __('install_common_title_step_0', 'install'), BASE_URL);
     $this->s_step_title .= __('install_common_title_step_0', 'install');
 }
Exemplo n.º 10
0
<?php

defined('CORE_PATH') or die('No direct script access.');
/**
 * @file    error.php
 * @author  Daniel Becker   <*****@*****.**>
 * @date    27.02.2015
 * @package game_core
 * @subpackage views
 *
 * @description
 * The error-view of the game
 *
 * @var string  $s_error_message    the given error message
 * @var string  $s_error_code       the given error code
 * @var string  $s_error_file       the given error file
 * @var string  $s_error_line       the given error line
 */
if (strpos($s_error_code, 'TEMPLATE') !== false) {
    echo $s_error_message;
    echo '<br><br><b>Code: ' . $s_error_code . '</b>';
} else {
    Replacer::output($s_error_message);
    Replacer::output('<br><b>Code:  ' . $s_error_code . '</b>');
    Replacer::output('<br><b>File:  ' . $s_error_file . '</b>');
    Replacer::output('<br><b>Line:  ' . $s_error_line . '</b>');
}
Exemplo n.º 11
0
    echo Replacer::filterName($value['job_title']);
    ?>
/<?php 
    echo $value['job_id'];
    ?>
"></a>
                                    <img src="<?php 
    echo Config::get('jobphoto.upload_path') . $value['job_list_photo'];
    ?>
" alt="">
                                </div><!-- /.image -->
                                <div class="wrapper">
                                    <div class="title">
                                        <h3>
                                            <a href="munka/<?php 
    echo Replacer::filterName($value['job_title']);
    ?>
/<?php 
    echo $value['job_id'];
    ?>
"><?php 
    echo $value['job_title'];
    ?>
</a>
                                        </h3>
                                    </div><!-- /.title -->
                                    <div class="location">
                                        <?php 
    $location = $value['city_name'];
    if (!empty($value['district_name'])) {
        $location .= ', ' . $value['district_name'] . ' kerület';
Exemplo n.º 12
0
<?php

defined('CORE_PATH') or die('No direct script access.');
/**
 * @file    install.php
 * @author  Daniel   <*****@*****.**>
 * @date    04.08.2015
 * @package game_core
 * @subpackage views
 *
 * @description
 * The view for the install-script of the game
 *
 * @var string  $i_step     the current step of installation
 */
$a_supported_languages = I18N::get_all_supported_languages(false);
$s_html = '<form method="post" action="' . BASE_URL . '"> ';
$s_html .= '<select name="game_language">';
foreach ($a_supported_languages as $s_language_code => $s_language_name) {
    $s_is_selected = null;
    if (I18N::get_language() === $s_language_code) {
        $s_is_selected = 'selected';
    }
    $s_html .= '<option ' . $s_is_selected . ' value="' . $s_language_code . '">' . $s_language_name . '</option>';
}
$s_html .= '</select> <input type="submit" value="' . __('form_choose_submit_form', 'form') . '"> </form>';
Replacer::output($s_html);
Exemplo n.º 13
0
//Initialize the random number generator
mt_srand(LOGD::make_seed());
//Initialize the Session and the Routing
Session::get_session();
Routing::init();
//check if the dbconfig.default.php exist, if yes - we have to install the game
if (!file_exists(dirname(LOGD_ROOT) . DIRECTORY_SEPARATOR . '.dbconfig' . EXT) && file_exists(dirname(LOGD_ROOT) . DIRECTORY_SEPARATOR . '.dbconfig.default' . EXT)) {
    //try-catch the installer, if it fails
    try {
        new \Install\Installer();
    } catch (LOGD_Exception $e) {
        $e->print_error();
    }
    exit(1);
}
//Initialize the language Class
//todo this is later only a fallback if nothing found in the database
//I18N::init(GAME_LANGUAGE);
//including the .dbconfig.php with all Database-Constants
include dirname(LOGD_ROOT) . DIRECTORY_SEPARATOR . '.dbconfig' . EXT;
//Load the default template instance
// @todo maybe set it later via database
//Template::get_instance(null,false);
//Set the page_header and page_footer every time
// @todo set it later via database
Replacer::page_header('LOGD - OOP');
$test = Database::factory();
//todo: implement routing
//Routing::init()->get_view();
//Render the first view
View::create('start')->render();