public function formImportFullText() { $language = new Language(); $this->data->languages = $language->listAll()->asQuery()->chunkResult('idLanguage', 'language'); $this->data->action = '@fnbr20/utils/import/importFullText'; $this->render(); }
/** * Get available languages list * * @return mixed */ function availableLangs() { $objLang = new Language(); //$conditions = $this->Access->isAdmin() ? array() : array('visible' => 1); $conditions = array(); return $objLang->find('list', array('conditions' => $conditions)); }
public function getMessages() { $parent = parent::getMessages(); $language = $this->languageValidator->getMessages(); $chain = $this->chain->getMessages(); return array_merge($parent, $language, $chain); }
function edit($id = false) { if (!$id) { redirect($this->linker->a_recipe_show_link()); } /* Loading libraries */ $this->load->library('form_validation'); # Js function from main.js which loads by default array_push($this->data['js_functions'], array('name' => 'recipes_edit_init', 'data' => FALSE)); array_push($this->data['js_functions'], array('name' => 'language_text_init', 'data' => FALSE)); /* Get data for select boxes */ $recipe = new Recipe(); $meras = new Mera(); $languages = new Language(); $recipe->get_full_info($id); $languages->get_iterated(); $meras->get_full_info(); #soedinit' sushestvuushie shagi po language if ($this->form_validation->run('recipe_edit')) { $this->_save($recipe); } else { /* Error on validation */ $this->data['form_error'] = validation_errors(); } # $this->data['dm_recipe'] = $recipe; $this->data['dm_languages'] = $languages; $this->data['dm_meras'] = $meras; $this->template->load('/admin/templates/main_template', '/admin/recipes/edit', $this->data); }
/** * get the Language config information * * @param object &$DBconn * @param int $lang_id * @return array $arr_data * */ function getLangByDB(&$DBconn, $lang_id) { $language = new Language(&$DBconn); $language->id = $lang_id; $arr_data = $language->selectLanguage(); return $arr_data; }
public function index() { $code = ''; $this->load->model('localisation/language'); $languages = $this->model_localisation_language->getLanguages(); if (isset($this->request->cookie['language'])) { $code = $this->request->cookie['language']; } // Language Detection if (!empty($this->request->server['HTTP_ACCEPT_LANGUAGE']) && !array_key_exists($code, $languages)) { $browser_languages = explode(',', $this->request->server['HTTP_ACCEPT_LANGUAGE']); foreach ($browser_languages as $browser_language) { if (array_key_exists(strtolower($browser_language), $languages)) { $code = strtolower($browser_language); break; } } } if (!array_key_exists($code, $languages)) { $code = $this->config->get('config_language'); } if (!isset($this->request->cookie['language']) || $this->request->cookie['language'] != $code) { setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']); } // Overwrite the default language object $language = new Language($code); $language->load($code); $this->registry->set('language', $language); // Set the config language_id $this->config->set('config_language_id', $languages[$code]['language_id']); }
function save_postdata($post_id) { // verify if this is an auto save routine. // If it is our form has not been submitted, so we dont want to do anything if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } // verify this came from the our screen and with proper authorization, // because save_post can be triggered at other times if (!wp_verify_nonce($_POST['aceelpress_noncename'], plugin_basename(__FILE__))) { return; } // Check permissions if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return; } } else { if (!current_user_can('edit_post', $post_id)) { return; } } // OK, we're authenticated: we need to find and save the data $l = new Language(); if (!($languageIDs = $_POST[$l->getFormName()])) { return; } foreach ($languageIDs as $lid => $val) { add_post_meta($post_id, 'accelpress_language_' . $lid, $val, true) or update_post_meta($post_id, 'accelpress_language_' . $lid, $val); } }
function sendmessage($touser, $title, $message, $from = '0') { global $hp_url, $admin_email, $admin_name, $hp_title; $_language_tmp = new Language(); $systemmail = false; if (!$from) { $systemmail = true; $from = '1'; } if (!$systemmail) { safe_query("INSERT INTO " . PREFIX . "messenger (userID, date, fromuser, touser, title, message, viewed) values('{$from}', '" . time() . "', '{$from}', '{$touser}', '{$title}', '" . $message . "', '0')"); safe_query("UPDATE " . PREFIX . "user SET pmsent=pmsent+1 WHERE userID='{$from}'"); } if (!isignored($touser, $from) or $systemmail) { if ($touser != $from || $systemmail) { safe_query("INSERT INTO " . PREFIX . "messenger (userID, date, fromuser, touser, title, message, viewed) VALUES ('{$touser}', '" . time() . "', '{$from}', '{$touser}', '{$title}', '" . $message . "', '0')"); } safe_query("UPDATE " . PREFIX . "user SET pmgot=pmgot+1 WHERE userID='{$touser}'"); if (wantmail($touser) and isonline($touser) == "offline") { $ds = mysql_fetch_array(safe_query("SELECT email, language FROM " . PREFIX . "user WHERE userID='{$touser}'")); $_language_tmp->set_language($ds['language']); $_language_tmp->read_module('messenger'); $mail_body = str_replace("%nickname%", getnickname($touser), $_language_tmp->module['mail_body']); $mail_body = str_replace("%hp_url%", $hp_url, $mail_body); mail($ds['email'], $hp_title . ': ' . $_language_tmp->module['mail_subject'], $mail_body, "Content-Type: text/html; charset=utf-8\nFrom: " . $admin_email . "\n"); } } }
function fetchJobSpecInfo($value) { $lan = new Language(); require $lan->getLangPath("full.php"); $jobTitle = new JobTitle(); $status = $jobTitle->getJobStatusFromTitle($value); $stat[] = array(0 => '', 1 => '0', 2 => "-- {$lang_hremp_selempstat} --"); for ($i = 0; $i < count($status); $i++) { $stat[] = $status[$i]; } $status = $stat; $view_controller = new ViewController(); $response = new xajaxResponse(); $xajaxFiller = new xajaxElementFiller(); $objResponse = $xajaxFiller->cmbFillerById($response, $status, 1, 'frmEmp.empstatpp', 'cmbType'); $jobSpec = $view_controller->getJobSpecForJob($value); if (empty($jobSpec)) { $jobSpecName = ''; $jobSpecDuties = ''; } else { $jobSpecName = CommonFunctions::escapeHtml($jobSpec->getName()); $jobSpecDuties = nl2br(CommonFunctions::escapeHtml($jobSpec->getDuties())); } $response->addAssign('jobSpecName', 'innerHTML', $jobSpecName); $response->addAssign('jobSpecDuties', 'innerHTML', $jobSpecDuties); $response->addAssign('status', 'innerHTML', ''); $response->addScript('reselectEmpStatus();'); return $response->getXML(); }
/** * Calls the delete_files function, then displays a message. * * @param string $folder - path to the cache folder * @param string $msg - show "cleared" message or not * @return bool $success */ public function clearCache($h, $folder, $msg = true) { // clear language from memory (lang_cache only) if ($folder == 'lang_cache') { $h->lang = array(); } // go delete the files $success = $this->deleteFiles(CACHE . $folder); // lang_cache only: if ($folder == 'lang_cache') { $langObj = new Language(); $h->lang = $langObj->includeLanguagePack($h->lang, 'main'); $h->lang = $langObj->includeLanguagePack($h->lang, 'admin'); } // no need to show a message, return now if (!$msg) { return $success; } // prepare messages if ($success) { $h->messages[$h->lang('admin_maintenance_clear_cache_success')] = 'alert-success'; } else { $h->messages[$h->lang('admin_maintenance_clear_cache_failure')] = 'alert-danger'; } // return boolean result return $success; }
function run_update($command, $args) { CLI::logging("Updating...\n"); $language = new Language(); $language->updateLanguagePlugin($command[0], $command[1]); CLI::logging("Update successful\n"); }
public function editOrder($order_id, $data) { $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int) $data['order_status_id'] . "', date_modified = NOW() WHERE order_id = '" . (int) $order_id . "'"); $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int) $order_id . "', order_status_id = '" . (int) $data['order_status_id'] . "', notify = '" . (isset($data['notify']) ? (int) $data['notify'] : 0) . "', comment = '" . $this->db->escape(strip_tags($data['comment'])) . "', date_added = NOW()"); if (isset($data['notify'])) { $query = $this->db->query("SELECT *, os.name AS status, l.code AS language FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_status os ON (o.order_status_id = os.order_status_id AND os.language_id = o.language_id) LEFT JOIN " . DB_PREFIX . "language l ON (o.language_id = l.language_id) WHERE o.order_id = '" . (int) $order_id . "'"); if ($query->num_rows) { $language = new Language($query->row['language']); $language->load('customer/order'); $subject = sprintf($language->get('mail_subject'), html_entity_decode($this->config->get('config_store'), ENT_QUOTES, 'UTF-8'), $order_id); $message = $language->get('mail_order') . ' ' . $order_id . "\n"; $message .= $language->get('mail_date_added') . ' ' . date($language->get('date_format_short'), strtotime($query->row['date_added'])) . "\n\n"; $message .= $language->get('mail_order_status') . "\n\n"; $message .= $query->row['status'] . "\n\n"; $message .= $language->get('mail_invoice') . "\n"; $message .= html_entity_decode(HTTP_CATALOG . 'index.php?route=account/invoice&order_id=' . $order_id, ENT_QUOTES, 'UTF-8') . "\n\n"; if (isset($data['comment'])) { $message .= $language->get('mail_comment') . "\n\n"; $message .= strip_tags(html_entity_decode($data['comment'], ENT_QUOTES, 'UTF-8')) . "\n\n"; } $message .= $language->get('mail_footer'); $mail = new Mail($this->config->get('config_mail_protocol'), $this->config->get('config_smtp_host'), $this->config->get('config_smtp_username'), html_entity_decode($this->config->get('config_smtp_password'), ENT_QUOTES, 'UTF-8'), $this->config->get('config_smtp_port'), $this->config->get('config_smtp_timeout')); $mail->setTo($query->row['email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender(html_entity_decode($this->config->get('config_store'), ENT_QUOTES, 'UTF-8')); $mail->setSubject($subject); $mail->setText($message); $mail->send(); } } }
function get_short_info($id = false, $current_language = 'English') { # $language = new Language(); is_numeric($current_language) ? $language->get_by_id($current_language) : $language->get_by_name($current_language); #svazivaet nutrition s vibranim language if ($id) { $this->get_by_id($id); $this->language->include_join_fields()->get_iterated(); } else { $full_list = new Nutrition(); $full_list->select('id, tagname')->where('Group_List', 3)->get_iterated(); #создает объектную модель данных для одбращения к данным через свойства объекта $this->select('id, tagname, value, units')->where('group_list', 3)->get(); foreach ($this as $nutrition) { $this->data->{strtolower($nutrition->tagname)} = array('id' => $nutrition->id, 'value' => $nutrition->value, 'units' => $nutrition->units); } #добавляет нулевые значения к отсутствующим данным foreach ($full_list as $elem) { if (!isset($this->data->{strtolower($elem->tagname)})) { $this->data->{strtolower($elem->tagname)} = array('id' => $elem->id, 'value' => '~', 'units' => ''); } } $this->id = null; } }
public static function translate(Language $language, $html, $debug = false) { $errors = []; // @param $html : html document foreach (self::$loadedSources as $sourcename) { // load translations from file $temp = $language->getTranslations($sourcename); $translations = []; if (isset($temp['translations'])) { $translations = $temp['translations']; } // apply given values foreach ($translations as $key => $value) { try { if (empty($value)) { #throw new Exception('Missing translation for '.$key); if ($debug) { $value = '(' . $key . ')'; } else { $value = ''; } } $html = str_replace($key, trim($value), $html); } catch (Exception $e) { $errors[] = $e->getMessage(); } } } return array('content' => $html, 'errors' => $errors); }
public function postLanguage() { $language = new Language(); $language->name = Input::get('name'); $language->save(); return Response::json($language); }
public static function GetURI($p_publicationId, $p_languageId, $p_issueNo = null, $p_sectionNo = null, $p_articleNo = null) { $translator = \Zend_Registry::get('container')->getService('translator'); $languageObj = new Language($p_languageId); if (!$languageObj->exists()) { return new PEAR_Error($translator->trans('Language does not exist.')); } $uri = '/' . $languageObj->getCode() . '/'; if (!is_null($p_issueNo) && is_null($p_articleNo)) { $issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo); if (!$issueObj->exists()) { return new PEAR_Error($translator->trans('Issue does not exist.')); } $uri .= $issueObj->getUrlName() . '/'; } if (!is_null($p_sectionNo) && is_null($p_articleNo)) { $sectionObj = new Section($p_publicationId, $p_issueNo, $p_languageId, $p_sectionNo); if (!$sectionObj->exists()) { return new PEAR_Error($translator->trans('Section does not exist.')); } $uri .= $sectionObj->getUrlName() . '/'; } if (!is_null($p_articleNo)) { $articleObj = new Article($p_languageId, $p_articleNo); if (!$articleObj->exists()) { return new PEAR_Error($translator->trans('Article does not exist.')); } $issueObj = new Issue($p_publicationId, $p_languageId, $articleObj->getIssueNumber()); $sectionObj = new Section($p_publicationId, $articleObj->getIssueNumber(), $p_languageId, $articleObj->getSectionNumber()); $uri .= $issueObj->getUrlName() . '/'; $uri .= $sectionObj->getUrlName() . '/'; $uri .= $articleObj->getUrlName() . '/'; } return $uri; }
function edit($id = false) { $this->load->library('form_validation'); # var $data['js_functions'] init from Admin_Controller # Js function from main.js which loads by default array_push($this->data['js_functions'], array('name' => 'nutritions_edit_init', 'data' => FALSE)); $languages = new Language(); $nutrition = new Nutrition(); $nutrition_categories = new Nutrition_category(); $languages->get_iterated(); $nutrition->get_full_info($id); $nutrition_categories->get_full_info(); //if form validates if ($this->form_validation->run('nutrition')) { $nutrition_category = new Nutrition_category(); $nutrition_category->get_by_id($this->input->post('nutritions_categories_id')); $nutrition->nutrition_category_id = $nutrition_category->id; if ($this->save_object_name($nutrition)) { $this->data['form_success'] = 'Вещество добавлено'; } else { $this->data['form_error'] = $nutrition->error->string; } } else { #$this->data['form_error'] = validation_errors(); } $this->data['dm_languages'] = $languages; $this->data['dm_nutrition'] = $nutrition; $this->data['current_language'] = 1; #Russian $this->data['nutrition_categories'] = $nutrition_categories; $this->template->load('/admin/templates/main_template', '/admin/nutritions/edit', $this->data); }
/** * @param $inputFileName * @param $expectedOutput * @param $description * @dataProvider testSanitizeFilenameDataProvider */ public function testSanitizeFilename($inputFileName, $contentLanguageCode, $expectedOutput, $description) { $language = new \Language(); $language->setCode($contentLanguageCode); $actualOutput = $this->imageFilenameSanitizer->sanitizeImageFileName($inputFileName, $language); $this->assertEquals($expectedOutput, $actualOutput, $description); }
public static function GetURI($p_publicationId, $p_languageId, $p_issueNo = null, $p_sectionNo = null, $p_articleNo = null) { $languageObj = new Language($p_languageId); if (!$languageObj->exists()) { return new PEAR_Error(getGS('Language does not exist.')); } $uri = $GLOBALS['Campsite']['SUBDIR'] . '/' . $languageObj->getCode() . '/'; if (!is_null($p_issueNo) && is_null($p_articleNo)) { $issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo); if (!$issueObj->exists()) { return new PEAR_Error(getGS('Issue does not exist.')); } $uri .= $issueObj->getUrlName() . '/'; } if (!is_null($p_sectionNo) && is_null($p_articleNo)) { $sectionObj = new Section($p_publicationId, $p_issueNo, $p_languageId, $p_sectionNo); if (!$sectionObj->exists()) { return new PEAR_Error(getGS('Section does not exist.')); } $uri .= $sectionObj->getUrlName() . '/'; } if (!is_null($p_articleNo)) { $articleObj = new Article($p_languageId, $p_articleNo); if (!$articleObj->exists()) { return new PEAR_Error(getGS('Article does not exist.')); } $issueObj = new Issue($p_publicationId, $p_languageId, $articleObj->getIssueNumber()); $sectionObj = new Section($p_publicationId, $articleObj->getIssueNumber(), $p_languageId, $articleObj->getSectionNumber()); $uri .= $issueObj->getUrlName() . '/'; $uri .= $sectionObj->getUrlName() . '/'; $uri .= $articleObj->getUrlName() . '/'; } return $uri; }
public function index() { if (!isset($this->session->data['language'])) { $languages = glob(DIR_LANGUAGE . '*', GLOB_ONLYDIR); foreach ($languages as $language) { $languages[] = basename($language); } if (isset($this->request->server['HTTP_ACCEPT_LANGUAGE'])) { $browser_languages = explode(',', $this->request->server['HTTP_ACCEPT_LANGUAGE']); foreach ($browser_languages as $browser_language) { if (in_array($browser_language, $languages)) { $this->session->data['language'] = $browser_language; break; } } } } if (!isset($this->session->data['language']) || !is_dir(DIR_LANGUAGE . str_replace('../', '/', $this->session->data['language']))) { $this->session->data['language'] = $this->config->get('language.default'); } // Language $language = new Language($this->session->data['language']); $language->load($this->session->data['language']); $this->registry->set('language', $language); }
public function getUndefinedLanguages($entry) { $criteria = $this->getCriteria()->select("idLanguage"); $criteria->where("entry = '{$entry}'"); $language = new Language(); $languages = $language->getCriteria()->select("idLanguage, language")->where('idLanguage', 'not in', $criteria)->asQuery()->chunkResult('idLanguage', 'language'); return $languages; }
public function testGetSupportedFromBrowserSimple() { $this->sut->setServer(['HTTP_ACCEPT_LANGUAGE' => 'en-US']); $this->assertTrue($this->sut->isSupported('en')); $this->assertFalse($this->sut->isSupported('en-US')); $actual = $this->sut->getSupportedFromBrowser(); $this->assertSame('en_EN', $actual); }
function __construct() { $this->IsAppLoggedIn(); $this->setAttributes(); $L = new Language(); $this->bruActions = (array) $L->GetServiceStrs($this->curPage); unset($L); }
public function getWeekDayName() { $language = new Language(CampTemplate::singleton()->context()->language->number); if (!$language->exists()) { return null; } return $language->getProperty('WDay' . (int) $this->getWeekDay()); }
public function ChangeLanguage($lang) { $L = new Language(); $L->SetLanguageName($lang); unset($L); $this->_user->SetUserLanguage($this->_user->username, $lang); return 'ok'; }
/** * Test the Language class. * * @return void * @access public */ public function testLanguage() { $l = new Language(); $this->assertEquals($l->getLanguage('eng'), 'English'); $this->assertEquals($l->getLanguage('??'), 'Unknown'); $this->assertEquals($l->getCode('English'), 'eng'); $this->assertEquals($l->getCode('???'), false); }
public function saveLanguage(Language $language) { try { $language->save(); } catch (Exception $e) { throw new DaoException($e->getMessage(), $e->getCode(), $e); } }
public function createFromArray($data) { $data = (object) $data; $instance = new Language(); $instance->setId($data->id); $instance->setName($data->name); return $instance; }
public function testAddLanguage() { $language = new Language(); $language->setName('Tamil'); $this->languageDao->saveLanguage($language); $savedLanguage = TestDataService::fetchLastInsertedRecord('Language', 'id'); $this->assertTrue($savedLanguage instanceof Language); $this->assertEquals('Tamil', $savedLanguage->getName()); }
public function actionAdmin() { $model = new Language('search'); $model->unsetAttributes(); if (isset($_GET['Language'])) { $model->setAttributes($_GET['Language']); } $this->render('admin', array('model' => $model)); }