/** * Return manager instance * * @access protected * @param void * @return I18nLocaleValues */ function manager() { if (!$this->manager instanceof I18nLocaleValues) { $this->manager = I18nLocaleValues::instance(); } return $this->manager; }
/** * Edit value (used in Ajax calls, so die() instead of redirectTo()) * * @param id format <id>_<column name> * @param value new value * @return string */ function edit_value() { $id_column = array_var($_POST, 'id', '_'); $id_column = explode('_', $id_column); $locale_value = I18nLocaleValues::findById($id_column[0]); if (!$locale_value instanceof I18nLocaleValue) { die(lang('locale value dnx')); } // if if (!$locale_value->canEdit(logged_user())) { die(lang('no access permissions')); } // if if ($id_column[1] == 'name') { $value = array_var($_POST, 'value', $locale_value->Name()); $locale_value->setName($value); } if ($id_column[1] == 'description') { $value = array_var($_POST, 'value', $locale_value->getDescription()); $locale_value->setDescription($value); } try { DB::beginWork(); $locale_value->save(); ApplicationLogs::createLog($locale_value, 0, ApplicationLogs::ACTION_EDIT); DB::commit(); die($value); //die(lang('success edit locale value')); } catch (Exception $e) { DB::rollback(); die(lang('error', $e)); } // try }
/** * Return locale values as text * * @param string name * @return string */ function getDownloadText($output = 'text') { $values = I18nLocaleValues::instance()->getLocaleValues($this->getId()); if ($output == 'php') { $s = ''; foreach ($values as $v) { $t = addslashes($v->getDescription()); $s .= "'{$v->getName()}' => '{$t}',\n"; } return "<?php\nreturn array(\n{$s});\n?>"; } $s = ''; foreach ($values as $v) { $t = addslashes($v->getDescription()); $s .= "{$v->getName()}\t{$t}\n"; } return $s; }
/** * Delete rows that match specific conditions. If $conditions is NULL all rows from table will be deleted * * @access public * @param string $conditions Query conditions * @return boolean */ function delete($condition = null) { if (isset($this) && instance_of($this, 'I18nLocaleValues')) { return parent::delete($condition); } else { return I18nLocaleValues::instance()->delete($condition); } // if }
/** * loadValues * * @param boolean $replace Replace all values with the new values * @param integer $locale Locale to use * @return boolean */ function loadValues($locale, $replace) { return I18nLocaleValues::instance()->import($this->getId(), $locale, $replace); }