function flash($title = null, $message = null) { $flash = new FlashMessage(); if ($title == null && $message == null) { return $flash->create(); } return $flash->create($title, $message); }
/** * Store a newly created resource in storage. * * @return Response */ public function update($id) { // Get input and save into variable. $data = Input::all(); // Validate input data. $val = AboutUs::validate($data); // If validator fails show errors to user. if ($val->fails()) { return Redirect::back()->withErrors($val); } // If no validation errors, update About Us information on database. $aboutus = AboutUs::find($id); $aboutus->title = Input::get('title'); $aboutus->body = Input::get('body'); // Get original data to compare if changes were made. $original = AboutUs::find($id); // Check if changes were made, if so, save to form, if no, redirect back with message. if ($original->title != $aboutus->title || $original->body != $aboutus->body) { $aboutus->save(); // Redirect with success message. return Redirect::back()->with('message', FlashMessage::DisplayAlert('Information Updated Successfully!', 'success')); } else { // No changes were made, redirect back with warning message. return Redirect::back()->with('message', FlashMessage::DisplayAlert('Nothing to update. No changes made.', 'warning')); } }
/** * Returns true on success, false on errors. */ function validate($src) { $success = true; if (!$src->name) { FlashMessage::add('Numele nu poate fi vid.'); $success = false; } if (!$src->shortName) { FlashMessage::add('Numele scurt nu poate fi vid.'); $success = false; } if (!$src->urlName) { FlashMessage::add('Numele URL nu poate fi vid.'); $success = false; } if (!$src->author) { FlashMessage::add('Autorul nu poate fi vid.'); $success = false; } if ($src->defCount < 0 && $src->defCount != Source::$UNKNOWN_DEF_COUNT) { FlashMessage::add("Numărul de definiții trebuie să fie pozitiv."); $success = false; } return $success; }
/** * このクラスのインスタンスを取得 */ public static function getInstance() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; }
function perform() { $company_id = $this->session->get('company_id'); $user_id = $this->session->get('user_id'); $current_pwd = $this->af->get('current_pwd'); $new_pwd1 = $this->af->get('new_pwd1'); $new_pwd2 = $this->af->get('new_pwd2'); $current_pwd_hash = md5($current_pwd); $new_pwd_hash = md5($new_pwd1); // 入力値チェック $params = array('company_id' => $company_id, 'user_id' => $user_id, 'current_pwd' => $current_pwd, 'current_pwd_hash' => $current_pwd_hash, 'new_pwd1' => $new_pwd1, 'new_pwd2' => $new_pwd2); $error_message = $this->validateParams($params); if (!empty($error_message)) { return array(400, $error_message); exit; } // 更新 $UserMst = DaoFactory::UserMst(); $params = array('company_id' => $company_id, 'user_id' => $user_id, 'user_pwd' => $new_pwd_hash, 'upd_uid' => $user_id, 'upd_pgm' => get_class()); $ret = $UserMst->UserMst_PasswordUpdate($params); if (!$ret) { $result = array('result' => 'error', 'error_message' => 'DBの更新に失敗しました。'); echo json_encode($result); exit; } $this->session->set('pwd_kigengire', 0); FlashMessage::getInstance()->add('パスワードを変更しました。'); $result = array('result' => 'success'); echo json_encode($result); exit; }
/** * Store a newly created resource in storage. * * @return Response */ public function update($id) { $input = Input::all(); $val = ContactUs::validate($input); if ($val->fails()) { return Redirect::back()->withErrors($val); } $contactus = ContactUs::find($id); $contactus->title = Input::get('title'); $contactus->address = Input::get('address'); $contactus->city = Input::get('city'); $contactus->state = Input::get('state'); $contactus->zip = Input::get('zip'); $contactus->email_1 = Input::get('email_1'); $contactus->email_2 = Input::get('email_2'); $contactus->phone_1 = Input::get('phone_1'); $contactus->phone_2 = Input::get('phone_2'); // Original record $original = ContactUs::find($id); // If nothing changed do not make call to database and return with warning message. if ($original->title != $contactus->title || $original->address != $contactus->address || $original->city != $contactus->city || $original->state != $contactus->state || $original->zip != $contactus->zip || $original->email_1 != $contactus->email_1 || $original->email_2 != $contactus->email_2 || $original->phone_1 != $contactus->phone_1 || $original->phone_2 != $contactus->phone_2) { $contactus->save(); return Redirect::back()->with('message', FlashMessage::DisplayAlert('Information Updated Successfully!', 'success')); } return Redirect::back()->with('message', FlashMessage::DisplayAlert('Nothing to update. No changes made.', 'warning')); }
/** * Returns null and sets a flash message on all errors. **/ static function finishAuth() { $consumer = self::getConsumer(); $return_to = self::getReturnTo(); $response = $consumer->complete($return_to); if ($response->status == Auth_OpenID_CANCEL) { FlashMessage::add('Verificare anulată.'); return null; } else { if ($response->status == Auth_OpenID_FAILURE) { FlashMessage::add('Verificarea a eșuat: ' . $response->message); return null; } else { if ($response->status == Auth_OpenID_SUCCESS) { $result = array(); $result['identity'] = htmlentities($response->getDisplayIdentifier()); if ($response->endpoint->canonicalID) { $escaped_canonicalID = htmlentities($response->endpoint->canonicalID); // Ignored for now } $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response); if ($sreg_resp) { $sreg = $sreg_resp->contents(); if (isset($sreg['email'])) { $result['email'] = $sreg['email']; } if (isset($sreg['nickname'])) { $result['nickname'] = $sreg['nickname']; } if (isset($sreg['fullname'])) { $result['fullname'] = $sreg['fullname']; } } $ax_resp = Auth_OpenID_AX_FetchResponse::fromSuccessResponse($response); if ($ax_resp) { $data = $ax_resp->data; if (isset($data['http://axschema.org/contact/email']) && count($data['http://axschema.org/contact/email'])) { $result['email'] = $data['http://axschema.org/contact/email'][0]; // Take this over sreg } if (isset($data['http://axschema.org/namePerson']) && count($data['http://axschema.org/namePerson'])) { $result['fullname'] = $data['http://axschema.org/namePerson'][0]; } $names = array(); if (isset($data['http://axschema.org/namePerson/first']) && count($data['http://axschema.org/namePerson/first'])) { $names[] = $data['http://axschema.org/namePerson/first'][0]; } if (isset($data['http://axschema.org/namePerson/last']) && count($data['http://axschema.org/namePerson/last'])) { $names[] = $data['http://axschema.org/namePerson/last'][0]; } if (count($names)) { $result['fullname'] = implode(' ', $names); } } return $result; } } } }
protected function setLoginErrorAndQuit($message) { if (isset($message)) { FlashMessage::flash('LoginError', $message); header('Location: /account.php'); exit; } }
private function setLoginErrorAndQuit($message) { if (isset($message)) { FlashMessage::flash('LoginError', $message); header('Location: /admin.php'); exit; } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $status = Status::find($id); if ($status) { try { // Delete breed, if not possible, catch error. $status->delete(); } catch (Exception $e) { // If breed to be deleted is in use, send nice error back to admin. return Redirect::back()->with('message', FlashMessage::DisplayAlert('Status can NOT be deleted because it\'s in use.', 'alert')); } return Redirect::back()->with('message', FlashMessage::DisplayAlert('Status Deleted Successfully!', 'success')); } return Redirect::back()->with('message', FlashMessage::DisplayAlert('Record Not Found.', 'alert')); }
/** * Smarty {flash_message} function plugin */ function smarty_function_flash_message($params, &$smarty) { $class = $params['class'] ? $params['class'] : 'flash_message'; $style = $params['style'] ? $params['style'] : ''; $id = $params['id'] ? $params['id'] : ''; $FlMsgObj = FlashMessage::getInstance(); $msg = $FlMsgObj->get(); $FlMsgObj->clear(); if (count($msg) == 0) { return; } $html = '<ul ' . ($id != '' ? 'id="' . $id . '" ' : '') . ($style != '' ? ' style="' . $style . '" ' : '') . ' class="' . $class . '">'; foreach ($msg as $m) { $html .= '<li>' . $m . '</li>'; } $html .= '</ul>'; return $html; }
public function updateProfile($id) { $input = Input::all(); $val = User::validate($input, $id); // If validator fails redirect back with errors for user to correct. if ($val->fails()) { return Redirect::back()->withErrors($val); } $update = User::find($id); if ($update) { $update->username = Input::get('username'); $update->email = Input::get('email'); $update->password = Hash::make(Input::get('password')); $update->save(); } else { return Redirect::back()->with('message', FlashMessage::DisplayAlert('User not found!', 'alert')); } return Redirect::to('admin/dashboard')->with('message', FlashMessage::DisplayAlert('User Profile Updated Successfully.', 'success')); }
public static function displayFlash($messageName, $type = '') { if (isset($messageName)) { if ($type == 'message') { echo '<div class="col-md-12">'; echo '<div class="alert alert-success flash-alert">'; echo '<a href="#" class="close" data-dismiss="alert">×</a>' . FlashMessage::flash($messageName); echo '</div><br />'; echo '</div>'; return true; } else { echo '<div class="col-md-12">'; echo '<div class="alert alert-danger flash-alert">'; echo '<a href="#" class="close" data-dismiss="alert">×</a>' . FlashMessage::flash($messageName); echo '</div><br />'; echo '</div>'; return true; } } return false; }
} } } class SyslogLogger { // ... public function info($message) { syslog(LOG_INFO, $message); } } class FlashMessage { // ... public function success($message) { echo $message; } } /// $data = ['username' => 'adrianpietka', 'password' => 'strong#password', 'email' => '*****@*****.**']; $flash = new FlashMessage(); $logger = new SyslogLogger(); $userRepository = new DoctrineUserRepository(); $userFactory = new RegisterFormUserFactory(); $registerService = new RegisterUserService($userRepository, $userFactory); $registerService->register($data, function ($user) use($logger, $flash) { $logger->info(sprintf('Created new account with email: %s', $user->getEmail())); $flash->success('Congratulations your registration has been successful.'); }); // @via zawarstwaabstrakcji.pl
if ($error) { throw new OpenIDException($errorDescription); } if (!$code || !$state || $state != session_get('openid_connect_state')) { throw new OpenIDException('Răspuns incorect de la server'); } if (!$provider) { throw new OpenIDException('Sesiune coruptă'); } $token = $oidc->requestToken($code); $data = $oidc->getUserInfo($token); if (!isset($data['sub'])) { throw new OpenIDException('Date incorecte de la furnizor'); } } catch (OpenIDException $e) { FlashMessage::add('Eroare la autentificare: ' . $e->getMessage()); util_redirect('login.php'); } // With OpenID connect, the user is uniquely identified by (provider, sub). // We store the provider in the User.identity field for backwards compatibility with OpenID. // We also rename the name field to fullname, plain OpenID style $data['identity'] = $provider; if (isset($data['name'])) { $data['fullname'] = $data['name']; } $user = User::get_by_identity_openidConnectSub($provider, $data['sub']); if (!$user && $oidc->getPlainOpenid()) { // This may be the first time the user logs in after the migration from // OpenID 2.0 to OpenID Connect. $user = User::get_by_identity($oidc->getPlainOpenid()); if ($user) {
--> <html> <head> <meta charset="UTF-8"> <title></title> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"> </head> <body> <div class="text-info"> <?php session_start(); /*$_SESSION['flashmessages'] = array( 'testing' => 'FlashMessage test' );*/ include './models/IMessage.php'; include './models/Message.php'; include './models/FlashMessage.php'; $flashMessage = new FlashMessage(); $messages = $flashMessage->getAllMessages(); print_r($messages); ?> </div> </body> </html>
if (substr($_REQUEST['remote_url'], 0, 9) == 'web+fork:') { $_REQUEST['remote_url'] = substr($_REQUEST['remote_url'], 9); } $fr = new ForkRemote($_REQUEST['remote_url']); if (false === $fr->parse()) { //no url found $error = $fr->error; } else { if (false !== ($gitUrl = $fr->getUniqueGitUrl())) { if (isset($_POST['orig_url'])) { $fr->setUrl($_POST['orig_url']); } $forker = new Forker(); try { $new = $forker->forkRemote($gitUrl['url'], $fr->getUrl(), $gitUrl['title']); FlashMessage::save('Remote paste has been forked'); redirect($new->getLink('display', null, true)); } catch (\Exception $e) { $error = $e->getMessage(); } } else { //multiple urls found $urls = $fr->getGitUrls(); } } } $selsize = 0; if (is_array($urls)) { foreach ($urls as $group) { ++$selsize; if (count($group) > 1) {
<!-- Navigation Menu Ends --> <!-- Content Starts --> <div class="container" id="mainContentBody"> <!-- Start of form inspired from http://bootswatch.com/flatly/ --> <div class="col-md-12"> <form class="form-horizontal" method="post" action="admin.php" name="loginform"> <fieldset> <h2 class="topHeader">Administrator Login</h2> <div class="col-md-12"> <?php // Show potential feedback from the login object if (FlashMessage::flashIsSet('LoginError')) { FlashMessage::displayFlash('LoginError', 'error'); } elseif (FlashMessage::flashIsSet('LoginMessage')) { FlashMessage::displayFlash('LoginMessage', 'message'); } ?> </div> <div class="form-group"> <label for="inputUsername" class="col-lg-2 control-label"><a href="#" class="tool-tip" data-toggle="tooltip" data-placement="top" data-original-title="This username will be provided to you from CloudEther when a payment plan has been agreed upon.">Username:</a> </label> <div class="col-lg-10"> <input type="text" class="form-control" id="inputUsername" placeholder="Username" name="admin_name"> </div> </div> <div class="form-group"> <label for="inputPassword" class="col-lg-2 control-label">Password:</label> <div class="col-lg-10"> <input type="password" class="form-control" id="inputPassword" placeholder="Password" name="admin_password" autocomplete="off"> </div>
if ($value) { $m = Model::factory('FlexModel')->where_raw("concat(modelType, number) = '{$value}'")->find_one(); if ($m) { $oldModelType = $lm->modelType; $oldModelNumber = $lm->modelNumber; $lm->modelType = $m->modelType; $lm->modelNumber = $m->number; $ifs = $lm->generateInflectedForms(); if (!is_array($ifs)) { FlashMessage::add("Lexemul '{$l->formNoAccent}' nu poate fi flexionat cu modelul '{$value}'"); $errorMap[$l->id] = true; $lm->modelType = $oldModelType; $lm->modelNumber = $oldModelNumber; } } else { FlashMessage::add("Modelul '{$value}' nu există pentru lexemul '{$l->formNoAccent}'."); $errorMap[$l->id] = true; } } break; case 'verifSp': $l->verifSp = 1; break; case 'comment': if ($l->comment) { $l->comment = $value; } break; case 'delete': case 'deleteConfirm': $deleteMap[$l->id] = array_key_exists($l->id, $deleteMap) ? $deleteMap[$l->id] + 1 : 1;
public function registerNewUser($user_group = 1) { if (empty($_POST['user_name'])) { $this->setErrorAndQuit('Username cannot be empty.'); } elseif (empty($_POST['user_password_new']) || empty($_POST['user_password_repeat'])) { $this->setErrorAndQuit('Password cannot be empty.'); } elseif ($_POST['user_password_new'] !== $_POST['user_password_repeat']) { $this->setErrorAndQuit('RegisterError', 'Passwords do not match.'); } elseif (!passwordPolicyMatch($_POST['user_password_new'])) { $this->setErrorAndQuit('Password does not match'); } elseif (strlen($_POST['user_name']) > 64 || strlen($_POST['user_name']) < 2) { $this->setErrorAndQuit('Password does not conform to the password policy.<br />' . passwordPolicyWritten()); } elseif (!preg_match('/^[a-zA-Z0-9]*[_.-]?[a-zA-Z0-9]*$/', $_POST['user_name'])) { $this->setErrorAndQuit('Username does not match the naming scheme. Only letters, numbers, underscores, and periods are allowed'); } elseif (empty($_POST['user_email'])) { $this->setErrorAndQuit('Email cannot be empty.'); } elseif (strlen($_POST['user_email']) > 64) { $this->setErrorAndQuit('Email cannot be longer than 64 characters.'); } elseif (!filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)) { $this->setErrorAndQuit('Your email address is not in a valid email format.'); } elseif (!empty($_POST['user_name']) && strlen($_POST['user_name']) <= 64 && strlen($_POST['user_name']) >= 2 && preg_match('/^[a-zA-Z0-9]*[_.-]?[a-zA-Z0-9]*$/', $_POST['user_name']) && !empty($_POST['user_email']) && strlen($_POST['user_email']) <= 64 && filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL) && !empty($_POST['user_password_new']) && !empty($_POST['user_password_repeat']) && $_POST['user_password_new'] === $_POST['user_password_repeat']) { if ($this->db_connection = startPDOConnection()) { //Trim the whitespace $user_name = trim($_POST['user_name']); $user_fullname = trim($_POST['user_fullname']); $user_email = trim($_POST['user_email']); $user_password = $_POST['user_password_new']; $user_created = date('Y-m-d H:i:s'); $user_password_hash = password_hash($user_password, PASSWORD_DEFAULT); if (isset($_POST['account_type']) && $_POST['account_type'] == 'admin') { $account_type = 'admin'; } else { $account_type = 'clients'; } // Check if the user/email address is already taken or not if ($stmt = $this->db_connection->prepare('SELECT * FROM ' . $account_type . ' WHERE username=? OR email=?')) { if ($stmt->execute(array($user_name, $user_email))) { if ($stmt->rowCount() == 1) { $this->setErrorAndQuit('Sorry, that username or email address is already taken.'); } else { $stmt = null; // Prepare and bind the database to insert the administrator account if ($stmt = $this->db_connection->prepare('INSERT INTO ' . $account_type . ' (username, password, email, name, created) VALUES (?, ?, ?, ?, ?)')) { if ($stmt->execute(array($user_name, $user_password_hash, $user_email, $user_fullname, $user_created))) { FlashMessage::flash('RegisterSuccess', $user_name . ' has been created successfully.'); header('Location: /admin/newaccount.php'); exit; } else { $this->setErrorAndQuit('Sorry, your registration failed.<br />Please go back and try again.'); } } else { $this->setErrorAndQuit('Sorry, your registration failed.<br />Please go back and try again.'); } } } else { $this->setErrorAndQuit('There was a problem connecting to the database.<br />Please try again.'); } } else { $this->setErrorAndQuit('There was a problem connecting to the database.<br />Please try again.'); } } else { $this->setErrorAndQuit('There was a problem connecting to the database.<br />Please try again.'); } } else { $this->setErrorAndQuit('Sorry, your registration failed.<br />Please go back and try again.'); } }
<?php require_once "../phplib/util.php"; $submitButton = util_getRequestParameter('submitButton'); if ($submitButton) { util_assertModerator(PRIV_ADMIN); $order = 1; $ids = util_getRequestParameter("ids"); foreach ($ids as $id) { $src = Source::get_by_id($id); $src->displayOrder = $order++; $src->save(); } FlashMessage::add('Ordinea a fost salvată.', 'info'); util_redirect('surse'); } $sources = util_isModerator(PRIV_VIEW_HIDDEN) ? Model::factory('Source')->order_by_asc('displayOrder')->find_many() : Model::factory('Source')->where_not_equal('isOfficial', SOURCE_TYPE_HIDDEN)->order_by_asc('displayOrder')->find_many(); smarty_assign('sources', $sources); smarty_assign('page_title', 'Surse'); smarty_displayCommonPageWithSkin('surse.ihtml');
require_once "../phplib/util.php"; // Parse or initialize the GET/POST arguments $nick = util_getRequestParameter('n'); $medalSaveButton = util_getRequestParameter('medalSaveButton'); $userId = util_getRequestParameter('userId'); $medalsGranted = util_getRequestParameter('medalsGranted'); if ($medalSaveButton) { util_assertModerator(PRIV_ADMIN); $user = User::get_by_id($userId); $user->medalMask = Medal::getCanonicalMask(array_sum($medalsGranted)); $user->save(); util_redirect(util_getWwwRoot() . "utilizator/{$user->nick}"); } $user = User::get_by_nick($nick); if (!$user) { FlashMessage::add('Utilizatorul ' . htmlspecialchars($nick) . ' nu există.'); util_redirect(util_getWwwRoot()); } $userData = array(); $user->email = StringUtil::scrambleEmail($user->email); // Find the rank of this user by number of words and number of characters $topWords = TopEntry::getTopData(CRIT_WORDS, SORT_DESC, true); $numUsers = count($topWords); $rankWords = 0; while ($rankWords < $numUsers && $topWords[$rankWords]->userNick != $nick) { $rankWords++; } $userData['rank_words'] = $rankWords + 1; if ($rankWords < $numUsers) { $topEntry = $topWords[$rankWords]; $userData['last_submission'] = $topEntry->timestamp;
<?php require_once "../phplib/util.php"; ini_set('max_execution_time', '3600'); define('DB_QUERY', 'select * from Lexem where isLoc order by formNoAccent'); $locVersion = util_getRequestParameter('locVersion'); $newLocVersion = util_getRequestParameter('newLocVersion'); if ($newLocVersion) { if ($locVersion == $newLocVersion) { FlashMessage::add('Ați selectat aceeași versiune LOC de două ori'); util_redirect('scrabble-loc'); } $file1 = tempnam('/tmp', 'loc_diff_'); $file2 = tempnam('/tmp', 'loc_diff_'); writeLexems($locVersion, $file1); writeLexems($newLocVersion, $file2); $diff = OS::executeAndReturnOutput("diff {$file1} {$file2} || true"); print "<pre>\n"; foreach ($diff as $line) { if (StringUtil::startsWith($line, '< ')) { print sprintf("<span style=\"color: red\">%s: %s</span>\n", $locVersion, substr($line, 2)); } else { if (StringUtil::startsWith($line, '> ')) { print sprintf("<span style=\"color: green\">%s: %s</span>\n", $newLocVersion, substr($line, 2)); } } } print "</pre>\n"; util_deleteFile($file1); util_deleteFile($file2); exit;
Route::get('laravel-version', function () { $laravel = app(); return "Your Laravel version is " . $laravel::VERSION; }); //Ruta pentru pagina de login Route::get('login', function () { return View::make('login.loginform')->with('title', 'Login'); // este numele viewului login.loginform; in folderul views trebuie sa avem folderul login si in el fisierul loginform.blade.php }); //ruta pentru logarea din form Route::post('login', 'UserController@login'); //ruta pentru logout Route::get('logout', function () { Auth::logout(); Session::flush(); return Redirect::to('login')->with('message', FlashMessage::DisplayAlert('Logout succesful', 'info')); }); //ruta pentru logarea din form Route::get('signup', function () { return View::make('user.signup')->with('title', 'Signup'); }); //ruta pentru signup page Route::post('signup', 'UserController@signup'); //ruta catre formularul de forgotten [password Route::get('forgotpassword', function () { return View::make('user.forgotpassword')->with('title', 'Password Reset'); }); //Route sumit of forgotten password form to the UserController Route::post('forgotpassword', 'UserController@forgotpassword'); //Route that uses the reset code to reset a users password Route::get('resetpassword/{resetcode}', 'UserController@resetpassword');
// Exercise the fields we'll need later in the view. // TODO: this code replicates code from search.php $hasUnrecommendedForms = false; foreach ($filtered_lexems as $l) { foreach ($l->getLexemModels() as $lm) { $lm->getModelType(); $lm->getSourceNames(); $map = $lm->loadInflectedFormMap(); $lm->addLocInfo(); foreach ($map as $ifs) { foreach ($ifs as $if) { $hasUnrecommendedForms |= !$if->recommended; } } } } SmartyWrap::assign('hasUnrecommendedForms', $hasUnrecommendedForms); SmartyWrap::assign('lexems', $filtered_lexems); SmartyWrap::assign('showParadigm', true); SmartyWrap::assign('locParadigm', session_user_prefers(Preferences::LOC_PARADIGM)); SmartyWrap::assign('onlyParadigm', !$ajax); } else { FlashMessage::add("Niciun rezultat pentru {$cuv}."); SmartyWrap::assign('page_title', "Eroare"); } if ($ajax) { SmartyWrap::displayWithoutSkin('bits/multiParadigm.ihtml'); } else { SmartyWrap::addCss('paradigm'); SmartyWrap::display('search.ihtml'); }
$words = preg_split('/[ .-]+/', $cuv); if (count($words) > 1) { $ignoredWords = array_slice($words, 5); $words = array_slice($words, 0, 5); $definitions = Definition::searchMultipleWords($words, $hasDiacritics, $sourceId, $exclude_unofficial); smarty_assign('ignoredWords', $ignoredWords); } } if (count($lexems) == 0 && empty($definitions)) { $searchType = SEARCH_APPROXIMATE; $lexems = Lexem::searchApproximate($cuv, $hasDiacritics, true); if (count($lexems) == 1) { FlashMessage::add("Ați fost redirecționat automat la forma „{$lexems[0]->formNoAccent}”."); } else { if (!count($lexems)) { FlashMessage::add("Niciun rezultat relevant pentru „{$cuv}”."); } } } if (count($lexems) == 1 && $cuv != $lexems[0]->formNoAccent) { // Convenience redirect when there is only one correct form. We want all pages to be canonical $sourcePart = $source ? "-{$source->urlName}" : ''; session_setVariable('redirect', true); session_setVariable('init_word', $cuv); util_redirect(util_getWwwRoot() . "definitie{$sourcePart}/{$lexems[0]->formNoAccent}" . ($xml ? '/xml' : '')); } smarty_assign('lexems', $lexems); if ($searchType == SEARCH_INFLECTED) { // For successful searches, load the definitions, inflections and linguistic articles $definitions = Definition::loadForLexems($lexems, $sourceId, $cuv, $exclude_unofficial); smarty_assign('wikiArticles', WikiArticle::loadForLexems($lexems));
if (count($matches) >= 1) { foreach ($matches as $match) { LexemDefinitionMap::associate($match->id, $definition->id); log_userLog("Associating with lexem {$match->id} ({$match->form})"); } } else { // Create a new lexem. $lexem = Lexem::create($lexemName, 'T', '1', ''); $lexem->save(); $lexem->regenerateParadigm(); LexemDefinitionMap::associate($lexem->id, $definition->id); log_userLog("Created lexem {$lexem->id} ({$lexem->form})"); } } } FlashMessage::add('Definiția a fost trimisă. Un moderator o va examina în scurt timp. Vă mulțumim!', 'info'); util_redirect('contribuie'); } } else { smarty_assign('sourceId', session_getDefaultContribSourceId()); } smarty_assign('contribSources', Model::factory('Source')->where('canContribute', true)->order_by_asc('displayOrder')->find_many()); smarty_assign('page_title', 'Contribuie cu definiții'); smarty_assign('suggestNoBanner', true); smarty_displayCommonPageWithSkin('contribuie.ihtml'); /**************************************************************************/ function deleteEmptyElements(&$v) { $result = array(); foreach ($v as $elem) { if (!empty($elem)) {
<?php require_once "../phplib/util.php"; require_once "../phplib/userPreferences.php"; util_assertNotLoggedIn(); $sendButton = util_getRequestParameter('send'); if ($sendButton) { $userPrefs = util_getRequestCheckboxArray('userPrefs', ','); $skin = util_getRequestParameter('skin'); session_setAnonymousPrefs($userPrefs); if (session_isValidSkin($skin)) { session_setSkin($skin); } FlashMessage::add('Preferințele au fost salvate.', 'info'); util_redirect('preferinte'); } else { $userPrefs = session_getAnonymousPrefs(); $skin = session_getSkin(); } foreach (preg_split('/,/', $userPrefs) as $pref) { if (isset($userPreferencesSet[$pref])) { $userPreferencesSet[$pref]['checked'] = true; } } smarty_assign('userPrefs', $userPreferencesSet); smarty_assign('skin', $skin); smarty_assign('availableSkins', pref_getServerPreference('skins')); smarty_assign('page_title', 'Preferințe'); smarty_displayCommonPageWithSkin('preferinte.ihtml');
require_once "../../phplib/util.php"; util_assertModerator(PRIV_ADMIN); util_assertNotMirror(); $MAX_AFFECTED = 1000; $search = util_getRequestParameter('search'); $replace = util_getRequestParameter('replace'); $sourceId = util_getRequestParameter('source'); $realRun = util_getRequestParameter('realRun'); $sourceClause = $sourceId ? "and sourceId = {$sourceId}" : ''; $count = Model::factory('Definition')->where_raw("status = 0 {$sourceClause} and binary internalRep like '%{$search}%'")->count(); if ($count > $MAX_AFFECTED) { if ($realRun) { FlashMessage::add("{$count} definiții se potrivesc, numai {$MAX_AFFECTED} au fost modificate.", 'info'); } else { FlashMessage::add("{$count} definiții se potrivesc, maxim {$MAX_AFFECTED} vor fi modificate."); } } $defs = Model::factory('Definition')->where_raw("status = 0 {$sourceClause} and binary internalRep like '%{$search}%'")->order_by_asc('id')->limit($MAX_AFFECTED)->find_many(); $searchResults = SearchResult::mapDefinitionArray($defs); foreach ($defs as $def) { $def->internalRep = str_replace($search, $replace, $def->internalRep); $ambiguousMatches = array(); $def->internalRep = AdminStringUtil::internalizeDefinition($def->internalRep, $def->sourceId, $ambiguousMatches); $def->htmlRep = AdminStringUtil::htmlize($def->internalRep, $def->sourceId); // Complete or un-complete the abbreviation review if (!count($ambiguousMatches) && $def->abbrevReview == ABBREV_AMBIGUOUS) { $def->abbrevReview = ABBREV_REVIEW_COMPLETE; } else { if (count($ambiguousMatches) && $def->abbrevReview == ABBREV_REVIEW_COMPLETE) { $def->abbrevReview = ABBREV_AMBIGUOUS;
/** * Delete lexems that do not have their own definitions. * Arguments for participles: 'A', ($adjectiveModel). * Arguments for long infinitives: 'F', ('107', '113'). */ private function _deleteDependentModels($inflId, $modelType, $modelNumbers) { // Load and hash all the definitionIds $ldms = LexemDefinitionMap::get_all_by_lexemId($this->id); $defHash = array(); foreach ($ldms as $ldm) { $defHash[$ldm->definitionId] = true; } // Iterate through all the forms of the desired inflection (participle / long infinitive) foreach ($this->getLexemModels() as $lm) { $ifs = InflectedForm::get_all_by_lexemModelId_inflectionId($lm->id, $inflId); foreach ($ifs as $if) { // Examine all lexems having one of the above forms $lexems = Lexem::get_all_by_formNoAccent($if->formNoAccent); foreach ($lexems as $l) { // Keep only the ones that have acceptable model types/numbers $acceptable = false; foreach ($l->getLexemModels() as $o) { if ($o->modelType == 'T' || $o->modelType == $modelType && in_array($o->modelNumber, $modelNumbers)) { $acceptable = true; } } // If $l has the right model, delete it unless it has its own definitions if ($acceptable) { $ownDefinitions = false; $ldms = LexemDefinitionMap::get_all_by_lexemId($l->id); foreach ($ldms as $ldm) { if (!array_key_exists($ldm->definitionId, $defHash)) { $ownDefinitions = true; } } if (!$ownDefinitions) { FlashMessage::add("Am șters automat lexemul {$l->formNoAccent}.", 'info'); $l->delete(); } } } } } }