<commit_before><?php

/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */

/**
 * opAPICommunity
 *
 * @package    OpenPNE
 * @subpackage api
 * @author     <NAME> <<EMAIL>>
 */
class opAPICommunity extends opAPI implements opAPIInterface
{
  public function feed()
  {
    $this
      ->addConditionPublished()
      ->addConditionUpdated()
      ->setOrderBy()
      ->setOffsetAndLimitation();

    $communities = $this->getRouteObject()->execute();
    if (!$communities->count())
    {
      return false;
    }

    $feed = $this->getGeneralFeed('Communities', $this->getTotalCount());
    foreach ($communities as $key => $community)
    {
      $entry = $feed->addEntry();
      $this->createEntryByInstance($community, $entry);
    }
    $feed->setUpdated($communities->getFirst()->getCreatedAt());

    return $feed->publish();
  }

  public function entry()
  {
    return $this->getRouteObject()->fetchOne();
  }

  public function insert(SimpleXMLElement $xml)
  {
    $member = Doctrine::getTable('Member')->find($this->getMemberIdByUrl((string)$xml->author->uri));
    if (!$member)
    {
      return false;
    }

    $community = new Community();
    $community->setName((string)$xml->title);
    $community->save();

    $admin = new CommunityMember();
    $admin->setPosition('admin');
    $admin->setMember($member);
    $admin->setCommunity($community);
    $admin->save();

    $config = new CommunityConfig();
    $config->setName('description');
    $config->setValue((string)$xml->content);
    $config->setCommunity($community);
    $config->save();

    return $community;
  }

  public function update(SimpleXMLElement $xml)
  {
    return false;
  }

  public function delete()<commit_msg>added the api for updating community entry<commit_after><?php

/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */

/**
 * opAPICommunity
 *
 * @package    OpenPNE
 * @subpackage api
 * @author     <NAME> <<EMAIL>>
 */
class opAPICommunity extends opAPI implements opAPIInterface
{
  public function feed()
  {
    $this
      ->addConditionPublished()
      ->addConditionUpdated()
      ->setOrderBy()
      ->setOffsetAndLimitation();

    $communities = $this->getRouteObject()->execute();
    if (!$communities->count())
    {
      return false;
    }

    $feed = $this->getGeneralFeed('Communities', $this->getTotalCount());
    foreach ($communities as $key => $community)
    {
      $entry = $feed->addEntry();
      $this->createEntryByInstance($community, $entry);
    }
    $feed->setUpdated($communities->getFirst()->getCreatedAt());

    return $feed->publish();
  }

  public function entry()
  {
    return $this->getRouteObject()->fetchOne();
  }

  public function insert(SimpleXMLElement $xml)
  {
    $member = Doctrine::getTable('Member')->find($this->getMemberIdByUrl((string)$xml->author->uri));
    if (!$member)
    {
      return false;
    }

    $community = new Community();
    $community->setName((string)$xml->title);
    $community->save();

    $admin = new CommunityMember();
    $admin->setPosition('admin');
    $admin->setMember($member);
    $admin->setCommunity($community);
    $admin->save();

    $config = new CommunityConfig();
    $config->setName('description');
    $config->setValue((string)$xml->content);
    $config->setCommunity($community);
    $config->save();

    return $community;
  }

  public function update(SimpleXMLElement $xml)
  {
    $community = $this->getRouteObject()->fetchOne();
    if (!$community)
    {
      return false;
    }

    $community->setName((string)$xml->title);
    $community->save();

    $config = Doctrine::getTable('CommunityConfig')->retrieveByNameAndCommunityId('description', $community->getId());
    $config->setValue((string)$xml->content);
    $config->save();

    return $community;
  }

  public function delete()
{'fraction_non_alphanumeric': 0.1635205285512034, 'fraction_numerical': 0.0, 'mean_word_length': 3.4762407602956706, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 12}, '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': '950059', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1244, 'n_words': 266}