aboutsummaryrefslogtreecommitdiff
path: root/app/views/helpers/category/update.phtml
blob: 9e55e613db325d082050db6226f62f0fc71892da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<div class="post">
	<h1><?= $this->category->name() ?></h1>

	<div>
		<a href="<?= _url('index', 'index', 'get', 'c_' . $this->category->id()) ?>"><?= _i('link') ?> <?= _t('gen.action.filter') ?></a>
	</div>

	<form method="post" action="<?= _url('subscription', 'category', 'id', $this->category->id()) ?>" autocomplete="off">
		<input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
		<legend><?= _t('sub.category.information') ?></legend>
		<div class="form-group">
			<label class="group-name" for="name"><?= _t('sub.category.title') ?></label>
			<div class="group-controls">
				<input type="text" name="name" id="name" class="extend" value="<?= $this->category->name()  ?>" <?php
					//Disallow changing the name of the default category
					echo $this->category->id() == FreshRSS_CategoryDAO::DEFAULTCATEGORYID ? 'disabled="disabled"' : '';
				?> />
			</div>
		</div>
		<div class="form-group">
			<label class="group-name" for="position"><?= _t('sub.category.position') ?></label>
			<div class="group-controls">
				<input type="number" name="position" id="position" min="1" value="<?= $this->category->attributes('position') ?>" />
				<?= _i('help') ?> <?= _t('sub.category.position_help') ?>
			</div>
		</div>

		<div class="form-group form-actions">
			<div class="group-controls">
				<button class="btn btn-important"><?= _t('gen.action.submit') ?></button>
				<button class="btn btn-attention confirm"
					data-str-confirm="<?= _t('gen.js.confirm_action_feed_cat') ?>"
					formaction="<?= _url('category', 'empty', 'id', $this->category->id()) ?>"
					formmethod="post"><?= _t('gen.action.empty') ?></button>
				<?php if (!$this->category->isDefault()): ?>
				<button class="btn btn-attention confirm"
					data-str-confirm="<?= _t('gen.js.confirm_action_feed_cat') ?>"
					formaction="<?= _url('category', 'delete', 'id', $this->category->id()) ?>"
					formmethod="post"><?= _t('gen.action.remove') ?></button>
				<?php endif;?>
			</div>
		</div>

		<legend><?= _t('sub.category.archiving') ?></legend>
		<?php
			$archiving = $this->category->attributes('archiving');
			if (empty($archiving)) {
				$archiving = [ 'default' => true ];
			} else {
				$archiving['default'] = false;
			}
			$volatile = [
				'enable_keep_period' => false,
				'keep_period_count' => '3',
				'keep_period_unit' => 'P1M',
			];
			if (!empty($archiving['keep_period'])) {
				if (preg_match('/^PT?(?P<count>\d+)[YMWDH]$/', $archiving['keep_period'], $matches)) {
					$volatile['enable_keep_period'] = true;
					$volatile['keep_period_count'] = $matches['count'];
					$volatile['keep_period_unit'] = str_replace($matches['count'], '1', $archiving['keep_period']);
				}
			}
			//Defaults
			if (!isset($archiving['keep_max'])) {
				$archiving['keep_max'] = false;
			}
			if (!isset($archiving['keep_favourites'])) {
				$archiving['keep_favourites'] = true;
			}
			if (!isset($archiving['keep_labels'])) {
				$archiving['keep_labels'] = true;
			}
			if (!isset($archiving['keep_unreads'])) {
				$archiving['keep_unreads'] = false;
			}
			if (!isset($archiving['keep_min'])) {
				$archiving['keep_min'] = 50;
			}
		?>

		<p class="alert alert-warn">
			<?= _t('conf.archiving.policy_warning') ?>
		</p>

		<div class="form-group">
			<label class="group-name"><?= _t('conf.archiving.policy') ?></label>
			<div class="group-controls">
				<label class="checkbox">
					<input type="checkbox" name="use_default_purge_options" id="use_default_purge_options" value="1"<?= $archiving['default'] ? ' checked="checked"' : '' ?> data-leave-validation="<?= $archiving['default'] ? 1 : 0 ?>" />
					<?= _t('gen.short.by_default') ?>
				</label>
			</div>
		</div>
		<div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
			<div class="group-controls">
				<label class="checkbox" for="enable_keep_max">
					<input type="checkbox" name="enable_keep_max" id="enable_keep_max" value="1"<?= empty($archiving['keep_max']) ? '' : ' checked="checked"' ?> data-leave-validation="<?= empty($archiving['keep_max']) ? 0 : 1 ?>"/>
					<?= _t('conf.archiving.keep_max') ?>
					<input type="number" id="keep_max" name="keep_max" min="0" value="<?= empty($archiving['keep_max']) ? 200 : $archiving['keep_max'] ?>" data-leave-validation="<?= empty($archiving['keep_max']) ? 200 : $archiving['keep_max'] ?>"/>
				</label>
			</div>
		</div>
		<div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
			<div class="group-controls">
				<label class="checkbox" for="enable_keep_period">
					<input type="checkbox" name="enable_keep_period" id="enable_keep_period" value="1"<?= $volatile['enable_keep_period'] ? ' checked="checked"' : '' ?> data-leave-validation="<?= $volatile['enable_keep_period'] ? 1 : 0 ?>"/>
					<?= _t('conf.archiving.keep_period') ?>
					<input type="number" id="keep_period_count" name="keep_period_count" min="0" value="<?= $volatile['keep_period_count'] ?>" data-leave-validation="<?= $volatile['keep_period_count'] ?>"/>
					<select class="number" name="keep_period_unit" id="keep_period_unit" data-leave-validation="<?= $volatile['keep_period_unit'] ?>">
						<option></option>
						<option value="P1Y" <?= 'P1Y' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.years') ?></option>
						<option value="P1M" <?= 'P1M' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.months') ?></option>
						<option value="P1W" <?= 'P1W' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.weeks') ?></option>
						<option value="P1D" <?= 'P1D' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.days') ?></option>
						<option value="PT1H" <?= 'PT1H' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.hours') ?></option>
					</select>
				</label>
			</div>
		</div>
		<div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
			<label class="group-name"><?= _t('conf.archiving.exception') ?></label>
			<div class="group-controls">
				<label class="checkbox" for="keep_favourites">
					<input type="checkbox" name="keep_favourites" id="keep_favourites" value="1"<?= $archiving['keep_favourites'] ? ' checked="checked"' : '' ?> data-leave-validation="<?= $archiving['keep_favourites'] ? 1 : 0 ?>"/>
					<?= _t('conf.archiving.keep_favourites') ?>
				</label>
			</div>
		</div>
		<div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
			<div class="group-controls">
				<label class="checkbox" for="keep_labels">
					<input type="checkbox" name="keep_labels" id="keep_labels" value="1"<?= $archiving['keep_labels'] ? ' checked="checked"' : '' ?> data-leave-validation="<?= $archiving['keep_labels'] ? 1 : 0 ?>"/>
					<?= _t('conf.archiving.keep_labels') ?>
				</label>
			</div>
		</div>
		<div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
			<div class="group-controls">
				<label class="checkbox" for="keep_unreads">
					<input type="checkbox" name="keep_unreads" id="keep_unreads" value="1"<?= $archiving['keep_unreads'] ? ' checked="checked"' : '' ?> data-leave-validation="<?= $archiving['keep_unreads'] ? 1 : 0 ?>"/>
					<?= _t('conf.archiving.keep_unreads') ?>
				</label>
			</div>
		</div>
		<div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
			<div class="group-controls">
				<label for="keep_min"><?= _t('sub.feed.keep_min') ?>
					<input type="number" id="keep_min" name="keep_min" min="0" value="<?= $archiving['keep_min'] ?>" data-leave-validation="<?= $archiving['keep_min'] ?>">
				</label>
			</div>
		</div>
		<div class="form-group form-actions">
			<div class="group-controls">
				<button class="btn btn-important"><?= _t('gen.action.submit') ?></button>
				<button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
			</div>
		</div>
	</form>
</div>