<commit_before><?php
/*"******************************************************************************************************
*   (c) 2007-2012 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
*-------------------------------------------------------------------------------------------------------*
*	$Id$                                  *
********************************************************************************************************/

/**
 * A content-provider used to upload archives from remote repositories.
 * Provides both, a search and a download-part.
 *
 * This implementation allows usage for various remote repositories. The access details are specified
 * using the constructor.
 *
 * Remote repositories are expected to provide packages using the packageserver module.
 *
 * @module module_packagemanager
 * @author <EMAIL>
 * @author <EMAIL>
 * @since 4.0
 */
abstract class class_module_packagemanager_contentprovider_remote_base implements interface_packagemanager_contentprovider {

    private $STR_BROWSE_HOST = "";
    private $STR_BROWSE_URL = "";
    private $STR_SEARCH_URL = "";
    private $STR_DOWNLOAD_URL = "";
    private $STR_PROVIDER_NAME;

    function __construct($strProviderName, $strBrowseHost, $strBrowseUrl, $strSearchUrl, $strDownloadUrl) {
        $this->STR_PROVIDER_NAME = $strProviderName;
        $this->STR_BROWSE_HOST = $strBrowseHost;
        $this->STR_BROWSE_URL = $strBrowseUrl;
        $this->STR_SEARCH_URL = $strSearchUrl;
        $this->STR_DOWNLOAD_URL = $strDownloadUrl;
    }


    /**
     * Returns the name of the current provider, in most cases used to select the provider.
     *
     * @return mixed
     */
    public function getDisplayTitle() {
        return class_carrier::getInstance()->getObjLang()->getLang($this->STR_PROVIDER_NAME, "packagemanager");
    }

