source: branches/1.2/content/plugins/autoreader/templates/autoreader_options.php @ 1334

Revision 1334, 5.8 KB checked in by shibuya246, 3 years ago (diff)

[branch 1.2] latest changes for current version

Line 
1<?php
2    require_once(PLUGINS . 'autoreader/autoreader.php');
3    $arSettings = new Autoreader($h);
4   
5    $action = $h->cage->post->testAlnumLines('action');
6
7     switch ($action) {
8        case "save":           
9            $autoreader_settings = $arSettings->getOptionSettings($h);
10            echo json_encode($autoreader_settings);
11            exit;
12     default :
13         $autoreader_settings = $arSettings->getOptionSettings($h);
14
15    }
16
17 ?>
18
19     
20  <div class="wrap">
21    <h2>Options</h2>
22
23    <?php if(isset($updated)): ?>
24      <div id="added-warning" class="updated"><p><?php echo 'Options saved.'; ?></p></div>
25    <?php endif ?>
26
27    <?php if(isset($not_writable)): ?>
28      <div class="error"><p><?php echo 'Image cache path ' . WPODIR . $autoreader_settings['wpo_cachepath'] . ' is not writable!'; ?></p></div>
29    <?php endif ?>
30
31    <form id="form_options" action="" method="post" accept-charset="utf-8">
32      <input type="hidden" name="update" value="1" />
33
34      <ul id="options">
35        <li id="options_cron">
36             <?php if ($autoreader_settings['wpo_premium']) { ?>
37                  <?php echo label_for('option_unixcron', 'Unix cron') ?>
38                  <?php echo checkbox_tag('option_unixcron', 1, $autoreader_settings['wpo_unixcron']) ?>
39            <?php } ?>
40
41          <h3>Cron command:</h3>
42          <div id="cron_command" class="command"><?php echo $arSettings->cron_command ?></div>
43
44           <?php if ($autoreader_settings['wpo_premium']) { ?>
45              <h3>WebCron-ready URL:</h3>
46              <div id="cron_command" class="command"><?php echo $arSettings->cron_url ?></div>
47           <?php } ?>
48
49          <p class="note"><?php echo 'Cron is set up to handle fetching.'; ?> <?php if ($autoreader_settings['wpo_help']) { ?><a href="<?php echo $arSettings->helpurl ?>cron" class="help_link"><?php echo 'More'; ?></a><?php } ?></p>
50        </li>
51
52        <li>
53          <?php echo label_for('option_logging', 'Enable logging') ?>
54          <?php echo checkbox_tag('option_logging', 1,$autoreader_settings['wpo_log']) ?>
55
56          <p class="note"><?php echo 'Enable database-driven logging of events.'; ?> <?php if ($autoreader_settings['wpo_help']) { ?><a href="<?php echo $this->helpurl ?>logging" class="help_link"><?php echo 'More'; ?></a><?php } ?></p>
57        </li>
58
59        <?php if ($autoreader_settings['wpo_premium']) { ?>
60            <li>
61              <?php echo label_for('option_logging_stdout', 'Enable logging stdout') ?>
62              <?php echo checkbox_tag('option_logging_stdout', 1, $autoreader_settings['wpo_log_stdout']) ?>
63
64              <p class="note"><?php echo 'With this option enabled, Autoreader will attempt to show you logs creation in real time when manual fetching is used.'; ?> <a href="<?php echo $this->helpurl ?>logging" class="help_link"><?php echo 'More'; ?></a></p>
65            </li>
66
67            <li>
68              <?php echo label_for('option_caching','Cache images') ?>
69              <?php echo checkbox_tag('option_caching', 1,$autoreader_settings['wpo_cacheimage']) ?>
70
71              <p class="note"><?php echo 'This option overrides all campaign-specific settings'; ?> <a href="<?php echo $this->helpurl ?>image_caching" class="help_link"><?php echo 'More'; ?></a></p>
72            </li>
73
74            <li>
75              <?php echo label_for('option_cachepath','Image cache path') ?>
76              <?php echo input_tag('option_cachepath', $autoreader_settings['wpo_cachepath']) ?>
77
78              <p class="note"><?php echo 'The path <span id="cachepath">'. PLUGINS . 'Autoreader/<span id="cachepath_input">' . $autoreader_settings['wpo_cachepath'] . '</span></span> must exist, be writable by the server and accessible through browser.'; ?></p>
79            </li>
80        <?php } ?>
81      </ul>
82
83      <p class="submit">
84        <input type="submit" id="edit_submit" value="Save" name="commit">
85      </p>
86    </form>
87  </div>
88
89<script type='text/javascript'>
90    jQuery('document').ready(function($) {
91
92        $("#edit_submit").click(function(event) {
93            event.preventDefault();
94
95            var options = $("form#form_options").serialize();
96
97            var formdata = 'options=' + options + '&action=save';
98            var sendurl = BASEURL + 'admin_index.php?page=plugin_settings&plugin=autoreader&alt_template=autoreader_options';
99
100            $.ajax(
101                {
102                type: 'post',
103                url: sendurl,
104                data: formdata,
105                beforeSend: function () {                   
106                                $('p.submit').append('<img src="' + BASEURL + "content/admin_themes/" + ADMIN_THEME + 'images/ajax-loader.gif' + '"/>');
107                        },
108                error:  function(XMLHttpRequest, textStatus, errorThrown) {
109                                //widget.html('ERROR');
110                },
111                success: function(data, textStatus) { // success means it returned some form of json code to us. may be code with custom error msg
112                        if (data.error === true) {
113                        }
114                        else
115                        {
116                            var img_src = "";
117                            // get required image based on returned data showing new status
118                            if(data.saved == 'true') { img_src = "active.png"; } else { img_src = "inactive.png"; }
119                           $('p.submit img').attr('src', BASEURL + "content/admin_themes/" + ADMIN_THEME + 'images/' + img_src);
120                        }
121                        //$('#return_message').html(data.message).addClass(data.color);
122                        //$('#return_message').html(data.message).addClass('message');
123                        //$('#return_message').fadeIn(1000).fadeout(1000);
124                },
125                dataType: "json"
126            });
127         
128        });
129
130      });
131
132</script>
Note: See TracBrowser for help on using the repository browser.