<?php

/* @phpbbservices_smartfeed/event/overall_header_head_append.html */
class __TwigTemplate_4abe2491e208825b10b29f206b2ee626167341c4c878f3e9f40b3b24c40805a8 extends Twig_Template
{
    public function __construct(Twig_Environment $env)
    {
        parent::__construct($env);

        $this->parent = false;

        $this->blocks = array(
        );
    }

    protected function doDisplay(array $context, array $blocks = array())
    {
        // line 1
        if (($context["S_AUTO_ADVERTISE_PUBLIC_FEED"] ?? null)) {
            // line 2
            echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"";
            echo ($context["U_SMARTFEED_URL"] ?? null);
            echo ($context["U_RSS_PARAMETERS"] ?? null);
            echo "\" />
<link rel=\"alternate\" type=\"application/atom+xml\" title=\"ATOM\" href=\"";
            // line 3
            echo ($context["U_SMARTFEED_URL"] ?? null);
            echo ($context["U_ATOM_PARAMETERS"] ?? null);
            echo "\" />
";
        }
        // line 5
        $asset_file = "@phpbbservices_smartfeed/custom.css";
        $asset = new \phpbb\template\asset($asset_file, $this->getEnvironment()->get_path_helper(), $this->getEnvironment()->get_filesystem());
        if (substr($asset_file, 0, 2) !== './' && $asset->is_relative()) {
            $asset_path = $asset->get_path();            $local_file = $this->getEnvironment()->get_phpbb_root_path() . $asset_path;
            if (!file_exists($local_file)) {
                $local_file = $this->getEnvironment()->findTemplate($asset_path);
                $asset->set_path($local_file, true);
            }
            $asset->add_assets_version('25');
        }
        $this->getEnvironment()->get_assets_bag()->add_stylesheet($asset);        // line 6
        if (($context["S_SMARTFEED_IN_SMARTFEED"] ?? null)) {
            // line 7
            echo "<script type=\"text/javascript\">
// <![CDATA[

// global variables
";
            // line 11
            if ( !($context["S_SMARTFEED_IS_GUEST"] ?? null)) {
                // line 12
                echo "var isIPV6 = ";
                echo ($context["S_SMARTFEED_IS_IPV6"] ?? null);
                echo ";
var smartfeedKey = '";
                // line 13
                echo ($context["S_SMARTFEED_PWD"] ?? null);
                echo "';
var smartfeedKeyWithIP = '";
                // line 14
                echo ($context["S_SMARTFEED_PWD_WITH_IP"] ?? null);
                echo "';
var thisIP = '";
                // line 15
                echo ($context["S_SMARTFEED_IP"] ?? null);
                echo "';
";
            }
            // line 17
            echo "var thereAreRequiredForums = ";
            echo ($context["S_SMARTFEED_REQUIRED_FORUMS"] ?? null);
            echo ";
";
            // line 18
            $asset_file = "@phpbbservices_smartfeed/js/smartfeed.js";
            $asset = new \phpbb\template\asset($asset_file, $this->getEnvironment()->get_path_helper(), $this->getEnvironment()->get_filesystem());
            if (substr($asset_file, 0, 2) !== './' && $asset->is_relative()) {
                $asset_path = $asset->get_path();                $local_file = $this->getEnvironment()->get_phpbb_root_path() . $asset_path;
                if (!file_exists($local_file)) {
                    $local_file = $this->getEnvironment()->findTemplate($asset_path);
                    $asset->set_path($local_file, true);
                }
                $asset->add_assets_version('25');
            }
            $this->getEnvironment()->get_assets_bag()->add_script($asset);            // line 19
            echo "function check_whole_number_range (field, maxValue, allowStar)
{
\t// If a star (wildcard) is allowed in a field, it is accepted. If the value is negative or it exceeds maxValue an error dialog appears and the default 
\t// value shows in the field again.
\tstarMessage = (allowStar) ? '";
            // line 23
            echo twig_escape_filter($this->env, $this->env->getExtension('phpbb\template\twig\extension')->lang("SMARTFEED_STAR_MESSAGE"), "js");
            echo "' : '';
\tif ((allowStar) && (field.value === '*')) {
\t\treturn;
\t}
\t
\tif (isNaN(field.value)) {
\t\talert(\"";
            // line 29
            echo twig_escape_filter($this->env, $this->env->getExtension('phpbb\template\twig\extension')->lang("SMARTFEED_SIZE_ERROR"), "js");
            echo "\" + starMessage);
\t\tfield.value = field.defaultValue;
\t\tfield.focus();
\t\treturn;
\t}
\tsize = parseInt(field.value);
\tif (size < 0) {
\t\talert(\"";
            // line 36
            echo twig_escape_filter($this->env, $this->env->getExtension('phpbb\template\twig\extension')->lang("SMARTFEED_SIZE_ERROR"), "js");
            echo "\" + starMessage);
\t\tfield.value = field.defaultValue;
\t\tfield.focus();
\t\treturn;
\t}
\t
\tif ((parseInt(maxValue) !== 0) && (size > parseInt(maxValue))) {
\t\talert(\"";
            // line 43
            echo twig_escape_filter($this->env, $this->env->getExtension('phpbb\template\twig\extension')->lang("SMARTFEED_SIZE_ERROR"), "js");
            echo "\" + starMessage);
\t\tfield.value = field.defaultValue;
\t\tfield.focus();
\t\treturn;
\t}
\tfield.value = size;
\treturn;
}

function check_for_negative_value (field) {
\t// Function returns an error if the value is negative or is not a number
\tfield_value = field.value;
\tif (isNaN(field_value)) {
\t\talert(\"";
            // line 56
            echo twig_escape_filter($this->env, $this->env->getExtension('phpbb\template\twig\extension')->lang("SMARTFEED_SIZE_ERROR_MIN"), "js");
            echo "\");
\t\tfield.value = field.defaultValue;
\t\tfield.focus();
\t}
\telse {
\t\tfield_value = parseInt(field_value);
\t\tif (field_value < 0) {
\t\t\talert(\"";
            // line 63
            echo twig_escape_filter($this->env, $this->env->getExtension('phpbb\template\twig\extension')->lang("SMARTFEED_SIZE_ERROR_MIN"), "js");
            echo "\");
\t\t\tfield.value = field.defaultValue;
\t\t\tfield.focus();
\t\t}
\t\telse {
\t\t\t//field.value = field.defaultValue;
\t\t\tfield.value = field_value;
\t\t}
\t}
}

function create_URL() {

\t// Creates a URL for display to be used by the newsreader to actually retrieve the newsfeed.
\tvar newsID = document.getElementById('phpbbservices_smartfeed');
\tvar numChecked;
\tvar forumString = '';
\t";
            // line 80
            if (($context["S_SMARTFEED_IS_GUEST"] ?? null)) {
                // line 81
                echo "\tvar loggedIn = 0;
\t";
            } else {
                // line 83
                echo "\tvar loggedIn = 1;
\tvar bookmarksID = document.getElementById('bookmarks');
\tvar pms1ID = document.getElementById('pms1');
\t";
            }
            // line 87
            echo "\t 
\t// Get # of checked forums
\tnumChecked = 0;
\tvar x = document.getElementById('div_0').getElementsByTagName('input');
\tfor(i=0;i<x.length;i++) {
\t\tthisObject = x[i];
\t\telementName = thisObject.name;
\t\tif(elementName !== null) {
\t\t\tif(elementName.substr(0,4) === \"elt_\") {
\t\t\t\tif (thisObject.checked === true) {
\t\t\t\t\tnumChecked++;
\t\t\t\t\tunderscoreLoc = thisObject.id.indexOf('_',5); // Look for underscore past the \"elt_\", or first 4 characters
\t\t\t\t\tforumString = forumString + \"&";
            // line 99
            echo ($context["S_SMARTFEED_FORUMS"] ?? null);
            echo "=\" + elementName.substring(4,underscoreLoc);
\t\t\t\t}
\t\t\t}
\t\t}
\t}
\tif ((thereAreRequiredForums) && (numChecked===0)) {
\t\tforumString = forumString + \"&f=-1\"; // -1 means that no forums were selected but there are required forums
\t\tnumChecked++;
\t}
\t";
            // line 108
            if ( !($context["S_SMARTFEED_IS_GUEST"] ?? null)) {
                // line 109
                echo "\t// If bookmarks are checked, then the forum string should be blank
\tif (bookmarksID.checked) {
\t\tforumString = null;
\t}
\t";
            }
            // line 114
            echo "
\t// If no forums were checked there is no point in generating a URL. 
\t// Instead, give a Javascript warning and generate nothing.
\tcreateMyURL = false;

\t";
            // line 119
            if ( !($context["S_SMARTFEED_IS_GUEST"] ?? null)) {
                // line 120
                echo "\tif ((numChecked===0) && (newsID.all_forums.checked===false) && (bookmarksID.checked===false) && (pms1ID.checked===false))
\t";
            } else {
                // line 122
                echo "\tif ((numChecked===0) && (newsID.all_forums.checked===false)) ";
            }
            echo " {
\t\talert(\"";
            // line 123
            echo twig_escape_filter($this->env, $this->env->getExtension('phpbb\template\twig\extension')->lang("SMARTFEED_NO_FORUMS_SELECTED"), "js");
            echo "\");
\t}
\telse {
\t\tcreateMyURL = true;
\t}

\t// Forums are selected so let's go
\tif (createMyURL) {
\t\t// Initialise the URL
\t\turl = \"";
            // line 132
            echo ($context["UA_SMARTFEED_SITE_URL"] ?? null);
            echo "feed\";
\t\t
\t\t// If user logged in, add the specific variables
\t\tif (loggedIn) {
\t\t\t// Add his user ID
\t\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\t\turl = url + append + \"";
            // line 138
            echo ($context["S_SMARTFEED_USER_ID"] ?? null);
            echo "=";
            echo ($context["UA_SMARTFEED_USER_ID"] ?? null);
            echo "\";

\t\t\t// Add his password + if needed address IP
\t\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\t\t";
            // line 142
            if (($context["S_SMARTFEED_REQUIRED_IP_AUTHENTICATION"] ?? null)) {
                // line 143
                echo "\t\t\turl = url + append + \"";
                echo ($context["S_SMARTFEED_ENCRYPTION_KEY"] ?? null);
                echo "=\" + smartfeedKeyWithIP;
\t\t\t";
            } else {
                // line 145
                echo "\t\t\tif (newsID.ip_auth1.checked === true) {
\t\t\t\turl = url + append + \"";
                // line 146
                echo ($context["S_SMARTFEED_ENCRYPTION_KEY"] ?? null);
                echo "=\" + smartfeedKeyWithIP;
\t\t\t}
\t\t\telse {
\t\t\t\turl = url + append + \"";
                // line 149
                echo ($context["S_SMARTFEED_ENCRYPTION_KEY"] ?? null);
                echo "=\" + smartfeedKey;
\t\t\t}
\t\t\t";
            }
            // line 152
            echo "
\t\t\t// If checked, add to reset the last visit date
\t\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\t\tif (newsID.lastvisit1.checked === true) {
\t\t\t\turl = url + append + \"";
            // line 156
            echo ($context["S_SMARTFEED_SINCE_LAST_VISIT"] ?? null);
            echo "=1\";
\t\t\t}

\t\t\t// If checked, add to add his unread private messages
\t\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\t\tif (newsID.pms1.checked === true) {
\t\t\t\turl = url + append + \"";
            // line 162
            echo ($context["S_SMARTFEED_PRIVATE_MESSAGE"] ?? null);
            echo "=1\";
\t\t\t\tif (newsID.mark_read.checked === true) {
\t\t\t\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\t\t\t\turl = url + append + \"";
            // line 165
            echo ($context["S_SMARTFEED_MARK_PRIVATE_MESSAGES"] ?? null);
            echo "=1\";
\t\t\t\t}
\t\t\t}

\t\t\t// If checked, add to remove his posts
\t\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\t\tif (newsID.remove_yours1.checked === true) {
\t\t\t\turl = url + append + \"";
            // line 172
            echo ($context["S_SMARTFEED_REMOVE_MINE"] ?? null);
            echo "=1\";
\t\t\t}

\t\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\t\t// If checked, add to remove posts from his foes
\t\t\tif (newsID.filter_foes1.checked === true) {
\t\t\t\turl = url + append + \"";
            // line 178
            echo ($context["S_SMARTFEED_FILTER_FOES"] ?? null);
            echo "=1\";
\t\t\t}

\t\t\t// If checked, add to select posts only from bookmarked topics, or from selected forums
\t\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\t\tif (newsID.bookmarks.checked === true) {
\t\t\t\turl = url + append + \"";
            // line 184
            echo ($context["S_SMARTFEED_BOOKMARKS"] ?? null);
            echo "=1\";
\t\t\t}
\t\t\telse {
\t\t\t\tif (newsID.all_forums.checked === false && numChecked > 0) {
\t\t\t\t\t// Remove the 1st \"&\" of the string as it'll be the 1st variable of the url
\t\t\t\t\turl = url + append + forumString.substring(1);
\t\t\t\t}
\t\t\t}
\t\t}
\t\telse {
\t\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\t\tif (newsID.all_forums.checked === false && numChecked > 0) {
\t\t\t\t// Add to select posts from selected forums
\t\t\t\turl = url + append + forumString.substring(1);
\t\t\t}
\t\t}

\t\t// Add the type of posts
\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\tif (newsID.firstpostonly1.checked === true) {
\t\t\turl = url + append + \"";
            // line 204
            echo ($context["S_SMARTFEED_FIRST_POST"] ?? null);
            echo "=1\";
\t\t}

\t\t// Add the time limit
\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\turl = url + append + \"";
            // line 209
            echo ($context["S_SMARTFEED_TIME_LIMIT"] ?? null);
            echo "=\" + newsID.post_limit.value;
\t\t
\t\t// Add the max number of posts
\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\tmaxItems = newsID.max_items.value;
\t\tif (maxItems > 0) {
\t\t\tif (newsID.max_items.value <= maxItems) {
\t\t\t\turl = url + append + \"";
            // line 216
            echo ($context["S_SMARTFEED_MAX_ITEMS_L"] ?? null);
            echo "=\" + newsID.max_items.value;
\t\t\t}
\t\t\telse if (maxItems < 0) {
\t\t\t\talert(\"";
            // line 219
            echo twig_escape_filter($this->env, $this->env->getExtension('phpbb\template\twig\extension')->lang("SMARTFEED_SIZE_ERROR"), "js");
            echo "\");
\t\t\t\tnewsID.max_items.focus();
\t\t\t\treturn;
\t\t\t}
\t\t}

\t\t// Add the sort order
\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\turl = url + append + \"";
            // line 227
            echo ($context["S_SMARTFEED_SORT_BY"] ?? null);
            echo "=\" + newsID.sort_by.value;

\t\t// Add to select posts with minimum words
\t\tif (newsID.min_words.value !== '') {
\t\t\tif (newsID.min_words.value > 0) {
\t\t\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\t\t\turl = url + append + \"";
            // line 233
            echo ($context["S_SMARTFEED_MIN_WORDS"] ?? null);
            echo "=\" + newsID.min_words.value;
\t\t\t}
\t\t\telse  if (newsID.min_words.value < 0) {
\t\t\t\talert(\"";
            // line 236
            echo twig_escape_filter($this->env, $this->env->getExtension('phpbb\template\twig\extension')->lang("SMARTFEED_SIZE_ERROR_MIN"), "js");
            echo "\");
\t\t\t\tnewsID.min_words.focus();
\t\t\t\treturn;
\t\t\t}
\t\t}

\t\t// Add the news feed type
\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\tif (newsID.feed_type1.checked === true) {
\t\t\turl = url + append + \"";
            // line 245
            echo ($context["S_SMARTFEED_FEED_TYPE"] ?? null);
            echo "=\" + \"";
            echo ($context["S_SMARTFEED_RSS_20_VALUE"] ?? null);
            echo "\";
\t\t}
\t\telse {
\t\t\tif (newsID.feed_type2.checked === true) {
\t\t\t\turl = url + append + \"";
            // line 249
            echo ($context["S_SMARTFEED_FEED_TYPE"] ?? null);
            echo "=\" + \"";
            echo ($context["S_SMARTFEED_RSS_10_VALUE"] ?? null);
            echo "\";
\t\t\t}
\t\t\telse {
\t\t\t\turl = url + append + \"";
            // line 252
            echo ($context["S_SMARTFEED_FEED_TYPE"] ?? null);
            echo "=\" + \"";
            echo ($context["S_SMARTFEED_ATOM_10_VALUE"] ?? null);
            echo "\";
\t\t\t}
\t\t}

\t\t// Add the news format
\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\tif (newsID.style1.checked === true) {
\t\t\turl = url + append + \"";
            // line 259
            echo ($context["S_SMARTFEED_FEED_STYLE"] ?? null);
            echo "=\" + newsID.style1.value;
\t\t}
\t\telse {
\t\t\tif (newsID.style2.checked === true) {
\t\t\t\turl = url + append + \"";
            // line 263
            echo ($context["S_SMARTFEED_FEED_STYLE"] ?? null);
            echo "=\" + newsID.style2.value;
\t\t\t}
\t\t\telse {
\t\t\t\tif (newsID.style3.checked === true) {
\t\t\t\t\turl = url + append + \"";
            // line 267
            echo ($context["S_SMARTFEED_FEED_STYLE"] ?? null);
            echo "=\" + newsID.style3.value;
\t\t\t\t}
\t\t\t\telse {
\t\t\t\t\turl = url + append + \"";
            // line 270
            echo ($context["S_SMARTFEED_FEED_STYLE"] ?? null);
            echo "=\" + newsID.style4.value;
\t\t\t\t}
\t\t\t}
\t\t}


\t\tappend = (url.indexOf('?') === -1) ? '?' : '&';
\t\t// Add the maximum words in news
\t\tif (newsID.max_word_size.value !== '') {
\t\t\tif (newsID.max_word_size.value > 0) {
\t\t\t\turl = url + append + \"";
            // line 280
            echo ($context["S_SMARTFEED_MAX_WORDS"] ?? null);
            echo "=\" + newsID.max_word_size.value;
\t\t\t}
\t\t\telse if (newsID.max_word_size.value < 0) {
\t\t\t\talert(\"";
            // line 283
            echo twig_escape_filter($this->env, $this->env->getExtension('phpbb\template\twig\extension')->lang("SMARTFEED_SIZE_ERROR_MIN"), "js");
            echo "\");
\t\t\t\tnewsID.max_word_size.focus();
\t\t\t\treturn
\t\t\t}
\t\t}

\t\t// Place the url in the field
\t\tnewsID.url.value = encodeURI(url);
\t\treturn true;
\t}
\telse {
\t\treturn false;\t// Failed validation
\t}
}

// ]]>  
</script>
";
        }
    }

    public function getTemplateName()
    {
        return "@phpbbservices_smartfeed/event/overall_header_head_append.html";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  489 => 283,  483 => 280,  470 => 270,  464 => 267,  457 => 263,  450 => 259,  438 => 252,  430 => 249,  421 => 245,  409 => 236,  403 => 233,  394 => 227,  383 => 219,  377 => 216,  367 => 209,  359 => 204,  336 => 184,  327 => 178,  318 => 172,  308 => 165,  302 => 162,  293 => 156,  287 => 152,  281 => 149,  275 => 146,  272 => 145,  266 => 143,  264 => 142,  255 => 138,  246 => 132,  234 => 123,  229 => 122,  225 => 120,  223 => 119,  216 => 114,  209 => 109,  207 => 108,  195 => 99,  181 => 87,  175 => 83,  171 => 81,  169 => 80,  149 => 63,  139 => 56,  123 => 43,  113 => 36,  103 => 29,  94 => 23,  88 => 19,  77 => 18,  72 => 17,  67 => 15,  63 => 14,  59 => 13,  54 => 12,  52 => 11,  46 => 7,  44 => 6,  33 => 5,  27 => 3,  21 => 2,  19 => 1,);
    }

    /** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */
    public function getSource()
    {
        @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED);

        return $this->getSourceContext()->getCode();
    }

    public function getSourceContext()
    {
        return new Twig_Source("", "@phpbbservices_smartfeed/event/overall_header_head_append.html", "");
    }
}
