/** * Можно ли закодировать данные с помощью json_encode * @param string $field имя поля * @return boolean */ public function isEncodableField($field) { /** * Если поле было распаковано ранее и еще не упаковано */ return is_scalar($field) && $this->_decodedFields->get($field) === false; }
protected function getUser($value, $default = 0) { $currentAdmin = APIHelpers::getkey($_SESSION, 'mgrInternalKey', 0); $value = (int) $value; if (!empty($value)) { $by = $this->findUserBy($value); $exists = $this->managerUsers->exists(function ($key, $val) use($by, $value) { return $val->containsKey($by) && $val->get($by) === (string) $value; }); if (!$exists) { $value = 0; } } if (empty($value)) { $value = empty($currentAdmin) ? $default : $currentAdmin; } return $value; }
$lReflect = $lReflect->reverse(); //Расчитываем сколько дат из какого списка взять $showBefore = $lReflect->count() < $limitBefore || empty($limitBefore) ? $lReflect->count() : $limitBefore; if ($rReflect->count() < $limitAfter || empty($limitAfter)) { $showAfter = $rReflect->count(); $showBefore += !empty($limitAfter) ? $limitAfter - $rReflect->count() : 0; } else { if ($limitBefore > 0) { $showAfter = $limitAfter + ($limitBefore - $showBefore); } else { $showAfter = $limitAfter; } } $showBefore += $showAfter >= $limitAfter || $limitAfter > 0 ? 0 : $limitAfter - $showAfter; //Создаем новую коллекцию дат $outReflects = new DLCollection($modx); //Берем нужное число элементов с левой стороны $i = 0; foreach ($lReflect as $item) { if (++$i > $showBefore) { break; } $outReflects->add($item['id']); } //Добавляем текущую дату if (is_null($activeReflect)) { if ($hasCurrentReflect && !$selectCurrentReflect || $appendCurrentReflect) { $outReflects->add($originalCurrentReflect); } } else { $outReflects->add($activeReflect);