private function getURL(MerchantLocationRequestOptions $options) { $url = ""; if ($this->environment == Environment::PRODUCTION) { $url = $this->PRODUCTION_URL; } else { $url = $this->SANDBOX_URL; } $url = URLUtil::addQueryParameter($url, "Details", $options->getDetails()); $url = URLUtil::addQueryParameter($url, "PageOffset", $options->getPageOffset()); $url = URLUtil::addQueryParameter($url, "PageLength", $options->getPageLength()); $url = URLUtil::addQueryParameter($url, "Category", $options->getCategory()); $url = URLUtil::addQueryParameter($url, "AddressLine1", $options->getAddressLine1()); $url = URLUtil::addQueryParameter($url, "AddressLine2", $options->getAddressLine2()); $url = URLUtil::addQueryParameter($url, "City", $options->getCity()); $url = URLUtil::addQueryParameter($url, "CountrySubdivision", $options->getCountrySubdivision()); $url = URLUtil::addQueryParameter($url, "PostalCode", $options->getPostalCode()); $url = URLUtil::addQueryParameter($url, "Country", $options->getCountry()); $url = URLUtil::addQueryParameter($url, "Latitude", $options->getLatitude()); $url = URLUtil::addQueryParameter($url, "Longitude", $options->getLongitude()); $url = URLUtil::addQueryParameter($url, "DistanceUnit", $options->getDistanceUnit()); $url = URLUtil::addQueryParameter($url, "Radius", $options->getRadius()); $url = URLUtil::addQueryParameter($url, "OfferMerchantId", $options->getMerchantId()); $url = URLUtil::addQueryParameter($url, "InternationalMaestroAccepted", $options->getInternationalMaestroAccepted()); return $url; }
function testSplitPath() { $strings = array('/foo/bar' => array('/foo', 'bar'), '/foo/bar/' => array('/foo', 'bar'), 'foo/bar/' => array('foo', 'bar'), 'foo/bar' => array('foo', 'bar'), 'foo/bar/baz' => array('foo/bar', 'baz'), 'foo/bar/baz/' => array('foo/bar', 'baz'), 'foo' => array('', 'foo'), 'foo/' => array('', 'foo'), '/foo/' => array('', 'foo'), '/foo' => array('', 'foo'), '' => array(null, null), "/àfoó/bar" => array("/àfoó", 'bar'), "/àfoo/bür/" => array("/àfoo", "bür"), "foo/àür" => array("foo", "àür")); foreach ($strings as $input => $expected) { $output = URLUtil::splitPath($input); $this->assertEquals($expected, $output, 'The expected output for \'' . $input . '\' was incorrect'); } }
private function getURL(CountryMerchantLocationRequestOptions $options) { $url = ""; if ($this->environment == Environment::PRODUCTION) { $url = $this->PRODUCTION_URL; } else { $url = $this->SANDBOX_URL; } $url = URLUtil::addQueryParameter($url, "Details", $options->getDetails()); return $url; }
private function getURL(CountrySubdivisionAtmLocationRequestOptions $options) { $url = ""; if ($this->environment == Environment::PRODUCTION) { $url = $this->PRODUCTION_URL; } else { $url = $this->SANDBOX_URL; } $url = URLUtil::addQueryParameter($url, "Country", $options->getCountry()); return $url; }
private function getURL(MerchantIdentifierRequestOptions $options) { $url = ""; if ($this->environment == Environment::PRODUCTION) { $url = $this->PRODUCTION_URL; } else { $url = $this->SANDBOX_URL; } $url = URLUtil::addQueryParameter($url, "MerchantId", $options->getMerchantId()); $url = URLUtil::addQueryParameter($url, "Type", $options->getType()); return $url; }
private function getURL($offset, $pageLength) { $url = null; if ($this->environment == Environment::PRODUCTION) { $url = TerminationInquiryService::PRODUCTION_URL; } else { $url = TerminationInquiryService::SANDBOX_URL; } $url = URLUtil::addQueryParameter($url, "PageOffset", $offset); $url = URLUtil::addQueryParameter($url, "PageLength", $pageLength); return $url; }
private function getURL($offset, $pageLength, $acquireId, $inquiryReferenceNumber) { $url = null; if ($this->environment == Environment::PRODUCTION) { $url = TerminationInquiryHistoryService::PRODUCTION_URL; } else { $url = TerminationInquiryHistoryService::SANDBOX_URL; } $url = sprintf($url, $inquiryReferenceNumber); $url = URLUtil::addQueryParameter($url, "PageOffset", $offset); $url = URLUtil::addQueryParameter($url, "PageLength", $pageLength); $url = URLUtil::addQueryParameter($url, "AcquirerId", $acquireId); return $url; }
/** * This function allows you to check if a node exists. * * @param string $path * @return bool */ public function nodeExists($path) { try { // The root always exists if ($path === '') { return true; } list($parent, $base) = URLUtil::splitPath($path); $parentNode = $this->getNodeForPath($parent); if (!$parentNode instanceof ICollection) { return false; } return $parentNode->childExists($base); } catch (Exception\NotFound $e) { return false; } }
private function getURL(RestaurantsLocalFavoritesRequestOptions $options) { $url = ""; if ($this->environment == Environment::PRODUCTION) { $url = $this->PRODUCTION_URL; } else { $url = $this->SANDBOX_URL; } $url = URLUtil::addQueryParameter($url, "PageLength", $options->getPageLength()); $url = URLUtil::addQueryParameter($url, "PageOffset", $options->getPageOffset()); $url = URLUtil::addQueryParameter($url, "AddressLine1", $options->getAddressLine1()); $url = URLUtil::addQueryParameter($url, "AddressLine2", $options->getAddressLine2()); $url = URLUtil::addQueryParameter($url, "City", $options->getCity()); $url = URLUtil::addQueryParameter($url, "CountrySubdivision", $options->getCountrySubdivision()); $url = URLUtil::addQueryParameter($url, "PostalCode", $options->getPostalCode()); $url = URLUtil::addQueryParameter($url, "Country", $options->getCountry()); $url = URLUtil::addQueryParameter($url, "Latitude", $options->getLatitude()); $url = URLUtil::addQueryParameter($url, "Longitude", $options->getLongitude()); $url = URLUtil::addQueryParameter($url, "DistanceUnit", $options->getDistanceUnit()); $url = URLUtil::addQueryParameter($url, "Radius", $options->getRadius()); return $url; }
/** * Displays the page for generating HTML code for pocket entry */ public function code_generation_page() { ?> <div class="wrap"> <h2 class="pkt-nws-gnrtr"><?php _e('Retrieve Items in Pocket and Generate HTML Code', self::DOMAIN); ?> </h2> <p><?php _e('Specify search condition for Pocket data retrieval and push the button below.', self::DOMAIN); ?> </p> <div class="pkt-nws-gnrtr"> <form action="" method="post"> <div> <label><?php _e('State', self::DOMAIN); ?> </label><br /> <select name="<?php echo PocketUtil::OPT_STATE; ?> " class="dropdown"> <option value="all" selected><?php _e('all (both unread and archived items)', self::DOMAIN); ?> </option> <option value="unread"><?php _e('only unread items', self::DOMAIN); ?> </option> <option value="archive"><?php _e('only archived items', self::DOMAIN); ?> </option> </select> </div> <div> <label><?php _e('Favorite', self::DOMAIN); ?> </label><br /> <select name="<?php echo PocketUtil::OPT_FAVORITE; ?> " class="dropdown"> <option value ="" selected><?php _e('all (both un-favorited and favorited items)', self::DOMAIN); ?> </option> <option value="0"><?php _e('only un-favorited items', self::DOMAIN); ?> </option> <option value="1"><?php _e('only favorited items', self::DOMAIN); ?> </option> </select> </div> <div> <label><?php _e('Tag', self::DOMAIN); ?> </label><br /> <input type="text" class="text" name="<?php echo PocketUtil::OPT_TAG; ?> " size="60" value="" /> </div> <div> <label><?php _e('Content Type', self::DOMAIN); ?> </label><br /> <select name="<?php echo PocketUtil::OPT_CONTENT_TYPE; ?> " class="dropdown"> <option value ="" selected><?php _e('all', self::DOMAIN); ?> </option> <option value="article"><?php _e('only articles', self::DOMAIN); ?> </option> <option value="video"><?php _e('only videos or articles with embedded videos', self::DOMAIN); ?> </option> <option value="image"><?php _e('only images', self::DOMAIN); ?> </option> </select> </div> <div> <label><?php _e('Sort', self::DOMAIN); ?> </label><br /> <select name="<?php echo PocketUtil::OPT_SORT; ?> " class="dropdown"> <option value ="newest" selected><?php _e('items in order of newest to oldest', self::DOMAIN); ?> </option> <option value="oldest"><?php _e('items in order of oldest to newest', self::DOMAIN); ?> </option> <option value="title"><?php _e('items in order of title alphabetically', self::DOMAIN); ?> </option> <option value="site"><?php _e('items in order of URL alphabetically', self::DOMAIN); ?> </option> </select> </div> <div> <label><?php _e('Search', self::DOMAIN); ?> </label><br /> <input type="text" class="text" name="<?php echo PocketUtil::OPT_SEARCH; ?> " size="60" value="" /> </div> <div> <label><?php _e('Domain', self::DOMAIN); ?> </label><br /> <input type="text" class="text" name="<?php echo PocketUtil::OPT_DOMAIN; ?> " size="60" value="" /> </div> <div> <label><?php _e('Since (YYYY-MM-DD HH24:MM)', self::DOMAIN); ?> </label><br /> <input type="text" class="text" name="<?php echo PocketUtil::OPT_SINCE; ?> " size="60" value="" /> </div> <div> <label><?php _e('Count', self::DOMAIN); ?> </label><br /> <input type="text" class="text" name="<?php echo PocketUtil::OPT_COUNT; ?> " size="60" value="" /> </div> <div> <label><?php _e('Offset', self::DOMAIN); ?> </label><br /> <input type="text" class="text" name="<?php echo PocketUtil::OPT_OFFSET; ?> " size="60" value="" /> </div> <input type="hidden" name="action" value="generate" /> <div> <input type="submit" class="button button-primary" value="<?php _e('Generate', self::DOMAIN); ?> " /> </div> </form> </div> </div> <br /> <?php if ($_POST["action"] === 'generate') { $consumer_key = get_option(self::DB_CONSUMER_KEY); $access_token = get_option(self::DB_ACCESS_TOKEN); $format = get_option(self::DB_FORMAT); $state = $_POST[PocketUtil::OPT_STATE]; $favorite = $_POST[PocketUtil::OPT_FAVORITE]; $tag = $_POST[PocketUtil::OPT_TAG]; $contentType = $_POST[PocketUtil::OPT_CONTENT_TYPE]; $sort = $_POST[PocketUtil::OPT_SORT]; $search = $_POST[PocketUtil::OPT_SEARCH]; $domain = $_POST[PocketUtil::OPT_DOMAIN]; $since = $_POST[PocketUtil::OPT_SINCE]; $count = $_POST[PocketUtil::OPT_COUNT]; $offset = $_POST[PocketUtil::OPT_OFFSET]; if (isset($state) && $state) { $option_params[PocketUtil::OPT_STATE] = $state; } if ($favorite == 0 || $favorite == 1) { $option_params[PocketUtil::OPT_FAVORITE] = $favorite; } if (isset($tag) && $tag) { $option_params[PocketUtil::OPT_TAG] = $tag; } if (isset($contentType) && $contentType) { $option_params[PocketUtil::OPT_CONTENT_TYPE] = $contentType; } if (isset($sort) && $sort) { $option_params[PocketUtil::OPT_SORT] = $sort; } if (isset($search) && $search) { $option_params[PocketUtil::OPT_SEARCH] = $search; } if (isset($domain) && $domain) { $option_params[PocketUtil::OPT_DOMAIN] = $domain; } if (isset($since) && $since) { $gmt_time = get_gmt_from_date($since); $option_params[PocketUtil::OPT_SINCE] = strtotime($gmt_time); } if (isset($count) && $count) { $option_params[PocketUtil::OPT_COUNT] = $count; } if (isset($offset) && $offset) { $option_params[PocketUtil::OPT_OFFSET] = $offset; } $option_params[PocketUtil::OPT_DETAIL_TYPE] = 'complete'; //$debug_mode = true; if (isset($debug_mode) && $debug_mode) { echo 'consumer_key: ' . $consumer_key . '<br />'; echo 'access_token: ' . $access_token . '<br />'; echo 'state: ' . $state . '<br />'; echo 'favorite: ' . $favorite . '<br />'; echo 'tag: ' . $tag . '<br />'; echo 'contentType: ' . $contentType . '<br />'; echo 'sort: ' . $sort . '<br />'; echo 'search: ' . $search . '<br />'; echo 'domain: ' . $domain . '<br />'; echo 'since: JST-> ' . $since . ' GMT-> ' . $gmt_time . '<br />'; echo 'count: ' . $count . '<br />'; echo 'offset: ' . $offset . '<br />'; echo 'Default timezone: ' . date_default_timezone_get() . '<br />'; echo 'Local timezone: ' . get_option('timezone_string') . '<br />'; echo 'Difference in time from default timezone: ' . get_option('gmt_offset') . '<br />'; echo 'Array of option parameters:<br />'; print_r($option_params); } $pocket_util = new PocketUtil(); $pocket_body = $pocket_util->retrieveItem($consumer_key, $access_token, $option_params); $feedly_util = new FeedlyUtil(); if (!empty($pocket_body)) { //Check if there is mached data. if (!empty($pocket_body->list)) { echo '<div class="wrap">'; echo '<h2 class="pkt-nws-gnrtr">' . __('Generated HTML Code', self::DOMAIN) . '</h2>'; echo '<p>' . __('Generated HTML code is as follows. Copy and paste it into your post.', self::DOMAIN) . '</p>'; echo '<div class="pkt-nws-gnrtr">'; echo '<label>' . __('HTML Code', self::DOMAIN) . '</label><br />'; echo '<textarea class="text" style="width:500px;height:300px;">'; foreach ($pocket_body->list as $pocket_item) { //Post URL $html_code = str_replace(self::FRMT_POST_URL, $pocket_item->{PocketUtil::REF_RESOLVED_URL}, stripslashes($format)); //Post title $html_code = str_replace(self::FRMT_POST_TITLE, $pocket_item->{PocketUtil::REF_RESOLVED_TITLE}, $html_code); //Site name and site URL if (strpos($format, self::FRMT_SITE_NAME) !== false || strpos($format, self::FRMT_SITE_URL) !== false) { $url_util = new URLUtil($pocket_item->{PocketUtil::REF_RESOLVED_URL}); $feedly_info_flag = false; do { $feedly_body = $feedly_util->getSiteInfo($url_util->getURL()); $site_name = $feedly_body->results[0]->{FeedlyUtil::REF_SITE_NAME}; $site_url = $feedly_body->results[0]->{FeedlyUtil::REF_SITE_URL}; if (isset($site_name) && isset($site_url)) { $html_code = str_replace(self::FRMT_SITE_NAME, $site_name, $html_code); $html_code = str_replace(self::FRMT_SITE_URL, $site_url, $html_code); $feedly_info_flag = true; break; } //Check next path existence } while ($url_util->next()); if (!$feedly_info_flag) { //Site URL (URL of top page) retrieval $site_url = $pocket_util->getBaseUrl($pocket_item->{PocketUtil::REF_RESOLVED_URL}); $html_code = str_replace(self::FRMT_SITE_URL, $site_url, $html_code); //Information retrieval of OGP $graph = OpenGraph::fetch($pocket_item->{PocketUtil::REF_RESOLVED_URL}); if (isset($graph->site_name)) { // Content of og:site_name $html_code = str_replace(self::FRMT_SITE_NAME, $graph->site_name, $html_code); } else { // Content of title in top page $site_name = $pocket_util->getSiteName($pocket_item->{PocketUtil::REF_RESOLVED_URL}); $html_code = str_replace(self::FRMT_SITE_NAME, $site_name, $html_code); } } } //Post excerpt if (strpos($format, self::FRMT_POST_EXCERPT) !== false) { if (isset($pocket_item->{PocketUtil::REF_EXCERPT})) { // Content of excerpt in Pocket data $html_code = str_replace(self::FRMT_POST_EXCERPT, $pocket_item->{PocketUtil::REF_EXCERPT}, $html_code); } else { //Information retrieval of OGP $graph = OpenGraph::fetch($pocket_item->{PocketUtil::REF_RESOLVED_URL}); // Content of og:description $html_code = str_replace(self::FRMT_POST_EXCERPT, $graph->description, $html_code); } } //Post image if (strpos($format, self::FRMT_POST_IMAGE) !== false) { if (isset($graph->image)) { //Information retrieval of OGP $graph = OpenGraph::fetch($pocket_item->{PocketUtil::REF_RESOLVED_URL}); $html_code = str_replace(self::FRMT_POST_IMAGE, $graph->image, $html_code); } } echo htmlspecialchars($html_code); } echo '</textarea>'; echo '</div>'; echo '</div>'; } else { echo '<div class="pkt-nws-gnrtr">'; echo '<span class="red">' . __('INFO: Pocket data matching your specified condition was not found.', self::DOMAIN) . '</span>'; echo '</div>'; } } else { echo '<div class="pkt-nws-gnrtr">'; echo '<span class="red">' . __('ERROR: Pocket data retrieval failed.', self::DOMAIN) . '</span>'; echo '</div>'; } } }
/** * Renames the node * * @param string $name The new name * @return void */ function setName($name) { list($parentLocalPath, ) = URLUtil::splitPath($this->localPath); list($parentPath, ) = URLUtil::splitPath($this->path); list(, $newName) = URLUtil::splitPath($name); $newPath = $parentLocalPath . '/' . $newName . '/'; $path = trim($parentPath, 'files') . '/' . $newName . '/'; $hash = sha1($path); $log = print_r([$this->exData->pdo, $name, $newPath, $hash, date('Y-m-d H:i:s'), $this->dirid], true); file_put_contents('cache/logs/xxebug.log', ' --- ' . date('Y-m-d H:i:s') . ' --- RequestInterface --- ' . PHP_EOL . $log, FILE_APPEND); $stmt = $this->exData->pdo->prepare('UPDATE vtiger_files_dir SET name=?, path = ?, hash=?, mtime=? WHERE id=?;'); $stmt->execute([$name, $newPath, $hash, date('Y-m-d H:i:s'), $this->dirid]); rename($this->exData->localStorageDir . $this->localPath, $this->exData->localStorageDir . $newPath); $this->path = $newPath; }
/** * This method will check if the url matches the temporary file pattern * if it does, it will return an path based on $this->dataDir for the * temporary file storage. * * @param string $path * @return boolean|string */ protected function isTempFile($path) { // We're only interested in the basename. list(, $tempPath) = URLUtil::splitPath($path); foreach ($this->temporaryFilePatterns as $tempFile) { if (preg_match($tempFile, $tempPath)) { return $this->getDataDir() . '/sabredav_' . md5($path) . '.tempfile'; } } return false; }
public function testAddParameterWithSpaces() { $url = self::BASE_URL; $url = \URLUtil::addQueryParameter($url, "Spaces", "value1 value2"); $this->assertTrue(strcmp($url, BASE_URL . "&Spaces=value1%20value2") == 0); }
/** * Deletes a node from the tree * * @param string $path * @return void */ public function delete($path) { $node = $this->getNodeForPath($path); $node->delete(); list($parent) = URLUtil::splitPath($path); $this->markDirty($parent); }
/** * @dataProvider resolveData */ function testResolve($base, $update, $expected) { $this->assertEquals($expected, URLUtil::resolve($base, $update)); }