/** * Returns the known country/region codes as an array. * * @return CArrayObject The known country/region codes of type `CUStringObject`. */ public static function knownCountryCodes() { return oop_a(CMap::keys(DULocale::$CountryCodeToInfo)); }
/** * Returns all the values assigned to a specified long option with which the script was run, * e.g. "--option=value1 --option=value2". * * @param string $optionName The name of the option, excluding "-". * * @return CArrayObject The values of the option specified, where each value is of type `CUStringObject`. */ public static function valuesForLongOption($optionName) { assert('is_cstring($optionName)', vs(isset($this), get_defined_vars())); assert('self::hasLongOptionWithValue($optionName)', vs(isset($this), get_defined_vars())); $opt = getopt("", ["{$optionName}:"]); $values = $opt[$optionName]; return oop_a(is_cmap($values) ? CArray::fromPArray($values) : CArray::fromElements($values)); }
/** * Sends a message to the recipient(s). * * @param reference $failedAddresses **OPTIONAL. OUTPUT.** After the method is called with this parameter * provided, the parameter's value, which is of type `CArrayObject`, is an array containing the email addresses of * the recipients who failed to receive the message. * * @return int The number of recipients who have successfully received the message. */ public function send(&$failedAddresses = null) { assert('isset($this->m_swiftMailer) && isset($this->m_swiftMessage)', vs(isset($this), get_defined_vars())); assert('(isset($this->m_from) || isset($this->m_sender) || isset($this->m_returnAddress)) && ' . '(isset($this->m_to) || isset($this->m_cc) || isset($this->m_bcc))', vs(isset($this), get_defined_vars())); $message = $this->m_swiftMessage; if (isset($this->m_from)) { $message->setFrom($this->m_from); } if (isset($this->m_to)) { $message->setTo($this->m_to); } if (isset($this->m_cc)) { $message->setCc($this->m_cc); } if (isset($this->m_bcc)) { $message->setBcc($this->m_bcc); } if (isset($this->m_sender)) { $message->setSender($this->m_sender); } if (isset($this->m_returnAddress)) { $message->setReturnPath($this->m_returnAddress); } if (isset($this->m_replyAddress)) { $message->setReplyTo($this->m_replyAddress); } if (isset($this->m_body)) { if (CString::equals($this->m_bodyType, CMimeType::PLAIN_TEXT)) { $this->m_body = $this->maybeWrapText($this->m_body); } $message->setBody($this->m_body, $this->m_bodyType); } if (isset($this->m_altBodiesAndTypes)) { $len = CArray::length($this->m_altBodiesAndTypes); for ($i = 0; $i < $len; $i++) { $bodyAndType = $this->m_altBodiesAndTypes[$i]; $body = $bodyAndType[0]; $type = $bodyAndType[1]; if (CString::equals($type, CMimeType::PLAIN_TEXT)) { $body = $this->maybeWrapText($body); } $message->addPart($body, $type); } } $paFailedAddresses; $res = $this->m_swiftMailer->send($message, $paFailedAddresses); if (is_cmap($paFailedAddresses)) { $failedAddresses = oop_a(CArray::fromPArray($paFailedAddresses)); } $res = is_int($res) ? $res : 0; return $res; }
/** * Returns the names of the time zones that are known for a specified country. * * If the country's code is not recognized for any reason, the entire list of the known time zone names is * returned. * * @param string $countryCode The two-letter code of the country, as provided by ISO 3166. * * @return CArrayObject The known time zone names for the country specified, of type `CUStringObject`. */ public static function knownNamesForCountry($countryCode) { assert('is_cstring($countryCode)', vs(isset($this), get_defined_vars())); $paNames = DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, $countryCode); $paNames = CMap::filter($paNames, "CTimeZone::isNameIcuCompatible"); $names = CArray::fromPArray($paNames); if (is_cmap($paNames) && !CArray::isEmpty($names)) { return oop_a($names); } else { return oop_a(self::knownNames()); } }
/** * @ignore */ function _to_oop_tp($value) { // Only used with OOP wrapping for third-party components. if (is_array($value)) { foreach ($value as &$mapValue) { $mapValue = _to_oop_tp($mapValue); } unset($mapValue); if (!CMap::areKeysSequential($value)) { $value = oop_m($value); } else { $value = oop_a(CArray::fromPArray($value)); } return $value; } if ($value instanceof SplFixedArray) { $len = CArray::length($value); for ($i = 0; $i < $len; $i++) { $value[$i] = _to_oop_tp($value[$i]); } return oop_a($value); } return $value; }
/** * Returns the paths to the subdirectories found in a directory by a regular expression pattern, searching only in * the name of every contained subdirectory with the pattern, also looking into the subdirectories of the directory * and so on. * * The returned paths are always absolute. * * @param string $inDirectoryPath The path to the directory to be looked into (not required to end with "/"). * @param string $regexPattern The regular expression pattern to be used for searching. * @param bool $sort **OPTIONAL. Default is** `false`. Tells whether the returned paths should be sorted, in the * ascending order. * * @return CArrayObject The paths to the subdirectories found by the regular expression pattern specified, * including ones found in the subdirectories of the specified directory and so on. */ public static function reFindDirectoriesOnNameRecursive($inDirectoryPath, $regexPattern, $sort = false) { assert('is_cstring($inDirectoryPath) && is_cstring($regexPattern) && is_bool($sort)', vs(isset($this), get_defined_vars())); $inDirectoryPath = CFilePath::frameworkPath($inDirectoryPath); return oop_a(CArray::filter(self::listDirectoriesRecursive($inDirectoryPath, $sort), function ($path) use($regexPattern) { return CRegex::find(CFilePath::name($path), $regexPattern); })); }
protected static function recurseQueryValueAfterParsing($value, $currDepth) { if ($currDepth == self::$ms_maxRecursionDepth) { return $value; } $currDepth++; if (!is_cmap($value)) { // Only interested in PHP's associative arrays. return $value; } if (CMap::areKeysSequential($value)) { $value = CArray::fromPArray($value); $len = CArray::length($value); for ($i = 0; $i < $len; $i++) { $value[$i] = self::recurseQueryValueAfterParsing($value[$i], $currDepth); } return oop_a($value); } else { foreach ($value as &$mapValue) { $mapValue = self::recurseQueryValueAfterParsing($mapValue, $currDepth); } unset($mapValue); return oop_m($value); } }
protected static function recurseValueAfterDecoding($value, $currDepth) { if ($currDepth == self::$ms_maxRecursionDepth) { return $value; } $currDepth++; if (is_string($value)) { return $value; } if (is_object($value)) { $value = (array) $value; foreach ($value as &$valueInMap) { $valueInMap = self::recurseValueAfterDecoding($valueInMap, $currDepth); } unset($valueInMap); $value = oop_m($value); } else { if (is_array($value)) { $value = CArray::fromPArray($value); $len = CArray::length($value); for ($i = 0; $i < $len; $i++) { $value[$i] = self::recurseValueAfterDecoding($value[$i], $currDepth); } $value = oop_a($value); } } return $value; }