/** * Get an item from an array or object using "dot" notation. * * @param mixed $target * @param string|array $key * @param mixed $default * @return mixed */ function data_get($target, $key, $default = null) { if (is_null($key)) { return $target; } $key = is_array($key) ? $key : explode('.', $key); while (($segment = array_shift($key)) !== null) { if ($segment === '*') { if ($target instanceof Collection) { $target = $target->all(); } elseif (!is_array($target)) { return value($default); } $result = Arr::pluck($target, $key); return in_array('*', $key) ? Arr::collapse($result) : $result; } if (Arr::accessible($target) && Arr::exists($target, $segment)) { $target = $target[$segment]; } elseif (is_object($target) && isset($target->{$segment})) { $target = $target->{$segment}; } else { return value($default); } } return $target; }
/** * Get an item from an array or object using "dot" notation. * * @param mixed $target * @param string|array $key * @param mixed $default * @return mixed */ function data_get($target, $key, $default = null) { if (is_null($key)) { return $target; } $key = is_array($key) ? $key : explode('.', $key); foreach ($key as $segment) { if (is_array($target)) { if (!array_key_exists($segment, $target)) { return value($default); } $target = $target[$segment]; } elseif ($target instanceof ArrayAccess) { if (!isset($target[$segment])) { return value($default); } $target = $target[$segment]; } elseif (is_object($target)) { $method = 'get' . ucfirst($segment); if (isset($target->{$segment})) { $target = $target->{$segment}; } elseif (is_callable([$target, $method])) { $target = $target->{$method}(); } else { return value($default); } } else { return value($default); } } return $target; }
public function get($key, $default = NULL) { if ($this->offsetExists($key)) { return $this->items[$key]['response']; } return value($default); }
public function rule($rule, $condition = true) { if (value($condition) && !in_array($rule, $this->rules)) { $this->rules[] = $rule; } return $this; }
function env($key, $default = null) { if (isset($_ENV[$key])) { $value = $_ENV[$key]; } else { return value($default); } switch (strtolower($value)) { case 'true': case '(true)': return true; case 'false': case '(false)': return false; case 'empty': case '(empty)': return ''; case 'null': case '(null)': return; } if (preg_match('/^"[^"]+"$/', $value)) { return substr($value, 1, -1); } else { return $value; } }
/** * Gets the value of an environment variable. Supports boolean, empty and null. * * @param string $key * @param mixed $default * * @return mixed */ function env($key, $default = NULL) { $value = getenv($key); if ($value === FALSE) { return value($default); } switch (strtolower($value)) { case 'true': case '(true)': return TRUE; case 'false': case '(false)': return FALSE; case 'empty': case '(empty)': return ''; case 'null': case '(null)': return NULL; } if (strlen($value) > 1 && Lib::starts_with('"', $value) && Lib::ends_with('"', $value)) { return substr($value, 1, -1); } return $value; }
function env($key, $default = null) { $value = getenv($key); if ($value === false) { return value($default); } switch (strtolower($value)) { case 'true': case '(true)': return true; case 'false': case '(false)': return false; case 'empty': case '(empty)': return ''; case 'null': case '(null)': return; } if ($value[0] === '"' && $value[strlen($value) - 1] === '"') { return substr($value, 1, -1); } return $value; }
/** * Get the language line as a string. * * <code> * // Get a language line * $line = Lang::line('validation.required')->get(); * * // Get a language line in a specified language * $line = Lang::line('validation.required')->get('sp'); * * // Return a default value if the line doesn't exist * $line = Lang::line('validation.required')->get(null, 'Default'); * </code> * * @param string $language * @param string $default * @return string */ public function get($language = null, $default = null) { //ff($language); die(); // If no default value is specified by the developer, we'll just return the // key of the language line. This should indicate which language line we // were attempting to render and is better than giving nothing back. if (is_null($default)) { $default = $this->key; } if (is_null($language)) { $language = $this->language; } list($bundle, $file, $line) = $this->parse($this->key); $identifier_as_line = $line; // If the file does not exist, we'll just return the default value that was // given to the method. The default value is also returned even when the // file exists and that file does not actually contain any lines. if (!static::load($bundle, $language, $file)) { return value($identifier_as_line); //return value($default); } $lines = static::$lines[$bundle][$language][$file]; $line = array_get($lines, $line, $identifier_as_line); //$line = array_get($lines, $line, $default); // If the line is not a string, it probably means the developer asked for // the entire language file and the value of the requested value will be // an array containing all of the lines in the file. if (is_string($line)) { foreach ($this->replacements as $key => $value) { $line = str_replace(':' . $key, $value, $line); } } return $line; }
private function _isUnread() { if (Auth::guest()) { return false; } $markAsReadAfter = value(Config::get('forums::forums.mark_as_read_after')); if (!IoC::registered('topicsview')) { IoC::singleton('topicsview', function () use($markAsReadAfter) { return Forumview::where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter))->where('user_id', '=', Auth::user()->id)->lists('topic_id'); }); } $tv = IoC::resolve('topicsview'); $nb = count($tv); $view = Forumtopic::where('forumcategory_id', '=', $this->id)->where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter)); if ($nb > 0) { $view = $view->where_not_in('id', $tv); } $view = $view->count(); if ($nb == 0 && $view > 0) { return true; } if ($view > 0) { return true; } return false; }
/** * Get an attribute from the container. * * @param string $key * @param mixed $default * @return mixed */ public function get($key, $default = null) { if (array_key_exists($key, $this->attributes)) { return $this->attributes[$key]; } return value($default); }
/** * Renvoie un élément de la collection à partir de sa clé. * * @param mixed $mKey Clé. * @param mixed $mDefault Valeur à renvoyer si l'élément n'existe pas. * @return type */ public function get($mKey, $mDefault = null) { if (array_key_exists($mKey, $this->_aItems)) { return $this->_aItems[$mKey]; } return value($mDefault); }
/** * Redirect user based on type * * @static * @access public * @param string $type * @return void * @throws AuthException */ public static function redirect($type) { if (is_null($path = Config::get("oneauth::urls.{$type}"))) { throw new Exception(__METHOD__ . ": Unable to redirect using {$type} type."); } return Redirect::to(value($path)); }
/** * Get an item from the collection by key. * * @param mixed $key * @param mixed $default * * @return mixed|static */ public function get($key, $default = null) { if ($this->offsetExists($key)) { return is_array($this->items[$key]) ? new static($this->items[$key]) : $this->items[$key]; } return value($default); }
/** * Updates the changes towards the object with the given id. * @param integer Id of the item, to be deleted. */ function process_object_update($id) { global $lang, $errors, $db, $page_action, $page_state; $cond = $this->item_pkname . " = {$id}"; // configure DBO $page_action = "UPDATE"; $page_state = "processing"; $tip = new TextInput($lang->get("name"), $this->item_table, $this->item_name, $cond, "type:text,size:32,width:200", "UNIQUE&MANDATORY"); $this->add($tip); $this->add(new Hidden("editing", $id)); $this->check(); $this->drawPage = "editing"; if ($errors == "") { $name = value($this->item_table . "_" . $this->item_name); global $c_magic_quotes_gpc; if ($c_magic_quotes_gpc == 1) { $name = str_replace("\\", "", $name); } $pname = parseSQL($name); $sql = "UPDATE " . $this->item_table . " SET " . $this->item_name . " = '" . $pname . "' WHERE " . $this->item_pkname . " = {$id}"; $query = new query($db, $sql); $query->free(); } if ($errors == "") { $this->addToTopText($lang->get("savesuccess")); } else { $this->addToTopText($lang->get("procerror")); $this->setTopStyle("errorheader"); } }
/** * Action (JsonRpc) * * @param Request $request * @param Response $response * @return mixed */ public function load(Request $request = null, Response $response = null) { $json = $request->getAttribute('json'); $params = value($json, 'params'); $result = ['status' => 1]; return $result; }
/** * standard constructor * @param string Text that is to be shown as description or label with your object. * @param string Table, you want to connect with the object. * @param string $longitude,column, which stores the longitude * @param string $latitude, columnd, which stores the latitude * @param string $row_identifier Usually to be generated with form->setPK. Identifies the * row in db, you want to affect with operation. Keep empty for insert. (Example: stdEDForm) */ function CoordinatesInput($label, $table, $longitude, $latitude, $row_identifier = "1") { global $page, $page_state, $forceLoadFromDB, $page_action; DBO::DBO($label, $table, $longitude, $row_identifier, ""); $this->lng = $longitude; $this->lat = $latitude; $this->vlng = 0; $this->vlat = 0; if ($page_state == "processing" && value("changevariation") != "GO" && !($forceLoadFromDB == "yes")) { $this->vlng = value("coordY", "NUMERIC", "0"); $this->vlat = value("coordX", "NUMERIC", "0"); } else { if (($page_action == "UPDATE" || $page_action == "DELETE") && $this->row_identifier != "1") { $this->vlng = getDBCell($table, $longitude, $row_identifier); $this->vlat = getDBCell($table, $latitude, $row_identifier); } } include_once "nxgooglemapsapi.php"; $this->api = new NXGoogleMapsAPI(); $this->api->setWidth(590); $this->api->setHeight(350); $this->api->addControl(GLargeMapControl); $this->api->addControl(GOverviewMapControl); $this->api->addControl(GMapTypeControl); $this->api->setCenter(50, 10); $this->api->setZoomFactor(4); if ($this->vlng != 0 || $this->vlat != 0) { $this->api->addDragMarker($this->vlng, $this->vlat); } $page->headerPayload = $this->api->getHeadCode(); $page->onLoad .= $this->api->getOnLoadCode(); }
/** * @param string $filter * @param mixed $default * * @return Filter */ public function get($filter, $default = null) { if ($this->offsetExists($filter)) { return $this->items[$filter]; } return value($default); }
/** * processes the form. Used internally only. */ function process() { global $goon, $lang, $c, $errors; if ($goon == $lang->get("commit")) { // process all the registered checks. for ($i = 0; $i < count($this->actions); $i++) { if (value($this->actions[$i][0]) != "0") { $this->actions[$i][1]->process($this->actions[$i][0]); if ($errors == "") { $this->addToTopText("<br><b>" . $this->actions[$i][2] . " ". $lang->get("var_succeeded"). "</b>"); } else { $this->addToTopText($lang->get("error")); $this->setTopStyle("headererror;"); } } } } else if ($goon == $lang->get("cancel")) { global $db; $db->close(); if ($this->backpage == "") { header ("Location: " . $c["docroot"] . "api/userinterface/page/blank_page.php"); } else { header ("Location: " . $c["docroot"] . $this->backpage); } exit; } }
/** * Gets a parameters * @param string $name The parameter name * @param mixed|\Closure $default Default value if parameter is not set * @return mixed */ public function param($name, $default = null) { if (isset($this->parameters[$name])) { return $this->parameters[$name]; } return value($default); }
/** * Get an item from the collection by key. * * @param mixed $key * @param mixed $default * @return mixed */ public function get($key, $default = null) { if ($this->offsetExists($key)) { return $this->offsetGet($key); } return value($default); }
/** * syncronize variations with entered data to the database. * The configuration for this function must be set manually. * I.E. there must be the $oid-Variable set and there must(!) * be also the global vars content_variations_VARIATION_ID_XX * and content_MODULE_ID * set which are automatically set by the SelectMultiple2Input. */ function syncVariations() { global $db, $oid, $content_MODULE_ID; $module = value("content_MODULE_ID", "NUMERIC"); if ($module == "0") { $module = $content_MODULE_ID; } includePGNSource($module); //delete all variations first. $del = "UPDATE content_variations SET DELETED=1 WHERE CID = {$oid}"; $query = new query($db, $del); // get list of variations $variations = createNameValueArray("variations", "NAME", "VARIATION_ID", "DELETED=0"); for ($i = 0; $i < count($variations); $i++) { $id = $variations[$i][1]; if (value("content_variations_VARIATION_ID_" . $id) != "0") { // create or restore variation // check, if variations already exists and is set to deleted. $sql = "SELECT COUNT(CID) AS ANZ FROM content_variations WHERE CID = {$oid} AND VARIATION_ID = {$id}"; $query = new query($db, $sql); $query->getrow(); $amount = $query->field("ANZ"); if ($amount > 0) { $sql = "UPDATE content_variations SET DELETED=0 WHERE CID = {$oid} AND VARIATION_ID = {$id}"; } else { $fk = nextGUID(); $sql = "INSERT INTO content_variations (CID, VARIATION_ID, FK_ID, DELETED) VALUES ( {$oid}, {$id}, {$fk}, 0)"; $PGNRef = createPGNRef($module, $fk); $PGNRef->sync(); } $query = new query($db, $sql); } } }
/** * Get a specific key from the settings data. * * @param string|array $key * @param mixed $default Optional default value. * * @return mixed */ public function get($key, $default = null) { if (is_null($key)) { return $this->all(); } $this->loadSettingsIfNotLoaded(); $value = array_get($this->settings, $key, $this->randomDefaultValue); if ($this->randomDefaultValue !== $value) { if ($value === false) { return value($default); } if (!is_string($value)) { return $value; } switch (strtolower($value)) { case 'true': case '(true)': return true; case 'false': case '(false)': return false; case 'empty': case '(empty)': return ''; case 'null': case '(null)': return null; } return $value; } return $default; }
public static function get($path, $default = null) { if (file_exists($path)) { return file_get_contents($path); } return value($default); }
function dataGet($target, $key, $default = null) { if (is_null($key)) { return $target; } foreach (explode('.', $key) as $segment) { if (is_array($target)) { if (!array_key_exists($segment, $target)) { return value($default); } $target = $target[$segment]; } elseif ($target instanceof \ArrayAccess) { if (!isset($target[$segment])) { return value($default); } $target = $target[$segment]; } elseif (is_object($target)) { if (!isset($target->{$segment})) { return value($default); } $target = $target->{$segment}; } else { return value($default); } } return $target; }
/** * Get an item from an object or array using "dot" notation. * * @param object|array $object_or_array * @param string $key * @param mixed $default * * @return mixed */ function get($object_or_array, $key, $default = null) { if (is_array($object_or_array)) { if (is_null($key)) { return $object_or_array; } if (isset($object_or_array[$key])) { return $object_or_array[$key]; } foreach (explode('.', $key) as $segment) { if (!is_array($object_or_array) || !array_key_exists($segment, $object_or_array)) { return value($default); } $object_or_array = $object_or_array[$segment]; } return $object_or_array; } else { if (is_null($key) || trim($key) == '') { return $object_or_array; } foreach (explode('.', $key) as $segment) { if (!is_object($object_or_array) || !isset($object_or_array->{$segment})) { return value($default); } $object_or_array = $object_or_array->{$segment}; } return $object_or_array; } }
/** * Gets the value of an environment variable. Supports boolean, empty and null. * * @param string $key * @param mixed $default * @return mixed */ function env($key, $default = null) { $value = getenv($key); if ($value === false) { return value($default); } switch (strtolower($value)) { case 'true': case '(true)': return true; case 'false': case '(false)': return false; case 'empty': case '(empty)': return ''; case 'null': case '(null)': return; } if (startsWith($value, '"') && endsWith($value, '"')) { return substr($value, 1, -1); } return $value; }
/** * standard constructor * @param string Text that is to be shown as description or label with your object. * @param string Table, you want to connect with the object. * @param string column, you want to connect with the object. * @param string $row_identifier Usually to be generated with form->setPK. Identifies the * row in db, you want to affect with operation. Keep empty for insert. (Example: stdEDForm) * @param string $params Allowed parameter is: * param:<Name of form> needed for js-reasons. * @param string $check Does checks on user input. Allowed are MANDATORY (=not null)|UNIQUE. Separate with &. * @param string $db_datatype Datatype of the database, you want to use. Allowed is DATE only. */ function DateTimeInput($label, $table, $column, $row_identifier = "1", $params = "param:form1", $check = "", $db_datatype = "DATE") { DBO::DBO($label, $table, $column, $row_identifier, $params, $db_datatype, $check); // load the data of the field. global $page_state, $page_action; if ($page_state == "processing") { $this->value = value($this->name, "NOSPACES", ""); if ($this->value != "") { $this->value.=" ".value($this->name."_time", "NOSPACES", "").":00"; $this->value = str_replace("/", "-", $this->value); /** added 21.1.2002 */ global $c_magic_quotes_gpc; if ($c_magic_quotes_gpc == 1) $this->value = str_replace("\\", "", $this->value); /** got rid of magic quotes! */ $this->oldvalue = getDBCell($table, $column, $row_identifier); } } else { if (($page_action == "UPDATE" || $page_action == "DELETE") && $this->row_identifier != "1") { $this->value = getDBCell($table, $column, $row_identifier); if ($this->value == "0000-00-00 00:00:00" || $this->value == "00:00:00" || $this->value=="") $this->value = ""; } } $this->v_wuiobject = new DateTimebox($this->name, $this->value, $this->std_style, $this->parameter); }
/** * Basic handler of application exception. * * @param \Exception $e * * @return mixed */ public function handle(Exception $e) { list($exceptionClassName, $handlerClassName) = $this->getExceptionHandlerInfo($e); if (class_exists($handlerClassName)) { return call_user_func_array([value(new $handlerClassName()), 'handle'], [$e]); } throw $e; }
/** * Get an item from the cache, or cache and return the default value. * * <code> * // Get an item from the cache, or cache a value for 15 minutes * $name = Cache::remember('name', 'Taylor', 15); * * // Use a closure for deferred execution * $count = Cache::remember('count', function() { return User::count(); }, 15); * </code> * * @param string $key * @param mixed $default * @param int $minutes * @return mixed */ public function remember($key, $default, $minutes, $function = 'put') { if (!is_null($item = $this->get($key, null))) { return $item; } $this->{$function}($key, $default = value($default), $minutes); return $default; }
/** * Process the formfields, if set. Takes fields pgnratingcomment<id>, pgnratingvote<id>, * pgnratingsend<id> */ function processForm($sourceId) { if (value("pgnratingsend" . $sourceId) == "1") { return saveData(value("pgnrating" . $sourceId, "NUMERIC"), value("pgnratingcomment" . $sourceId, "", ""), $sourceId); } return false; }