/** * Retrieve the name of a language * @param string $languageCode The language code. If it contails also a terrotory code (eg: 'en-US'), the result will contain also the territory code (eg 'English (United States)') * @param string $locale = '' The locale to use. If empty we'll use the default locale set in \Punic\Data * @return string Returns the localized language name (returns $languageCode if not found) */ public static function getName($languageCode, $locale = '') { $result = $languageCode; $info = Data::explodeLocale($languageCode); if (!is_null($info)) { extract($info); $lookFor = array(); if (strlen($script)) { if (strlen($territory)) { $lookFor[] = "{$language}-{$script}-{$territory}"; } $lookFor[] = "{$language}-{$script}"; } elseif (strlen($territory)) { $lookFor[] = "{$language}-{$territory}"; } $lookFor[] = $language; $data = Data::get('languages', $locale); foreach ($lookFor as $key) { if (array_key_exists($key, $data)) { $result = $data[$key]; break; } } if (strlen($territory)) { $territoryName = Territory::getName($territory, $locale); if (strlen($territoryName)) { $patternData = Data::get('localeDisplayNames'); $pattern = $patternData['localeDisplayPattern']['localePattern']; $result = sprintf($pattern, $result, $territoryName); } } } return $result; }
public function sendJSON() { $data = Data::get()->getData(); header('Content-Type: application/json; charset=utf-8'); //Dev //var_dump($data); //Prod echo json_encode($data); }
public function doDelete() { $id = Data::get('id', '', Data::INT); if ($id) { if (Group::i($id)->delete()) { return true; } } return false; }
public function doSignIn() { $email = Data::get('email'); $password = Data::get('password'); $a = (object) array('success' => false, 'message' => ''); if (User::auth($email, $password)) { $a->message = 'Вы успешно авторизовались'; $a->success = true; } else { $a->message = 'Ошибка при авторизации'; } return $a; }
/** * @covers Geissler\CSL\Data\Data::getVariable * @depends testSet */ public function testGetVariable() { $json = '[ { "title": "My Book", "edition": "5", "id": "ITEM-1", "type": "book" }]'; $this->assertInstanceOf($this->class, $this->object->set($json)); $this->assertInternalType('array', $this->object->get()); $this->assertEquals('My Book', $this->object->getVariable('title')); $this->assertNull($this->object->getVariable('volume')); }
public function doAddAuditory() { $auditory = new StdClass(); $fields = array('number' => Data::STR, 'name' => Data::STR, 'build' => Data::STR); foreach ($fields as $field => $dataType) { $auditory->{$field} = Data::get($field, '', $dataType); } $a = (object) array('success' => false, 'message' => ''); if (Auditory::add($auditory)) { $a->message = 'Кабинет успешно добавлен!'; $a->success = true; } else { $a->message = 'Ошибка при добавлении кабинета'; } return $a; }
public function ajaxSignIn() { $user = new StdClass(); $fields = array('name' => Data::STR, 'password' => Data::STR); foreach ($fields as $field => $dataType) { $user->{$field} = Data::get($field, '', $dataType); } $a = (object) array('success' => false, 'message' => '0'); if (User::auth($user)) { $a->message = 'Вы успешно авторизовались'; $a->success = true; } else { $a->message = 'Ошибка при авторизации'; } return $a; }
public function doAddSubject() { $subject = new StdClass(); $fields = array('name' => Data::STR); foreach ($fields as $field => $dataType) { $subject->{$field} = Data::get($field, '', $dataType); } $a = (object) array('success' => false, 'message' => ''); if (Subject::add($subject)) { $a->message = 'Урок успешно добавлен!'; $a->success = true; } else { $a->message = 'Ошибка при добавлении урока'; } return $a; }
public function doSignUp() { $user = new StdClass(); $fields = array('name' => Data::STR, 'lastname' => Data::STR, 'middlename' => Data::STR, 'email' => Data::STR, 'phone' => Data::INT, 'password' => Data::STR); foreach ($fields as $field => $dataType) { $user->{$field} = Data::get($field, '', $dataType); } $a = (object) array('success' => false, 'message' => ''); if (User::add($user)) { $a->message = 'Пользователь успешно добавлен!'; $a->success = true; } else { $a->message = 'Ошибка при создании пользователя'; } return $a; }
public function doUpdate() { if ($lessons = Data::get("lessons")) { $lessons = json_decode($lessons); } if (!is_array($lessons)) { return false; } $n = 1; foreach ($lessons as $lessonid) { if ($lessonid) { $lesson = Lesson::i($lessonid); $lesson->subject_seq = $n; $lesson->update(); } $n++; } }
/** * Retrieve the name of a language. * * @param string $languageCode The language code. If it contails also a terrotory code (eg: 'en-US'), the result will contain also the territory code (eg 'English (United States)') * @param string $locale The locale to use. If empty we'll use the default locale set in \Punic\Data * * @return string Returns the localized language name (returns $languageCode if not found) */ public static function getName($languageCode, $locale = '') { $result = $languageCode; $info = Data::explodeLocale($languageCode); if ($info !== null) { $language = $info['language']; $script = $info['script']; $territory = $info['territory']; $lookFor = array(); if (isset($script[0])) { if (isset($territory[0])) { $lookFor[] = "{$language}-{$script}-{$territory}"; } $lookFor[] = "{$language}-{$script}"; } elseif (isset($territory[0])) { $lookFor[] = "{$language}-{$territory}"; } $lookFor[] = $language; $data = Data::get('languages', $locale); foreach ($lookFor as $key) { if (isset($data[$key])) { $result = $data[$key]; break; } } if (isset($territory[0])) { $territoryName = Territory::getName($territory, $locale); if (isset($territoryName[0])) { $patternData = Data::get('localeDisplayNames'); $pattern = $patternData['localeDisplayPattern']['localePattern']; $result = sprintf($pattern, $result, $territoryName); } } } return $result; }
/** * Return a list of some specified territory, structured or not. * $levels control which data you want to retrieve. It can be one or more of the following values: * <ul> * <li>'W': world</li> * <li>'C': continents</li> * <li>'S': sub-continents</li> * <li>'c': countries</li> * </ul> * If only one level is specified you'll get a flat list (like the one returned by {@link getContinents}). * If one or more levels are specified, you'll get a structured list (like the one returned by {@link getContinentsAndCountries}). * @param string $levels A string with one or more of the characters: 'W' (for world), 'C' (for continents), 'S' (for sub-continents), 'c' (for countries) * @param string $locale = '' The locale to use. If empty we'll use the default locale set in \Punic\Data * @return array * @link http://www.unicode.org/cldr/charts/latest/supplemental/territory_containment_un_m_49.html */ public static function getList($levels = 'W', $locale = '') { static $levelMap = array('W' => 0, 'C' => 1, 'S' => 2, 'c' => 3); $decodedLevels = array(); $n = is_string($levels) ? strlen($levels) : 0; if ($n > 0) { for ($i = 0; $i < $n; $i++) { $l = substr($levels, $i, 1); if (!array_key_exists($l, $levelMap)) { $decodedLevels = array(); break; } if (!in_array($levelMap[$l], $decodedLevels, true)) { $decodedLevels[] = $levelMap[$l]; } } } if (count($decodedLevels) === 0) { throw new \Punic\Exception\BadArgumentType($levels, "list of territory kinds: it should be a list of one or more of the codes '" . implode("', '", array_keys($levelMap)) . "'"); } $struct = self::filterStructure(self::getStructure(), $decodedLevels, 0); $flatList = count($decodedLevels) > 1 ? false : true; $finalized = self::finalizeWithNames(Data::get('territories', $locale), $struct, $flatList); if ($flatList) { natcasesort($finalized); } else { $finalized = static::sort($finalized); } return $finalized; }
public function albumlist() { //获取博主Id $_GET['blogerId'] = 1; //测试 $blogerId = Data::get($_GET['blogerId'], Data::Int); //$blogerId =1;//测试 if (!isset($_GET['blogerId']) || empty($blogerId)) { R('Index', 'index'); } //实例化Model $photoModel = new PhotosModel(); $albumModel = new AlbumModel(); $userModel = new UserModel(); $commentModel = new CommentModel(); $articleTagModel = new ArticleTagModel(); $articletypeModel = new ArticleTypeModel(); //$adminModel = new AdminModel(); //博主个人信息 $blogerInfo = $this->getBlogerInfo($blogerId); //获取所有文章分类 //$allTypes = $this->getAllTypes($blogerId); //var_dump($allTypes);exit(); $allTypes = $articletypeModel->getCatrgoryByadminId($blogerId); //获取所有文章标签 $allTags = $articleTagModel->getArticleTag(); //最新三条评论 $latestComments = $commentModel->getLatestComments($blogerId, '0,3'); //用户个人信息 $allUserInfo = $userModel->getAllUserInfo(); //根据adminId获取相册 $albums = $albumModel->getAlbumByAdminId($blogerId); //根据adminId获取相册数量 $count = $albumModel->getAlbumCountByAdminId($blogerId); if ($count > $pagesize) { $page = new Page($count, $p, $pagesize); $str = $page->show('themeuk.php'); } $albumsArr = array(); foreach ($albums as $key => $value) { //根据albumId获取照片的数量 $value['photocount'] = $photoModel->getPhotosCountByAlbumId($value['albumId']); //根据adminId获取相册数量 $value['albumcount'] = $albumModel->getAlbumCountByAdminId($blogerId); //$description = $value['description']; //$value['photocount'] = $photos; //根据albumid获取相册信息 $value['albumInfo'] = $albumModel->getAlbumById($value['albumId']); //var_dump($albumInfo);exit; $albumsArr[$value['photoId']] = $value; } $this->assign('page', $str); $this->assign('albums', $albums); $this->assign("allTags", $allTags); //所有文章标签 $this->assign('albumName', $albumName); //相册名 //$this->assign('description',$description);//相册描述 //$this->assign('albumInfo',''); $this->assign('allTypes', $allTypes); $this->assign("photoId", $value); $this->assign('count', $count); //相册数量 $this->assign('blogerInfo', $blogerInfo); //博主个人信息 $this->assign('latestComments', $latestComments); //最新三条评论 $this->assign('allUserInfo', $allUserInfo); //某用户信息 $this->assign("pageTitle", "个人主页"); $this->display(); }
/** * Convert a localized representation of a number to a number (for instance, converts the string '1,234' to 1234 in case of English and to 1.234 in case of Italian). * * @param string $value The string value to convert * @param string $locale The locale to use. If empty we'll use the default locale set in \Punic\Data * * @return int|float|null Returns null if $value is not valid, the numeric value otherwise */ public static function unformat($value, $locale = '') { $result = null; if (is_int($value) || is_float($value)) { $result = $value; } elseif (is_string($value) && isset($value[0])) { $data = Data::get('numbers', $locale); $plus = $data['symbols']['plusSign']; $plusQ = preg_quote($plus); $minus = $data['symbols']['minusSign']; $minusQ = preg_quote($minus); $decimal = $data['symbols']['decimal']; $decimalQ = preg_quote($decimal); $group = $data['symbols']['group']; $groupQ = preg_quote($group); $ok = true; if (preg_match('/^' . "({$plusQ}|{$minusQ})?(\\d+(?:{$groupQ}\\d+)*)" . '$/', $value, $m)) { $sign = $m[1]; $int = $m[2]; $float = null; } elseif (preg_match('/^' . "({$plusQ}|{$minusQ})?(\\d+(?:{$groupQ}\\d+)*){$decimalQ}" . '$/', $value, $m)) { $sign = $m[1]; $int = $m[2]; $float = ''; } elseif (preg_match('/^' . "({$plusQ}|{$minusQ})?(\\d+(?:{$groupQ}\\d+)*){$decimalQ}(\\d+)" . '$/', $value, $m)) { $sign = $m[1]; $int = $m[2]; $float = $m[3]; } elseif (preg_match('/^' . "({$plusQ}|{$minusQ})?{$decimalQ}(\\d+)" . '$/', $value, $m)) { $sign = $m[1]; $int = '0'; $float = $m[2]; } else { $ok = false; $float = $int = $sign = null; } if ($ok) { if ($sign === $minus) { $sign = '-'; } else { $sign = ''; } $int = str_replace($group, '', $int); if ($float === null) { $result = intval("{$sign}{$int}"); } else { $result = floatval("{$sign}{$int}.{$float}"); } } } return $result; }
protected static function getLocaleData($currencyCode, $locale) { $result = null; if (is_string($currencyCode) && strlen($currencyCode) === 3) { $data = Data::get('currencies', $locale); if (isset($data[$currencyCode])) { $result = $data[$currencyCode]; } } return $result; }
<?php require_once __DIR__ . '/../../bootstrap.php'; $fbid = $gRRH->getParam('fbid'); $proxAuth = $gRRH->getParam('prox_auth_token'); $aa_cities = Data::get('cities'); $cities = array_keys($aa_cities); $occupations = Data::get('occupations'); $religions = Data::get('religions'); $cdnUrl = App::CDN_URL . '/uploads/photos/'; ?> <!DOCTYPE html> <html lang="en" ng-app="TheGrade.Leaderboard"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <link rel="stylesheet" href="https://www.thegradedating.com/app/mobile/css/leaderboard-v2.css?v=14"> <title>The Grade - Leaderboard</title> </head> <body ontouchstart=""> <div class="page-wrap" ng-view></div> </body> <script type="text/ng-template" id="leaderboard-view"> <title-bar></title-bar> <div class="scroll-wrap"> <ul class="leaderboard" ng-class="{'is-loading': isLoading}"> <leaderboard-item ng-repeat="user in users" user="******"></leaderboard-item> </ul> <div class="no-results" ng-show="noResults()"> <h1 class="no-results-header">No Results!</h1> <p class="no-results-copy">Try Changing your filter settings, or select a different leaderboard</p>
/** * Retrieve the measurement systems and their localized names. * * @param string $locale The locale to use. If empty we'll use the default locale set in \Punic\Data * * @return array The array keys are the measurement system codes (eg 'metric', 'US', 'UK'), the values are the localized measurement system names (eg 'Metric', 'US', 'UK' for English) */ public static function getMeasurementSystems($locale = '') { return Data::get('measurementSystemNames', $locale); }
/** * Get the value associated with a given configuration key. * @param string $key * @param mixed $default * @return mixed */ public static function get($key, $default = null) { return self::getData()->isKeySet($key) ? static::$data->get($key) : $default; }
public function addAlbumComment() { if (!$_SESSION['qq']) { $result['code'] = "021"; $result['message'] = "未登录,请登录账号!"; } else { $_POST['content'] = Data::filter($_POST['content'], 9); $_POST['albumId'] = Data::get($_POST['albumId'], Data::Int); $_POST['adminId'] = Data::get($_POST['adminId'], Data::Int); $_POST['userId'] = Data::get($_POST['userId'], Data::Int); $comment = new CommentModel(); $row = $comment->addComment($_POST); if ($row) { $comments = $comment->getCommentById($row); $result['info'] = $comments; $result['code'] = "0"; $result['message'] = "恭喜,评论成功!"; } else { $result['code'] = "022"; $result['message'] = "评论失败"; } } echo json_encode($result); exit; }
/** * Generate the pagination markup relative to the feed being requested. * * * @return string */ private function printPagination() { $total = $this->totalCount(); $html = ''; $numPages = round($total / $this->settings['posts_per_page'], 0); if ($total % $this->settings['posts_per_page'] != 0) { $numPages++; } //if if ($numPages == 0) { return ''; } $iter = 1; while ($iter <= $numPages) { $slug = $_SERVER['REQUEST_URI']; $slug = explode('/', $slug); $tail = $this->settings['pagination_slug'] . '/' . $iter; if (\Data::get('current-page') === false) { //$slug[count($slug)-1] = rtrim('/',$slug[count($slug)-1]); if ($slug[count($slug) - 1] == "") { $slug[count($slug) - 1] = $tail; } else { $slug[] = $tail; } // } else { $slug[count($slug) - 1] = $iter; } //el $slug = implode('/', $slug); $classes = ''; if (\Data::get('current-page') !== false && $iter == \Data::get('current-page')) { $classes = 'current'; } else { if (\Data::get('current-page') === false && $iter == 1) { $classes = 'current'; } } //elif $html .= \Template::build('wordpress/pagination-list', array('classes' => $classes, 'page' => $iter, 'slug' => $slug)); $iter++; } //while $slug = $_SERVER['REQUEST_URI']; $slug = explode('/', $slug); $nFslug = $this->settings['pagination_slug'] . '/1'; if (\Data::get('current-page') === false) { $slug[] = $nFslug; } else { $slug[count($slug) - 1] = '1'; } //el $fslug = implode('/', $slug); $slug[count($slug) - 1] = $this->settings['pagination_slug'] . '/' . $numPages; $lslug = implode('/', $slug); $data = array('pages' => $html, 'first_arrow_classes' => '', 'first_arrow_slug' => $fslug, 'last_arrow_classes' => '', 'last_arrow_slug' => $lslug); if (\Data::get('current-page') === false) { $data['first_arrow_classes'] = 'unavailable'; $data['first_arrow_slug'] = ''; } else { if ($numPages == \Data::get('current-page')) { $data['last_arrow_classes'] = 'unavailable'; $data['last_arrow_slug'] = ''; } } //elif if ($numPages == 1) { $data['last_arrow_classes'] = 'unavailable'; $data['last_arrow_slug'] = ''; } //el return \Template::build('wordpress/pagination-container', $data); }
/** * Retrieve the line order (top-to-bottom or bottom-to-top). * * @param string $locale The locale to use. If empty we'll use the default locale set in \Punic\Data * * @return string Return 'top-to-bottom' or 'bottom-to-top' */ public static function getLineOrder($locale = '') { $data = Data::get('layout', $locale); return $data['lineOrder']; }
public static function fetch() { Data::get()->add('TITLE', 'Accueil'); }
$showSearch = true; if (isset($_POST['userSelect']) && is_numeric($_POST['userSelect'])) { $userEdit = new eCRFUser($_POST['userSelect']); if ($userEdit->get('email') && $userEdit->getPrivilege() >= $user->getPrivilege()) { $showSearch = false; echo "<h4>Edit the user's details below</h4>"; $form = new HTMLForm('process.php', 'post'); $fields = $trial->getFormFields($page); $form->processFields($fields, $userEdit); if (isset($_SESSION['inputErr'])) { // If any errors then add them to the form $form->addErrors($_SESSION['inputErr']); unset($_SESSION['inputErr']); } $centre = new Data($userEdit->getCentre(), 'Centre'); $form->addInputValue('usereg-country', $centre->get('country_id')); $form->addInput('hidden', 'userID', $userEdit->getID()); $form->addInput('hidden', 'page', $page); $form->addInput('hidden', 'deleteUser', 'false'); $form->addButton('Delete', array('btn-danger', 'hidden')); $form->addCancelButton('index.php?page=usereg'); $_SESSION['csrfToken'] = $token = base64_encode(openssl_random_pseudo_bytes(32)); $form->addInput('hidden', 'csrfToken', $token); echo $form->writeHTML(); } } if ($showSearch) { $sql = "SELECT *, user.id as userID, centre.name as centreName, country.name as countryName, privilege.name as privilegeName, privilege_id FROM user\n LEFT JOIN centre ON centre_id = centre.id\n LEFT JOIN country ON country_id = country.id\n LEFT JOIN privilege ON privilege_id = privilege.id"; if ($user->isLocal()) { $sql .= " WHERE centre.id = ?"; $pA = array('i', $user->getCentre());
public function updateArticleTypes() { $blogerId = Data::get($_GET['blogerId'], Data::Int); $articleType = $this->getAllTypes($blogerId); $this->assign('articleTypes', $articleType); $this->display(); }
protected static function decodeTimezoneDelta(\DateTime $value, $count, $locale) { $offset = $value->getOffset(); $sign = $offset < 0 ? '-' : '+'; $seconds = abs($offset); $hours = intval(floor($seconds / 3600)); $seconds -= $hours * 3600; $minutes = intval(floor($seconds / 60)); $seconds -= $minutes * 60; $partsWithoutSeconds = array(); $partsWithoutSeconds[] = $sign . substr('0' . strval($hours), -2); $partsWithoutSeconds[] = substr('0' . strval($minutes), -2); $partsMaybeWithSeconds = $partsWithoutSeconds; /* @TZWS if ($seconds > 0) { $partsMaybeWithSeconds[] = substr('0' . strval($seconds), -2); } */ switch ($count) { case 1: case 2: case 3: return implode('', $partsMaybeWithSeconds); case 4: $data = Data::get('timeZoneNames', $locale); $format = isset($data['gmtFormat']) ? $data['gmtFormat'] : 'GMT%1$s'; return sprintf($format, implode(':', $partsWithoutSeconds)); case 5: return implode(':', $partsMaybeWithSeconds); default: throw new Exception\ValueNotInList($count, array(1, 2, 3, 4, 5)); } }
/** * Get a GET variable in the request. * * @param string $k The key. * * @return string */ public function get($k = null) { return \Data::get($k); }
<?php session_start(); require_once "init.php"; if (isset($_GET['_ajc'])) { $parts = explode('::', $_GET['_ajc']); if (!empty($parts[0]) && !empty($parts[1])) { $method = 'ajax' . ucfirst($parts[1]); $renderer = Page::i($parts[0]); echo json_encode($renderer->{$method}()); } } else { $page = Data::get('_page', "main", Data::STR); Page::i($page)->display(); }
public function showData() { echo Data::get("employee_name"); echo "<br>"; echo Data::get("employee_id"); }
die; } } } else { $oInfos = new Infos(Data::get("home")); $title = $oInfos->title; $app->redirect('/admin/_connect.html'); die; } }); $app->get('/admin/_connect.html', function () { global $app, $smarty; if (get('error', 0) > 0) { $sPage = Data::get('home'); } else { $sPage = strpos(server('HTTP_REFERER'), server('HTTP_HOST')) !== false ? str_replace('http://' . server('HTTP_HOST') . '/', '', server('HTTP_REFERER')) : Data::get('home'); } $oParser = DomParser::getInstance(); $oParser->init(ROOT . $sPage, new Infos($sPage)); $oParser->displayConnectBox($sPage, get('error', 0)); die; }); $app->get('/admin/:page.html', 'admin_middleware', function ($sPage) { global $app, $smarty; $oParser = DomParser::getInstance(); $oParser->init(ROOT . $sPage . '.html', new Infos($sPage . '.html')); $oParser->display($sPage); die; }); $app->post('/admin/save/:ref/', 'admin_middleware', function ($sRef) use($app) { $oBrick = Brick::get($sRef);
public static function delete() { $token = Token::getBy('token', $_SERVER['HTTP_X_TOKEN']); $token->delete(); Data::get()->add('message', 'Good bye !'); }