Permalink
Browse files

Small cleanups & simplifications

  • Loading branch information...
flack committed Jan 10, 2019
1 parent d7f18ef commit a028d3139c7b1c51e403bc3c5f09e15e215ed53b
@@ -305,12 +305,10 @@ private function _get_css_classes($child, $item)
if ($this->component_name_to_class) {
$classes[] = str_replace('.', '_', $item[MIDCOM_NAV_COMPONENT]);
}
} else {
} elseif ($item[MIDCOM_NAV_ID] === $this->_nap->get_current_leaf()) {
// Place the corresponding css class for the currently active leaf)
if ($item[MIDCOM_NAV_ID] === $this->_nap->get_current_leaf()) {
$classes[] = $this->css_active;
$classes[] = $this->css_selected;
}
$classes[] = $this->css_active;
$classes[] = $this->css_selected;
}
if ($this->has_children_to_class) {
@@ -448,15 +448,11 @@ function get_host_prefix()
if (!$this->_cached_host_prefix) {
$host_name = $this->get_host_name();
$host_prefix = midcom_connection::get_url('prefix');
if ($host_prefix == '') {
$host_prefix = '/';
} elseif ($host_prefix != '/') {
if (substr($host_prefix, 0, 1) != '/') {
$host_prefix = "/{$host_prefix}";
}
if (substr($host_prefix, 0, -1) != '/') {
$host_prefix .= '/';
}
if (substr($host_prefix, 0, 1) != '/') {
$host_prefix = "/{$host_prefix}";
}
if (substr($host_prefix, -1, 1) != '/') {
$host_prefix .= '/';
}
$this->_cached_host_prefix = "{$host_name}{$host_prefix}";
}
@@ -336,10 +336,9 @@ public function get_handler(Request $request)
$this->_load_plugin($namespace, $name);
}
if (empty($argv)) {
$url = '/';
} else {
$url = '/' . implode('/', $argv) . '/';
$url = '/';
if (!empty($argv)) {
$url .= implode('/', $argv) . '/';
}
$this->router->getContext()
->fromRequest($request)
@@ -136,11 +136,10 @@ private function _process_cache($value)
$url = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : midcom_connection::get_url('self');
return new midcom_response_relocate($url);
}
if ($value == 'nocache') {
midcom::get()->cache->content->no_cache();
} else {
if ($value !== 'nocache') {
throw new midcom_error_notfound("Invalid cache request URL.");
}
midcom::get()->cache->content->no_cache();
}
private function _process_logout($value)
@@ -329,9 +329,9 @@ public function get_manifests(midcom_config $config = null)
foreach ($config->get('midcom_components', []) as $path) {
if (!file_exists($path . '/config/manifest.inc')) {
debug_add('No manifest found in path ' . $path . ', skipping', MIDCOM_LOG_ERROR);
} else {
$manifests[] = new midcom_core_manifest($path . '/config/manifest.inc');
continue;
}
$manifests[] = new midcom_core_manifest($path . '/config/manifest.inc');
}
return $manifests;
@@ -527,17 +527,18 @@ public function resize($x = 0, $y = 0)
return;
}
if ($x == 0) {
$geo = "x{$y}>";
} elseif ($y == 0) {
$geo = "{$x}x>";
} else {
$geo = "{$x}x{$y}>";
$geo = '';
if ($x != 0) {
$geo .= $x;
}
$geo .= 'x';
if ($y != 0) {
$geo .= $y;
}
$geo = "-geometry " . escapeshellarg($geo);
$geo .= '>';
$cmd = midcom::get()->config->get('utility_imagemagick_base') . "mogrify {$this->_quality} {$geo} "
. escapeshellarg($this->_filename);
$cmd = midcom::get()->config->get('utility_imagemagick_base') . "mogrify {$this->_quality} -geometry "
. escapeshellarg($geo) . ' ' . escapeshellarg($this->_filename);
$this->_run_command($cmd);
}
@@ -284,7 +284,7 @@ private function _set_property($key, $value)
*
* @param string $key The key that was updated. Leave empty for a complete update by the Datamanager.
*/
private function on_update($key = false)
private function on_update($key = null)
{
if ($key) {
unset($this->_cache[$key]);
@@ -30,14 +30,13 @@
if ($i == $data['page']) {
echo "$i ";
} else {
$page = urlencode($i);
$url = "{$prefix}{$querystring}&page={$page}";
$url = "{$prefix}{$querystring}&page={$i}";
echo "<a href='{$url}'>${i}</a> ";
}
}
if ($data['page'] < $data['max_pages']) {
$page = urlencode($data['page'] + 1);
$page = $data['page'] + 1;
$url = "{$prefix}{$querystring}&page={$page}";
$desc = $data['l10n']->get('next page');
echo "&nbsp;&nbsp;&nbsp;<a href='{$url}'>{$desc} &rArr;</a>";
@@ -163,14 +163,10 @@ private function _get_q(array $params)
$option = array_shift($params);
continue;
}
if ($option_params[0] == "q") {
$q = $option_params[1];
if (!is_numeric($q)) {
$q = 1.0;
} else {
//make sure that 0.0 <= $q <= 1.0
$q = max(0.0, min(1.0, $q));
}
if ( $option_params[0] == "q"
&& is_numeric($option_params[1])) {
// make sure that 0.0 <= $q <= 1.0
$q = max(0.0, min(1.0, $option_params[1]));
}
$option = array_shift($params);
}
@@ -119,10 +119,10 @@ private function process_attachment()
}
if (strlen(trim($this->attachment->title)) > 0) {
$this->title = "{$this->attachment->title} ({$this->attachment->name})";
$this->title = "{$this->attachment->title} ({$this->attachment->name})";
$this->content .= "\n{$this->attachment->title}\n{$this->attachment->name}";
} else {
$this->title = $this->attachment->name;
$this->title = $this->attachment->name;
$this->content .= "\n{$this->attachment->name}";
}

0 comments on commit a028d31

Please sign in to comment.