<commit_before><?php
/**
 * conjoon
 * (c) 2002-2009 siteartwork.de/conjoon.org
 * <EMAIL>
 *
 * $Author$
 * $Id$
 * $Date$
 * $Revision$
 * $LastChangedDate$
 * $LastChangedBy$
 * $URL$
 */

/**
 * Utility class for access to functionaly related to importing
 * feed items.
 *
 * @author <NAME> <<EMAIL>>
 */
class Conjoon_Modules_Groupware_Feeds_ImportHelper {


    private function __construct()
    {
    }

    private function __clone()
    {
    }

// -------- public api

    /**
     * Checks whether a given uri points to an rss feed resource.
     *
     * @param string $uri
     *
     * @return boolean true if a rss feed was found, otherwise false.
     */
    public static function isFeedAddressValid($uri)
    {
        /**
         * @see Zend_Feed
         */
        require_once 'Zend/Feed.php';

        try {
            Zend_Feed::import($uri);
            return true;
        } catch (Zend_Feed_Exception $e) {
            // ignore, we failed here
        }

        return false;
    }

    /**
     * Parses all feed items for their values and returns an associative
     * array with their normalized values, along with the accountId specified.
     *
     * @param array Zend_Feed_Reader_Feed_Interface
     * @param integer $accountId
     *
     * @return array
     */
    public static function parseFeedItems($import, $accountId)
    {
        /**
         * @see Conjoon_Util_Array
         */
        require_once 'Conjoon/Util/Array.php';

        /**
         * @see Conjoon_Modules_Groupware_Feeds_Item_Filter_Item
         */
        require_once 'Conjoon/Modules/Groupware/Feeds/Item/Filter/Item.php';

        $data = array();

        foreach ($import as $item) {

            $itemData = array();
            $itemData['groupwareFeedsAccountsId'] = $accountId;

            $itemData['title'] = $item->getTitle();

            // author
            $itemData['author']      = $item->getAuthor();
            $itemData['authorUri']   = "";//$item->getAuthor(0);
            $itemData['authorEmail'] = "";//$item->getAuthor(0);

             // description
            $itemData['description'] = $item->getDescription();
            if (!$itemData['description']) {
                $itemData['description'] = $itemData['title'];
            }

            // content
            $itemData['content'] = $item->getContent();

            // link
            $itemData['link'] = $item->getLink();

            // guid
            $itemData['guid'] = $item->getId();

            // pubDate
            $itemData['pubDate'] = $item->getDateModified()->getTimestamp();

            $itemData['savedTimestamp'] = time();

            $filter = new Conjoon_Modules_Groupware_Feeds_Item_Filter_Item(
                $itemData,
                Conjoon_Filter_Input::CONTEXT_CREATE
            );
            $fillIn = $filter->getProcessedData();
            Conjoon_Util_Array::underscoreKeys($fillIn);
            $data[] = $fillIn;
        }

        return $data;
    }


// -------- api



}<commit_msg> - enhancement: added fallback if field "content" would be empty<commit_after><?php
/**
 * conjoon
 * (c) 2002-2009 siteartwork.de/conjoon.org
 * <EMAIL>
 *
 * $Author$
 * $Id$
 * $Date$
 * $Revision$
 * $LastChangedDate$
 * $LastChangedBy$
 * $URL$
 */

/**
 * Utility class for access to functionaly related to importing
 * feed items.
 *
 * @author <NAME> <<EMAIL>>
 */
class Conjoon_Modules_Groupware_Feeds_ImportHelper {


    private function __construct()
    {
    }

    private function __clone()
    {
    }

// -------- public api

    /**
     * Checks whether a given uri points to an rss feed resource.
     *
     * @param string $uri
     *
     * @return boolean true if a rss feed was found, otherwise false.
     */
    public static function isFeedAddressValid($uri)
    {
        /**
         * @see Zend_Feed
         */
        require_once 'Zend/Feed.php';

        try {
            Zend_Feed::import($uri);
            return true;
        } catch (Zend_Feed_Exception $e) {
            // ignore, we failed here
        }

        return false;
    }

    /**
     * Parses all feed items for their values and returns an associative
     * array with their normalized values, along with the accountId specified.
     *
     * @param array Zend_Feed_Reader_Feed_Interface
     * @param integer $accountId
     *
     * @return array
     */
    public static function parseFeedItems($import, $accountId)
    {
        /**
         * @see Conjoon_Util_Array
         */
        require_once 'Conjoon/Util/Array.php';

        /**
         * @see Conjoon_Modules_Groupware_Feeds_Item_Filter_Item
         */
        require_once 'Conjoon/Modules/Groupware/Feeds/Item/Filter/Item.php';

        $data = array();

        foreach ($import as $item) {

            $itemData = array();
            $itemData['groupwareFeedsAccountsId'] = $accountId;

            $itemData['title'] = $item->getTitle();

            // author
            $itemData['author']      = $item->getAuthor();
            $itemData['authorUri']   = "";//$item->getAuthor(0);
            $itemData['authorEmail'] = "";//$item->getAuthor(0);

             // description
            $itemData['description'] = $item->getDescription();
            if (!$itemData['description']) {
                $itemData['description'] = $itemData['title'];
            }

            // content
            $itemData['content'] = $item->getContent();
            if (!$itemData['content']) {
                $itemData['content'] = $itemData['description'];
            }

            // link
            $itemData['link'] = $item->getLink();

            // guid
            $itemData['guid'] = $item->getId();

            // pubDate
            $itemData['pubDate'] = $item->getDateModified()->getTimestamp();

            $itemData['savedTimestamp'] = time();

            $filter = new Conjoon_Modules_Groupware_Feeds_Item_Filter_Item(
                $itemData,
                Conjoon_Filter_Input::CONTEXT_CREATE
            );
            $fillIn = $filter->getProcessedData();
            Conjoon_Util_Array::underscoreKeys($fillIn);
            $data[] = $fillIn;
        }

        return $data;
    }


// -------- api



}
{'fraction_non_alphanumeric': 0.13151440833844266, 'fraction_numerical': 0.0030656039239730227, 'mean_word_length': 1.628928283642224, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '377291', 'n_tokens_mistral': 1990, 'n_tokens_neox': 1793, 'n_words': 369}