Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/site/app/views/helpers/addons_html.php
diff options
context:
space:
mode:
Diffstat (limited to 'site/app/views/helpers/addons_html.php')
-rw-r--r--site/app/views/helpers/addons_html.php127
1 files changed, 11 insertions, 116 deletions
diff --git a/site/app/views/helpers/addons_html.php b/site/app/views/helpers/addons_html.php
index e996a82..b2d90b6 100644
--- a/site/app/views/helpers/addons_html.php
+++ b/site/app/views/helpers/addons_html.php
@@ -123,7 +123,7 @@ class AddonsHtmlHelper extends HtmlHelper
/**
* creates an <a href> link to a file
*/
- function linkFile($fileId, $title, $path, $htmlAttributes = array(), $return = false, $filename = null, $collection_id = null) {
+ function linkFile($fileId, $title, $path, $htmlAttributes = array(), $return = false, $filename = null) {
if (strpos($path, '://')!==false) {
$url = $path;
} else {
@@ -141,17 +141,13 @@ class AddonsHtmlHelper extends HtmlHelper
// optionally add file name for Save As to work correctly
if (!empty($filename))
$url .= "/$filename";
-
- // optionally add a collection stats code to the URL
- if (!empty($collection_id))
- $url .= "?collection_id={$collection_id}";
}
return $this->output(sprintf($this->tags['link'], $url, $this->parseHtmlOptions($htmlAttributes, null, '', ' '), $title), $return);
}
/**
* returns the url to $fileId
*/
- function urlFile($fileId, $filename = null, $collection_id = null) {
+ function urlFile($fileId, $filename = null) {
$url = $this->base . '/';
$url .= LANG;
$url .= '/'.APP_SHORTNAME;
@@ -160,11 +156,7 @@ class AddonsHtmlHelper extends HtmlHelper
//optionally add file name for Save As to work correctly
if (!empty($filename))
$url .= "/$filename";
-
- // optionally add a collection stats code to the URL
- if (!empty($collection_id))
- $url .= "?collection_id={$collection_id}";
-
+
return $url;
}
@@ -215,7 +207,7 @@ class AddonsHtmlHelper extends HtmlHelper
$showOthers = false;
}
- $text = @implode(", ", array_map(array(&$this, 'linkUserFromModel'), $usersModel));
+ $text = implode(", ", array_map(array(&$this, 'linkUserFromModel'), $usersModel));
if ($showOthers) {
$text .= ', ';
@@ -229,23 +221,12 @@ class AddonsHtmlHelper extends HtmlHelper
}
/**
- * Helper for getting a URL without application and locale.
- */
- function rootUrl($url = null) {
- return $this->url($url, false, false, false);
- }
-
- /**
* locale and application aware url generator function
*/
function url($url = null, $return = false, $addLocale = true, $addApplication = true) {
$oldbase = $this->base;
- if (!empty($this->plugin)) {
- $newbase = strip_plugin($this->base, $this->plugin);
- } else {
- $newbase = $this->base;
- }
+ $newbase = strip_plugin($this->base, $this->plugin);
// Rewrite base address to include locale, if applicable
if ($addLocale && $this->addLocale) {
@@ -267,7 +248,7 @@ class AddonsHtmlHelper extends HtmlHelper
$newbase .= '/'.APP_SHORTNAME;
}
- if (!empty($this->plugin)) {
+ if ($this->plugin) {
$newbase .= '/'.$this->plugin;
}
@@ -288,22 +269,18 @@ class AddonsHtmlHelper extends HtmlHelper
// Shouldn't see anything weird here, because it has to be a valid cake url
$_forward_to = empty($this->params['url']['url']) ? '' : $this->params['url']['url'];
}
- $get_params = array();
if ($add_get_parameters) {
// add GET parameters
+ $get_params = array();
foreach($this->params['url'] as $_key => $_param)
if ($_key != 'url') $get_params[] = "{$_key}={$_param}";
if (!empty($get_params)) $_forward_to .= '?'.implode('&',$get_params);
}
- if(!isset($this->params['url']['to'])) {
- $_forward_to = urlencode($_forward_to); // urlencode entities in the parameters
- } else {
- $_forward_to = urlencode($this->params['url']['to']);
- }
-
+ $_forward_to = urlencode($_forward_to); // urlencode entities in the parameters
$_forward_to = '?to='.$_forward_to;
+
return '/users/log'.(!$logout?'in':'out').$_forward_to;
}
@@ -506,95 +483,13 @@ class AddonsHtmlHelper extends HtmlHelper
return $this->output(implode("\n", $select), $return);
}
- function truncateChars($length, $string, $onSpaces = false) {
+ function truncateChars($length, $string) {
if (mb_strlen($string) <= $length) {
return $string;
} else {
- if($onSpaces) {
- $string = mb_substr($string, 0, $length-3);
- $sub = mb_substr($string, 0, mb_strrpos($string, ' '));
- } else {
- $sub = mb_substr($string, 0, $length - 3);
- }
+ $sub = mb_substr($string, 0, $length - 3);
return $sub.'...';
}
}
-
- /**
- * Returns the value of $statusMap according to the status of $addon.
- *
- * @param array $addon Addon object
- * @param array $statusMap assoc array with keys 'experimental',
- * 'recommended', and 'default'
- */
- function byStatus($addon, $statusMap) {
- global $experimental_status;
- if (in_array($addon['Addon']['status'], $experimental_status)) {
- return $statusMap['experimental'];
- } elseif ((isset($addon['Addon']['recommended']) && $addon['Addon']['recommended']) || $this->isFeatured($addon))
- {
- return $statusMap['recommended'];
- } else {
- return $statusMap['default'];
- }
- }
-
- function extraClass($addon, $default='') {
- return $this->byStatus($addon, array('experimental' => 'exp',
- 'recommended' => 'rec',
- 'default' => $default));
- }
-
- /**
- * Returns true or false if the addon is featured
- *
- * @param array $addon Addon object
- * @return boolean True/false if addon is featured
- */
- function isFeatured($addon) {
- $featured = false;
-
- foreach($addon['AddonTag'] as $tag) {
- if($tag['feature'] == 1) {
- $featured = true;
- break;
- }
- }
- return $featured;
- }
-
- function flag($addon, $default='') {
- $flag = $this->byStatus($addon, array(
- 'experimental' => $this->link(___('addon_listitem_flag_experimental'),
- '/pages/faq#experimental-addons'),
- 'recommended' => $this->link(___('addon_listitem_flag_recommended'),
- '/pages/faq#recommended-addons'),
- 'default' => $default
- ));
- if (!empty($flag)) {
- return '<h5 class="flag">'.$flag.'</h5>';
- } else {
- return '';
- }
- }
-
- /**
- * This is copied from cake, but with less fail.
- *
- * If $model->validationErrors[$field] is 1, we'll show $default_text.
- * This is for backwards compat with $model->invalidate.
- *
- * If $model->validationErrors[$field] is a string, we'll use that as
- * the error message.
- */
- function tagErrorMsg($field, $text) {
- $this->setFormTag($field);
- if ($error = $this->tagIsInvalid($this->model, $this->field)) {
- $msg = is_string($error) ? $error : $text;
- return sprintf('<div class="error_message">%s</div>', $msg);
- } else {
- return null;
- }
- }
}
?>