浏览代码

Merge pull request #447 from aledeg/share

Sharing optimization
Alexandre Alapetite 12 年之前
父节点
当前提交
faa9a74324
共有 4 个文件被更改,包括 13 次插入9 次删除
  1. 11 4
      app/Models/Configuration.php
  2. 0 3
      app/Models/Share.php
  3. 1 1
      app/views/configure/sharing.phtml
  4. 1 1
      app/views/helpers/view/normal_view.phtml

+ 11 - 4
app/Models/Configuration.php

@@ -193,7 +193,9 @@ class FreshRSS_Configuration {
 			if (!is_array($value)) {
 				continue;
 			}
-			if (array_key_exists('url', $value)) {
+
+			// Verify URL and add default value when needed
+			if (isset($value['url'])) {
 				$is_url = (
 					filter_var ($value['url'], FILTER_VALIDATE_URL) ||
 					(version_compare(PHP_VERSION, '5.3.3', '<') &&
@@ -203,10 +205,15 @@ class FreshRSS_Configuration {
 				if (!$is_url) {
 					continue;
 				}
-				if (!array_key_exists('name', $value) || strcmp($value['name'], '') === 0) {
-					$value['name'] = $value['type'];
-				}
+			} else {
+				$value['url'] = null;
 			}
+
+			// Add a default name
+			if (empty($value['name'])) {
+				$value['name'] = $value['type'];
+			}
+
 			$this->data['sharing'][] = $value;
 		}
 	}

+ 0 - 3
app/Models/Share.php

@@ -3,9 +3,6 @@
 class FreshRSS_Share {
 
 	static public function generateUrl($options, $selected, $link, $title) {
-		if (!array_key_exists('url', $selected)) {
-			$selected['url'] = '';
-		}
 		$share = $options[$selected['type']];
 		$matches = array(
 			'~URL~',

+ 1 - 1
app/views/configure/sharing.phtml

@@ -35,7 +35,7 @@
 				<a href='#' class='share add'><?php echo FreshRSS_Themes::icon('add'); ?></a>
 				<select>
 					<?php foreach($this->conf->shares as $key => $params):?>
-						<option value='<?php echo $key?>' data-form='<?php echo $params['form']?>' data-help='<?php echo $params['help']?>'><?php echo Minz_Translate::t($key) ?></option>
+						<option value='<?php echo $key?>' data-form='<?php echo $params['form']?>' data-help='<?php if (!empty($params['help'])) {echo $params['help'];}?>'><?php echo Minz_Translate::t($key) ?></option>
 					<?php endforeach; ?>
 				</select>
 			</div>

+ 1 - 1
app/views/helpers/view/normal_view.phtml

@@ -138,7 +138,7 @@ if (!empty($this->entries)) {
 							<?php foreach ($sharing as $share) :?>
 								<li class="item share">
 									<a target="_blank" href="<?php echo FreshRSS_Share::generateUrl($this->conf->shares, $share, $item->link(), $item->title() . ' . ' . $feed->name())?>">
-										<?php echo array_key_exists('name', $share) ? $share['name'] : Minz_Translate::t ($share['type']);?>
+										<?php echo Minz_Translate::t ($share['name']);?>
 									</a>
 								</li>
 							<?php endforeach;?>