本文整理汇总了PHP中Data::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::get方法的具体用法?PHP Data::get怎么用?PHP Data::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Data
的用法示例。
在下文中一共展示了Data::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getName
/**
* 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;
}
示例2: sendJSON
public function sendJSON()
{
$data = Data::get()->getData();
header('Content-Type: application/json; charset=utf-8');
//Dev
//var_dump($data);
//Prod
echo json_encode($data);
}
示例3: doDelete
public function doDelete()
{
$id = Data::get('id', '', Data::INT);
if ($id) {
if (Group::i($id)->delete()) {
return true;
}
}
return false;
}
示例4: doSignIn
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;
}
示例5: testGetVariable
/**
* @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'));
}
示例6: doAddAuditory
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;
}
示例7: ajaxSignIn
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;
}
示例8: doAddSubject
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;
}
示例9: doSignUp
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;
}
示例10: doUpdate
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++;
}
}
示例11: getName
/**
* 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;
}
示例12: getList
/**
* 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;
}
示例13: albumlist
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();
}
示例14: unformat
/**
* 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;
}
示例15: getLocaleData
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;
}