1<?php
2/**
3 * Copyright (c) 2021. ComboStrap, Inc. and its affiliates. All Rights Reserved.
4 *
5 * This source code is licensed under the GPL license found in the
6 * COPYING  file in the root directory of this source tree.
7 *
8 * @license  GPL 3 (https://www.gnu.org/licenses/gpl-3.0.en.html)
9 * @author   ComboStrap <support@combostrap.com>
10 *
11 */
12
13namespace ComboStrap;
14
15
16use syntax_plugin_combo_tooltip;
17
18/**
19 * Class PageProtection handles the protection of page against
20 * public agent such as low quality page or late publication
21 *
22 * @package ComboStrap
23 *
24 * The test are in two separate classes {@link \LowQualityPageTest}
25 * and {@link \PublicationTest}
26 */
27class PageProtection
28{
29
30    const NAME = "page-protection";
31    const ACRONYM = "pp";
32
33    /**
34     * The possible values
35     */
36    const CONF_VALUE_ACL = "acl";
37    const CONF_VALUE_HIDDEN = "hidden";
38    const CONF_VALUE_ROBOT = "robot";
39    const CONF_VALUE_FEED = "feed";
40
41
42    const PAGE_PROTECTION_LINK_WARNING = "warning";
43    const PAGE_PROTECTION_LINK_NORMAL = "normal";
44    const PAGE_PROTECTION_LINK_LOGIN = "login";
45    public const DATA_PP_SOURCE = "data-pp-source";
46    public const DATA_PP_LINK = "data-pp-link";
47
48
49    /**
50     * Add the Javascript snippet
51     * We have created only one because a page
52     * may be of low quality and with a late publication.
53     * To resolve conflict between the two protections, the parameters are the same
54     * and the late publication takes precedence on low quality page
55     */
56    public static function addPageProtectionSnippet()
57    {
58        Tooltip::addToolTipSnippetIfNeeded();
59        PluginUtility::getSnippetManager()->attachJavascriptFromComponentId(self::NAME);
60    }
61
62}
63