<commit_before><?php

/**
 * schemahistory actions.
 *
 * @package    registry
 * @subpackage schemahistory
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id: actions.class.php 2288 2006-10-02 15:22:13Z fabien $
 */
class schemahistoryActions extends autoschemahistoryActions
{
  public function executeFeed()
  {
    /** @var sfWebRequest **/
    $request = $this->getContext()->getRequest();
    $IdType = $this->getRequestParameter('IdType', null);
    $id = $this->getRequestParameter('id', null);

    //Build the title
    $title = "Metadata Registry Change History";
    $filter = false;

    switch ($IdType)
    {
      //ElementSet :: (Schema)Element  :: (Schema)ElementProperty
      //Schema     :: SchemaProperty :: SchemaPropertyElement
      case "schema_property_element_id":
        /** @var SchemaPropertyElement **/
        $element = DbFinder::from('SchemaPropertyElement')->findPk($id);
        if ($element)
        {
          /** @var SchemaProperty **/
          $property = $element->getSchemaPropertyRelatedBySchemaPropertyId();
          $title .= " for Property: '" .    $element->getProfileProperty()->getLabel();
          if ($property)
          {
            $title .= "' of Element: '" .     $property->getLabel() .
                      "' in Element Set: '" . $property->getSchema()->getName() . "'";
          }
        }
        $filter = true;
        break;
      case "schema_property_id":
        /** @var SchemaProperty **/
        $property = DbFinder::from('SchemaProperty')->findPk($id);
        if ($property)
        {
          $title .= " for Element: '" .     $property->getLabel() .
                    "' in Element Set: '" . $property->getSchema()->getName() . "'";
        }
        $filter = true;
        break;
      case "schema_id":
        /** @var Schema **/
        $schema = DbFinder::from('Schema')->findPk($id);
        if ($schema)
        {
          $title .= " for Element Set: '" . $schema->getName() . "'";
        }
        $filter = true;
        break;
      default: //the whole shebang
        $title .= " for all Element Sets";
        break;
    }

    $column = sfInflector::camelize($IdType);

    //default limit to 100 if not set in config
    $limit = $request->getParameter('nb', sfConfig::get('app_frontend_feed_count', 100));

    $finder = DbFinder::from('SchemaPropertyElementHistory')
      ->orderBy('SchemaPropertyElementHistory.CreatedAt', 'desc')
      ->join('SchemaPropertyElementHistory.SchemaPropertyElementId', 'SchemaPropertyElement.Id', 'left join')
      ->join('SchemaProperty','left join')
      ->join('Schema','left join')
      ->join('Status','left join')
      ->join('User','left join')
      ->join('ProfileProperty','left join')
      ->with('Schema','ProfileProperty','User','Status','SchemaProperty');

    if ($filter)
    {
      $finder = $finder->where('SchemaPropertyElementHistory.'.$column,$id);
    }

    $finder = $finder->find($limit);

    $this->setTemplate('feed');
    $this->feed = sfFeedPeer::createFromObjects(
      $finder,
      array(
        'format'      => $request->getParameter('format', 'atom1'),
        'link'        => $request->getUriPrefix() . $request->getPathInfo(),
        'feedUrl'     => $request->getUriPrefix() . $request->getPathInfo(),
        'title'       => htmlentities($title),
        'methods'     => array('authorEmail' => '', 'link' => 'getFeedUniqueId')
      )
    );

    return;
  }
  public function executeList ()
  {
    $idType = $this->getRequestParameter('IdType', null);
    $id = $this->getRequestParameter('id', null);

    if(!$idType)
    {
      //a current schema is required to be in the request URL
      myActionTools::requireSchemaFilter();
    }
    else
    {
      $this->getRequest()->getParameterHolder()->set($idType, $id);
    }

    $schema = myActionTools::findCurrentSchema();
    if ($schema)
    {
      $this->schema = $schema;
      $schemaId = $schema->getId();
    }

    if (in_array($idType, array('schema_property_id','schema_property_element_id')))
    {
      $this->property = myActionTools::findCurrentSchemaProperty();
      $this->setFlash('hasProperty', true);
      $schemaId = $this->property->getSchemaId();
    }

    //get the versions array
    $c = new Criteria();
    $c->add(SchemaHasVersionPeer::SCHEMA_ID, $schemaId);
    $versions = SchemaHasVersionPeer::doSelect($c);
    $this->setFlash('versions', $versions);

    parent::executeList();
<commit_msg>add check for existence of property<commit_after><?php

/**
* schemahistory actions.
*
* @package    registry
* @subpackage schemahistory
* @author     <NAME> <<EMAIL>>
* @version    SVN: $Id: actions.class.php 2288 2006-10-02 15:22:13Z fabien $
*/
class schemahistoryActions extends autoschemahistoryActions
{
  public function executeFeed()
  {
    /** @var sfWebRequest **/
    $request = $this->getContext()->getRequest();
    $IdType = $this->getRequestParameter('IdType', null);
    $id = $this->getRequestParameter('id', null);

    //Build the title
    $title = "Metadata Registry Change History";
    $filter = false;

    switch ($IdType)
    {
      //ElementSet :: (Schema)Element  :: (Schema)ElementProperty
      //Schema     :: SchemaProperty :: SchemaPropertyElement
      case "schema_property_element_id":
        /** @var SchemaPropertyElement **/
        $element = DbFinder::from('SchemaPropertyElement')->findPk($id);
        if ($element)
        {
          /** @var SchemaProperty **/
          $property = $element->getSchemaPropertyRelatedBySchemaPropertyId();
          $title .= " for Property: '" .    $element->getProfileProperty()->getLabel();
          if ($property)
          {
            $title .= "' of Element: '" .     $property->getLabel() .
                      "' in Element Set: '" . $property->getSchema()->getName() . "'";
          }
        }
        $filter = true;
        break;
      case "schema_property_id":
        /** @var SchemaProperty **/
        $property = DbFinder::from('SchemaProperty')->findPk($id);
        if ($property)
        {
          $title .= " for Element: '" .     $property->getLabel() .
                    "' in Element Set: '" . $property->getSchema()->getName() . "'";
        }
        $filter = true;
        break;
      case "schema_id":
        /** @var Schema **/
        $schema = DbFinder::from('Schema')->findPk($id);
        if ($schema)
        {
          $title .= " for Element Set: '" . $schema->getName() . "'";
        }
        $filter = true;
        break;
      default: //the whole shebang
        $title .= " for all Element Sets";
        break;
    }

    $column = sfInflector::camelize($IdType);

    //default limit to 100 if not set in config
    $limit = $request->getParameter('nb', sfConfig::get('app_frontend_feed_count', 100));

    $finder = DbFinder::from('SchemaPropertyElementHistory')
      ->orderBy('SchemaPropertyElementHistory.CreatedAt', 'desc')
      ->join('SchemaPropertyElementHistory.SchemaPropertyElementId', 'SchemaPropertyElement.Id', 'left join')
      ->join('SchemaProperty','left join')
      ->join('Schema','left join')
      ->join('Status','left join')
      ->join('User','left join')
      ->join('ProfileProperty','left join')
      ->with('Schema','ProfileProperty','User','Status','SchemaProperty');

    if ($filter)
    {
      $finder = $finder->where('SchemaPropertyElementHistory.'.$column,$id);
    }

    $finder = $finder->find($limit);

    $this->setTemplate('feed');
    $this->feed = sfFeedPeer::createFromObjects(
      $finder,
      array(
        'format'      => $request->getParameter('format', 'atom1'),
        'link'        => $request->getUriPrefix() . $request->getPathInfo(),
        'feedUrl'     => $request->getUriPrefix() . $request->getPathInfo(),
        'title'       => htmlentities($title),
        'methods'     => array('authorEmail' => '', 'link' => 'getFeedUniqueId')
      )
    );

    return;
  }
  public function executeList ()
  {
    $idType = $this->getRequestParameter('IdType', null);
    $id = $this->getRequestParameter('id', null);

    if(!$idType)
    {
      //a current schema is required to be in the request URL
      myActionTools::requireSchemaFilter();
    }
    else
    {
      $this->getRequest()->getParameterHolder()->set($idType, $id);
    }

    $schema = myActionTools::findCurrentSchema();
    if ($schema)
    {
      $this->schema = $schema;
      $schemaId = $schema->getId();
    }

    if (in_array($idType, array('schema_property_id','schema_property_element_id')))
    {
      $property = myActionTools::findCurrentSchemaProperty();
      if ($property)
      {
        $this->property = $property;
        $this->setFlash('hasProperty', true);
        $schemaId = $this->property->getSchemaId();
      }
    }

    //get the versions array
    $c = new Criteria();
    $c->add(SchemaHasVersionPeer::SCHEMA_ID, $schemaId);
    $versions = SchemaHasVersionPeer::doSelect($c);
    $this->setFlash('versions', $versions);

    parent::executeList();

{'fraction_non_alphanumeric': 0.16948216848846195, 'fraction_numerical': 0.005520591807441758, 'mean_word_length': 2.6145251396648046, 'pattern_counts': {'":': 6, '<': 11, '<?xml version=': 0, '>': 119, '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': '4938424', 'n_tokens_mistral': 2660, 'n_tokens_neox': 2595, 'n_words': 497}