    /**
     * Renders the list of available packages or any other kind of gui-representation
     * of the packageprovider.
     *
     * Whenever the provider is capable of uploading new packages, the copy & and upload process
     * should be triggered by the admin-class again.
     * So make sure links or forms point to
     * module = packagemanager
     * action = uploadPackage
     * provider = class_name
     * The provider will be called using the processPackageUpload method.
     *
     * @throws class_exception
     * @return string
     */
    public function renderPackageList() {
        $intStart = ($this->getPageNumber() - 1) * _admin_nr_of_rows_;
        $intEnd = $intStart + _admin_nr_of_rows_ - 1;
        $intType = 0;

        $objToolkit = class_carrier::getInstance()->getObjToolkit("admin");
        $objLang = class_carrier::getInstance()->getObjLang();
        $strReturn = "";

        $strReturn .= $objToolkit->listHeader();

        $objRemoteloader = new class_remoteloader();
        $objRemoteloader->setStrHost($this->STR_BROWSE_HOST);
        $objRemoteloader->setStrQueryParams($this->STR_BROWSE_URL."&start=".$intStart."&end=".$intEnd."&type=".$intType."&domain=".urlencode(_webpath_));

        $strResponse = "";
        try {
            $strResponse = $objRemoteloader->getRemoteContent();
        }
        catch (class_exception $objEx) {
            return $objLang->getLang("package_remote_errorloading", "packagemanager");
        }

        $arrResponse = json_decode($strResponse, true);

        $remoteParser = class_module_packagemanager_remoteparser_factory::getRemoteParser($arrResponse,
            $this->getPageNumber(), $intStart, $intEnd, $this->STR_PROVIDER_NAME);

        $arrPackages = $remoteParser->getArrPackages();
        if($arrPackages == null)
            throw new class_exception("Failed to load remote-packages:  ".strip_tags($strResponse), class_exception::$level_ERROR);

        if(count($arrPackages) == 0)
            $strReturn .= $this->objToolkit->getTextRow($this->getLang("commons_list_empty"));

        $intI = 0;
        foreach($arrPackages as $arrOnePackage) {
            $strAction = $objToolkit->listButton(
                getLinkAdmin(
                    "packagemanager",
                    "uploadPackage",
                    "provider=".get_class($this)."&systemid=".$arrOnePackage["systemid"],
                    $objLang->getLang("package_install", "packagemanager"),
                    $objLang->getLang("package_install", "packagemanager"),
                    "icon_downloads.png"
                )
            );


            $strIcon = "icon_module.png";
            if($arrOnePackage["type"] == "TEMPLATE")
                $strIcon = "icon_dot.png";
<commit_msg>BUG: Now properly showing message "no items found" if content provider returns no packages.<commit_after><?php
/*"******************************************************************************************************
*   (c) 2007-2012 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
*-------------------------------------------------------------------------------------------------------*
*	$Id$                                  *
********************************************************************************************************/

/**
 * A content-provider used to upload archives from remote repositories.
 * Provides both, a search and a download-part.
 *
 * This implementation allows usage for various remote repositories. The access details are specified
 * using the constructor.
 *
 * Remote repositories are expected to provide packages using the packageserver module.
 *
 * @module module_packagemanager
 * @author <EMAIL>
 * @author <EMAIL>
 * @since 4.0
 */
abstract class class_module_packagemanager_contentprovider_remote_base implements interface_packagemanager_contentprovider {

    private $STR_BROWSE_HOST = "";
    private $STR_BROWSE_URL = "";
    private $STR_SEARCH_URL = "";
    private $STR_DOWNLOAD_URL = "";
    private $STR_PROVIDER_NAME;

    function __construct($strProviderName, $strBrowseHost, $strBrowseUrl, $strSearchUrl, $strDownloadUrl) {
        $this->STR_PROVIDER_NAME = $strProviderName;
        $this->STR_BROWSE_HOST = $strBrowseHost;
        $this->STR_BROWSE_URL = $strBrowseUrl;
        $this->STR_SEARCH_URL = $strSearchUrl;
        $this->STR_DOWNLOAD_URL = $strDownloadUrl;
    }


    /**
     * Returns the name of the current provider, in most cases used to select the provider.
     *
     * @return mixed
     */
    public function getDisplayTitle() {
        return class_carrier::getInstance()->getObjLang()->getLang($this->STR_PROVIDER_NAME, "packagemanager");
    }

    /**
     * Renders the list of available packages or any other kind of gui-representation
     * of the packageprovider.
     *
     * Whenever the provider is capable of uploading new packages, the copy & and upload process
     * should be triggered by the admin-class again.
     * So make sure links or forms point to
     * module = packagemanager
     * action = uploadPackage
     * provider = class_name
     * The provider will be called using the processPackageUpload method.
     *
     * @throws class_exception
     * @return string
     */
    public function renderPackageList() {
        $intStart = ($this->getPageNumber() - 1) * _admin_nr_of_rows_;
        $intEnd = $intStart + _admin_nr_of_rows_ - 1;
        $intType = 0;

        $objToolkit = class_carrier::getInstance()->getObjToolkit("admin");
        $objLang = class_carrier::getInstance()->getObjLang();
        $strReturn = "";

        $strReturn .= $objToolkit->listHeader();

        $objRemoteloader = new class_remoteloader();
        $objRemoteloader->setStrHost($this->STR_BROWSE_HOST);
        $objRemoteloader->setStrQueryParams($this->STR_BROWSE_URL."&start=".$intStart."&end=".$intEnd."&type=".$intType."&domain=".urlencode(_webpath_));

        $strResponse = "";
        try {
            $strResponse = $objRemoteloader->getRemoteContent();
        }
        catch (class_exception $objEx) {
            return $objLang->getLang("package_remote_errorloading", "packagemanager");
        }

        $arrResponse = json_decode($strResponse, true);

        $remoteParser = class_module_packagemanager_remoteparser_factory::getRemoteParser($arrResponse,
            $this->getPageNumber(), $intStart, $intEnd, $this->STR_PROVIDER_NAME);

        $arrPackages = $remoteParser->getArrPackages();
        if($arrPackages == null) {
            $arrPackages = array();
        }

        if(count($arrPackages) == 0)
            $strReturn .= $objToolkit->getTextRow($objLang->getLang("commons_list_empty", null));

        $intI = 0;
        foreach($arrPackages as $arrOnePackage) {
            $strAction = $objToolkit->listButton(
                getLinkAdmin(
                    "packagemanager",
                    "uploadPackage",
                    "provider=".get_class($this)."&systemid=".$arrOnePackage["systemid"],
                    $objLang->getLang("package_install", "packagemanager"),
                    $objLang->getLang("package_install", "packagemanager"),
                    "icon_downloads.png"
                )
            );


            $strIcon = "icon_module.png";
            if($arrOnePackage["type"] == "TEMPLATE")
                $strIcon = "icon_dot.png";

{'fraction_non_alphanumeric': 0.17171929088429666, 'fraction_numerical': 0.0035665582712682263, 'mean_word_length': 2.516783474732571, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5048097', 'n_tokens_mistral': 2653, 'n_tokens_neox': 2525, 'n_words': 538}