diff options
| author | 2015-01-07 14:59:18 +0100 | |
|---|---|---|
| committer | 2015-01-07 14:59:18 +0100 | |
| commit | 0140448a562b97859be0b9a6e480e1f6aa4d1b1d (patch) | |
| tree | 02cfb3cc6b4e0e3af8d096c44c8c5bf2c70f7ae8 /app/views | |
| parent | bd199c617081f0354576afd09e9427756873afd2 (diff) | |
Refactor FreshRSS_Share object to be more usable
- FreshRSS_Share is the only object we manipulate
- Add a way to register new share options easily
- Move some i18n keys from index.php to gen.php
See https://github.com/FreshRSS/FreshRSS/issues/730
Diffstat (limited to 'app/views')
| -rw-r--r-- | app/views/configure/sharing.phtml | 27 | ||||
| -rw-r--r-- | app/views/index/normal.phtml | 28 |
2 files changed, 29 insertions, 26 deletions
diff --git a/app/views/configure/sharing.phtml b/app/views/configure/sharing.phtml index f5c133f07..da7557480 100644 --- a/app/views/configure/sharing.phtml +++ b/app/views/configure/sharing.phtml @@ -15,22 +15,25 @@ <a target="_blank" class="btn" title="<?php echo _t('conf.sharing.more_information'); ?>" href="##help##"><?php echo _i('help'); ?></a> </div></div>'> <legend><?php echo _t('conf.sharing'); ?></legend> - <?php foreach (FreshRSS_Context::$user_conf->sharing as $key => $sharing) { ?> - <?php $share = FreshRSS_Context::$user_conf->shares[$sharing['type']]; ?> - <div class="form-group" id="group-share-<?php echo $key; ?>"> + <?php + foreach (FreshRSS_Context::$user_conf->sharing as $key => $share_options) { + $share = FreshRSS_Share::get($share_options['type']); + $share->update($share_options); + ?> + <div class="form-group group-share" id="group-share-<?php echo $key; ?>"> <label class="group-name"> - <?php echo _t('conf.sharing.' . $sharing['type']); ?> + <?php echo $share->name(true); ?> </label> <div class="group-controls"> - <input type='hidden' id='share_<?php echo $key;?>_type' name="share[<?php echo $key;?>][type]" value='<?php echo $sharing['type']?>' /> - <?php if ($share['form'] === 'advanced') { ?> + <input type='hidden' id='share_<?php echo $key; ?>_type' name="share[<?php echo $key; ?>][type]" value='<?php echo $share->type(); ?>' /> + <?php if ($share->formType() === 'advanced') { ?> <div class="stick"> - <input type="text" id="share_<?php echo $key;?>_name" name="share[<?php echo $key;?>][name]" class="extend" value="<?php echo $sharing['name']?>" placeholder="<?php echo _t('conf.sharing.share_name'); ?>" size="64" /> - <input type="url" id="share_<?php echo $key;?>_url" name="share[<?php echo $key;?>][url]" class="extend" value="<?php echo $sharing['url']?>" placeholder="<?php echo _t('conf.sharing.share_url'); ?>" size="64" /> + <input type="text" id="share_<?php echo $key; ?>_name" name="share[<?php echo $key; ?>][name]" class="extend" value="<?php echo $share->name(); ?>" placeholder="<?php echo _t('conf.sharing.share_name'); ?>" size="64" /> + <input type="url" id="share_<?php echo $key; ?>_url" name="share[<?php echo $key; ?>][url]" class="extend" value="<?php echo $share->baseUrl(); ?>" placeholder="<?php echo _t('conf.sharing.share_url'); ?>" size="64" /> <a href='#' class='remove btn btn-attention' data-remove="group-share-<?php echo $key; ?>"><?php echo _i('close'); ?></a> </div> - <a target="_blank" class="btn" title="<?php echo _t('conf.sharing.more_information'); ?>" href="<?php echo $share['help']?>"><?php echo _i('help'); ?></a> + <a target="_blank" class="btn" title="<?php echo _t('conf.sharing.more_information'); ?>" href="<?php echo $share->help(); ?>"><?php echo _i('help'); ?></a> <?php } else { ?> <a href='#' class='remove btn btn-attention' data-remove="group-share-<?php echo $key; ?>"><?php echo _i('close'); ?></a> <?php } ?> @@ -41,8 +44,10 @@ <div class="form-group"> <div class="group-controls"> <select> - <?php foreach(FreshRSS_Context::$user_conf->shares as $key => $params) { ?> - <option value='<?php echo $key?>' data-form='<?php echo $params['form']?>' data-help='<?php if (!empty($params['help'])) {echo $params['help'];}?>'><?php echo _t('conf.sharing.' . $key) ?></option> + <?php foreach (FreshRSS_Share::enum() as $share) { ?> + <option value='<?php echo $share->type(); ?>' data-form='<?php echo $share->formType(); ?>' data-help='<?php echo $share->help(); ?>'> + <?php echo $share->name(true); ?> + </option> <?php } ?> </select> <a href='#' class='share add btn'><?php echo _i('add'); ?></a> diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index c2cf7c887..8c6ddd1ee 100644 --- a/app/views/index/normal.phtml +++ b/app/views/index/normal.phtml @@ -129,8 +129,6 @@ if (!empty($this->entries)) { } ?> <li class="item"><?php if ($bottomline_sharing) { - $link = urlencode($item->link()); - $title = urlencode($item->title() . ' · ' . $feed->name()); ?><div class="dropdown"> <div id="dropdown-share-<?php echo $item->id();?>" class="dropdown-target"></div> <a class="dropdown-toggle" href="#dropdown-share-<?php echo $item->id();?>"> @@ -139,19 +137,19 @@ if (!empty($this->entries)) { </a> <ul class="dropdown-menu"> - <li class="dropdown-close"><a href="#close">❌</a></li> - <?php - foreach ($sharing as $share) { - $type_share = FreshRSS_Context::$user_conf->shares[$share['type']]; - $has_specific_title = ($type_share['form'] === 'advanced'); - ?> - <li class="item share"> - <a target="_blank" href="<?php echo FreshRSS_Share::generateUrl(FreshRSS_Context::$user_conf->shares, $share, $item->link(), $item->title() . ' . ' . $feed->name())?>"> - <?php echo $has_specific_title ? $share['name'] : _t('index.share.' . $share['name']); ?> - </a> - </li> - <?php } ?> - </ul> + <li class="dropdown-close"><a href="#close">❌</a></li><?php + $link = $item->link(); + $title = $item->title() . ' · ' . $feed->name(); + foreach (FreshRSS_Context::$user_conf->sharing as $share_options) { + $share = FreshRSS_Share::get($share_options['type']); + $share_options['link'] = $link; + $share_options['title'] = $title; + $share->update($share_options); + ?><li class="item share"> + <a target="_blank" href="<?php echo $share->url(); ?>"><?php echo $share->name(); ?></a> + </li><?php + } + ?></ul> </div> <?php } ?> </li><?php |
