本文整理汇总了PHP中Tag::url方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::url方法的具体用法?PHP Tag::url怎么用?PHP Tag::url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::url方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
//.........这里部分代码省略.........
if ($chunks > 0) {
// Done, move to permanent location and save to DB
rename($tmp_path, $path);
}
}
if (!$internal_id) {
// Custom text uploads can stop here
die(json_encode(array('filename' => $file_name)));
}
$from = array();
$from['filename'] = $file_name;
$from['internal_id'] = $internal_id;
$from['file_modified_on'] = time();
} else {
if (isset($_POST['localfile'])) {
$filename = basename($_REQUEST['localfile']);
list($internal_id, $path) = $c->generate_internal_id();
if (!file_exists($_REQUEST['localfile'])) {
$this->error('500', '"localfile" does not exist.');
return;
}
if ($path) {
$path .= $filename;
} else {
$this->error('500', 'Unable to create directory for upload.');
return;
}
copy($_REQUEST['localfile'], $path);
$from = array();
$from['filename'] = $filename;
$from['internal_id'] = $internal_id;
$from['file_modified_on'] = time();
} else {
if (isset($_POST['from_url'])) {
$filename = basename($_POST['from_url']);
list($internal_id, $path) = $c->generate_internal_id();
if ($path) {
$path .= $filename;
} else {
$this->error('500', 'Unable to create directory for upload.');
return;
}
if ($this->_download(urldecode($_POST['from_url']), $path, true) && file_exists($path)) {
$from = array();
$from['filename'] = $filename;
$from['internal_id'] = $internal_id;
$from['file_modified_on'] = time();
} else {
$this->error('500', 'Unable to import file from provided URL.');
return;
}
} else {
if (is_null($id)) {
$this->error('403', 'New content records must be accompanied by an upload.');
return;
}
}
}
}
if (isset($from)) {
$from = array_merge($_POST, $from);
} else {
$from = $_POST;
}
if (isset($_REQUEST['rotate']) && is_numeric($_REQUEST['rotate']) && $c->exists()) {
$r = $_REQUEST['rotate'];
示例2: canonicalForTopHeadingCityStateZipSortLetter
/**
* Generate long format of canonical links for top headings.
* The format of canonical links for these landing page is
* ypex.com/Query/City_name/STATE_CODE/zip/page/sortType/letter
* E.g. Ypex.com/Insurance/New-York/NY/10021/2/.
* The point why we use this long format of URL is to avoid duplicated content problem(SEO).
* @param $query String
* @param $city_name String
* @param $state_code String
* @param $zip String
* @param $page String
* @param $sortType String
* @param $letter String
* @return String
*/
public static function canonicalForTopHeadingCityStateZipSortLetter($query, $city_name = '', $state_code = '', $zip = '', $page = '', $sortType = '', $letter = '')
{
// We create a solr document object to pass it to Tag::Url() function.
// We call Tag::Url() to build our canonical link.
// Tag::url() request two parameters.
// The first one is route name and here it is 'premium_geo'.
// The other one is an Apache_Solr_Document object which holds all the values needed
// to build link.
// We also TitleCase query string. That means capitalizing all the words in phrase
// except and, or, the etc.
$paramValues = new Apache_Solr_Document();
// We TitleCase query string. That means capitalizing all the words in phrase
// except and, or, the etc.
$paramValues->query = Common::titleCase($query);
$paramValues->city_name = Common::titleCase($city_name);
$paramValues->state_code = strtoupper($state_code);
$paramValues->zip = $zip;
$paramValues->page = $page;
$paramValues->sortType = strtolower($sortType);
$paramValues->letter = $letter;
// Call Tag::url() to get canonical link.
// The 'premium_geo' parameter specifies the route name.
// The which specifies the form of the link.
// The second parameter is an Apache_Solr_Document object which holds all the values needed
// to build the link.
// Note that the return string is a uri (starts with slash but is not prefixed
// with the host name, e.g. /Insurance/New-York/NY/10021/2/).
$canonicalUri = Tag::url('premium_geo', $paramValues);
// Add host name at the begin ng of the link and return.
return Common::getHostName() . $canonicalUri;
}
示例3: context
function context($params, $auth)
{
if (!$params['neighbors']) {
$single_neighbors = true;
$n = 1;
} else {
$single_neighbors = false;
$n = $params['neighbors'] / 2;
}
$to_arr_options = array('auth' => $auth);
if (!isset($params['context_order'])) {
$params['context_order'] = 'left_id';
$params['context_order_direction'] = 'ASC';
}
if ($params['context_order'] === 'manual') {
$params['context_order'] = 'left_id';
}
$next_operator = strtolower($params['context_order_direction']) === 'asc' ? '>' : '<';
$prev_operator = $next_operator === '>' ? '<' : '>';
$arr = array();
$next = new Album();
$prev = new Album();
if (isset($params['context']) && strpos($params['context'], 'tag-') === 0) {
$tag = str_replace('tag-', '', urldecode($params['context']));
$t = new Tag();
$t->where('name', $tag)->get();
if ($t->exists()) {
$prev->where('deleted', 0)->where('id !=', $this->id)->where('title <', $this->title)->where_related_tag('id', $t->id)->order_by('title DESC, id DESC');
$next->where('deleted', 0)->where('id !=', $this->id)->where('title >', $this->title)->where_related_tag('id', $t->id)->order_by('title ASC, id ASC');
$arr['type'] = 'tag';
$arr['title'] = $tag;
$arr['slug'] = $tag;
$to_arr_options['context'] = "tag-{$tag}";
$t->model = 'tag_albums';
$t->slug = $t->name;
$url = $t->url();
if ($url) {
list($arr['__koken_url'], $arr['url']) = $url;
}
}
} else {
if (isset($params['context']) && strpos($params['context'], 'category-') === 0) {
$category = str_replace('category-', '', $params['context']);
$cat = new Category();
$cat->where('slug', $category)->get();
if ($cat->exists()) {
$prev->where('deleted', 0)->where('id !=', $this->id)->where('title <', $this->title)->where_related_category('id', $cat->id)->order_by('title DESC, id DESC');
$next->where('deleted', 0)->where('id !=', $this->id)->where('title >', $this->title)->where_related_category('id', $cat->id)->order_by('title ASC, id ASC');
$arr['type'] = 'category';
$arr['title'] = $cat->title;
$arr['slug'] = $cat->slug;
$to_arr_options['context'] = "category-{$cat->id}";
$cat->model = 'category_albums';
$url = $cat->url();
if ($url) {
list($arr['__koken_url'], $arr['url']) = $url;
}
}
} else {
$prev->where('deleted', 0)->where("{$params['context_order']} {$prev_operator}", $this->{$params['context_order']})->where('level', $this->level)->order_by("{$params['context_order']} " . ($prev_operator === '<' ? 'DESC' : 'ASC'));
$next->where('deleted', 0)->where("{$params['context_order']} {$next_operator}", $this->{$params['context_order']})->where('level', $this->level)->order_by("{$params['context_order']} {$params['context_order_direction']}");
if ($this->level > 1) {
$parent = new Album();
$parent->select('left_id,right_id')->where('left_id <', $this->left_id)->where('level <', $this->level)->where('visibility', $this->visibility)->where('deleted', 0)->order_by('left_id DESC')->limit(1)->get();
if ($parent->exists()) {
$next->where('left_id >', $parent->left_id);
$next->where('right_id <', $parent->right_id);
$prev->where('left_id >', $parent->left_id);
$prev->where('right_id <', $parent->right_id);
}
}
}
}
if (!$auth) {
$next->where('visibility', 0);
$prev->where('visibility', 0);
}
if (!$params['include_empty_neighbors']) {
$next->where('total_count >', 0);
$prev->where('total_count >', 0);
}
$max = $next->get_clone()->count();
$min = $prev->get_clone()->count();
$arr['total'] = $max + $min + 1;
$arr['position'] = $min + 1;
$pre_limit = $next_limit = $n;
if ($min < $pre_limit) {
$next_limit += $pre_limit - $min;
$pre_limit = $min;
}
if ($max < $next_limit) {
$pre_limit = min($min, $pre_limit + ($next_limit - $max));
$next_limit = $max;
}
$arr['previous'] = array();
$arr['next'] = array();
if ($next_limit > 0) {
$next->limit($next_limit)->get_iterated();
foreach ($next as $a) {
$arr['next'][] = $a->to_array($to_arr_options);
//.........这里部分代码省略.........
示例4: index
//.........这里部分代码省略.........
$params['expand'] = true;
if ($page->exists()) {
$final = $page->to_array($params);
if (!$this->auth && !$final['published']) {
$this->error('404', 'Not found');
return;
}
} else {
$this->error('404', "Text with ID: {$id} not found.");
return;
}
if ($final['page_type'] === 'essay' && $page->published) {
$options = array('neighbors' => false, 'context' => false);
$options = array_merge($options, $params);
if ($options['neighbors']) {
// Make sure $neighbors is at least 2
$options['neighbors'] = max($options['neighbors'], 2);
// Make sure neighbors is even
if ($options['neighbors'] & 1 != 0) {
$options['neighbors']++;
}
$options['neighbors'] = $options['neighbors'] / 2;
} else {
$options['neighbors'] = 1;
}
if ($options['neighbors']) {
// TODO: Performance check
$next = new Text();
$prev = new Text();
$to_arr_options = array('auth' => $this->auth);
$next->group_start()->where('page_type', 0)->where('published', 1)->group_start()->where('published_on <', $page->published_on)->or_group_start()->where('published_on =', $page->published_on)->where('id <', $page->id)->group_end()->group_end()->group_end();
$prev->group_start()->where('page_type', 0)->where('published', 1)->group_start()->where('published_on >', $page->published_on)->or_group_start()->where('published_on =', $page->published_on)->where('id >', $page->id)->group_end()->group_end()->group_end();
if (strpos($options['context'], 'tag-') === 0) {
$tag = str_replace('tag-', '', urldecode($options['context']));
$t = new Tag();
$t->where('name', $tag)->get();
$to_arr_options['context'] = "tag-{$tag}";
if ($t->exists()) {
$next->where_related_tag('id', $t->id);
$prev->where_related_tag('id', $t->id);
$final['context']['type'] = 'tag';
$final['context']['title'] = $tag;
$final['context']['slug'] = $tag;
$t->model = 'tag_essays';
$t->slug = $t->name;
$url = $t->url();
if ($url) {
list($final['context']['__koken_url'], $final['context']['url']) = $url;
}
}
} else {
if (strpos($options['context'], 'category-') === 0) {
$category = str_replace('category-', '', $options['context']);
$cat = new Category();
$cat->where('slug', $category)->get();
if ($cat->exists()) {
$next->where_related_category('id', $cat->id);
$prev->where_related_category('id', $cat->id);
$final['context']['type'] = 'category';
$final['context']['title'] = $cat->title;
$final['context']['slug'] = $cat->slug;
$to_arr_options['context'] = "category-{$cat->id}";
$cat->model = 'category_essays';
$url = $cat->url();
if ($url) {
list($final['context']['__koken_url'], $final['context']['url']) = $url;
示例5: buildRefineUri
protected function buildRefineUri($businessType, $formData)
{
try {
echo str_replace(' ', '', strtolower($businessType)) . 'basicrefine';
if (array_key_exists('cat1', $formData) && !empty($formData['cat1']) && strtolower($formData['cat1']) != strtolower('ALL') && strtolower($formData['cat1']) != strtolower('Any')) {
$refcat1 = new Refcat1();
$formData['cat1name'] = $refcat1->getCatNameById($formData['cat1']);
}
/*
if (strtolower($formData['cat2']) == strtolower('ALL'))
{
$formData['cat2name'] = 'ALL';
}
else{
$refcat2 = new Refcategory();
$formData['cat2name'] = $refcat2->getCatNameById($formData['cat2']);
}
if (strtolower($formData['cat3']) == strtolower('ALL'))
{
$formData['cat3name'] = 'ALL';
}
else{
$refcat3 = new Refcategory();
$formData['cat3name'] = $refcat3->getCatNameById($formData['cat3']);
}
*/
if (array_key_exists('suburbid', $formData) && !empty($formData['suburbid']) && strtolower($formData['suburbid']) != strtolower('ALL')) {
$locationid = $formData['suburbid'];
} elseif (array_key_exists('regionid', $formData) && !empty($formData['regionid']) && strtolower($formData['regionid']) != strtolower('ALL')) {
$locationid = $formData['regionid'];
} elseif (array_key_exists('cityid', $formData) && !empty($formData['cityid']) && strtolower($formData['cityid']) != strtolower('ALL')) {
$locationid = $formData['cityid'];
} elseif (array_key_exists('stateid', $formData) && !empty($formData['stateid']) && strtolower($formData['stateid']) != strtolower('ALL')) {
$locationid = $formData['stateid'];
}
$location = new Location($locationid);
$formData['country'] = $location->getCountry();
$formData['city'] = $location->getUriCity();
$formData['state'] = $location->getUriState();
$formData['locationid'] = $locationid;
logfire('city', $formData['city']);
logfire('state', $formData['state']);
//logfire('cat3name', $formData['cat3name']);
echo 'sss' . '1';
$formData = Common::encodeUriParams($formData);
return Tag::url(str_replace(' ', '', strtolower($businessType)) . 'basicrefine', Common::arrayToStdClass($formData));
} catch (Exception $e) {
echo $e;
}
}
示例6: _getBusinessURL
/**
* Get business detail page's url.
* @param $listing_id
* @param $business_name
* @return string
*/
protected static function _getBusinessURL($listing_id, $business_name)
{
// Get web host name form registry (http://ypex.com).
$registry = Zend_Registry::getInstance();
$config = $registry->get('CONFIG');
$hostName = $config->website->host;
// Create a std class and pass it to Tag::url function to
// build business detail page uri.
$doc = new stdClass();
$doc->business_name = $business_name;
$doc->listing_id = $listing_id;
// Get business detail page's url.
return $hostName . Tag::url('businessBase', $doc);
}