<commit_before><?php
/**
 * routes module actions.
 *
 * @package    c2corg
 * @subpackage routes
 * @version    $Id: actions.class.php 2526 2007-12-18 23:25:31Z alex $
 */
class routesActions extends documentsActions
{
    /**
     * Model class name.
     */
    protected $model_class = 'Route';
    
    /**
     * Executes view action.
     */
    public function executeView()
    {
        parent::executeView();
        
        $this->associated_summits = c2cTools::sortArrayByName(array_filter($this->associated_docs, array('c2cTools', 'is_summit'))); 
        
        $this->associated_huts = array_filter($this->associated_docs, array('c2cTools', 'is_hut'));
        $this->associated_parkings = array_filter($this->associated_docs, array('c2cTools', 'is_parking'));
        
        $associated_outings = Outing::fetchAdditionalFields(array_filter($this->associated_docs,
                                                                         array('c2cTools', 'is_outing')));
        // sort outings array by antichronological order.
        usort($associated_outings, array('c2cTools', 'cmpDate'));
        $this->associated_outings = $associated_outings;

        // extract highest associated summit, and prepend its name to display this route's name.
        $this->highest_summit_name = c2cTools::extractHighestName($this->associated_summits);
        // redefine page title: prepend summit name
        $this->setPageTitle($this->__('route') . ' :: ' . $this->highest_summit_name
                            . $this->__(' :') . ' ' . $this->document->get('name'));
    }

    public function executeHistory()
    {
        parent::executeHistory();
        $this->title_prefix = $this->getHighestSummitName();
        // redefine page title: prepend summit name
        $this->setPageTitle($this->title_prefix . $this->__(' :') . ' ' . $this->document_name . ' :: ' . $this->__('history'));
    }

    public function setEditFormInformation()
    {
        parent::setEditFormInformation();
        $this->title_prefix = $this->getHighestSummitName();
        if (!$this->new_document)
        {
            $this->setPageTitle($this->__('Edition of "%1%"', array('%1%' => $this->title_prefix . $this->__(' :') . ' ' . $this->document->getName())));
        }
    }

    public function executeComment()
    {
        parent::executeComment();
        $this->title_prefix = $this->getHighestSummitName();
        $this->setPageTitle($this->__('Comments') . ' :: ' . $this->title_prefix . $this->__(' :') . ' ' . $this->document_name );
    }

    public function executeDiff()
    {
        parent::executeDiff();
        $this->title_prefix = $this->getHighestSummitName();
        $this->setPageTitle($this->title_prefix . $this->__(' :') . ' ' .
                            $this->new_document->get('name') . ' :: ' . $this->__('diff') . ' ' .
                            $this->getRequestParameter('old') . ' > ' . $this->getRequestParameter('new'));
    }

    protected function getHighestSummitName()
    {
        $id = $this->getRequestParameter('id');
        $user = $this->getUser();
        $prefered_cultures = $user->getCulturesForDocuments();
        $associated_docs = Association::findAllWithBestName($id, $prefered_cultures);
        $associated_summits = c2cTools::sortArrayByName(array_filter($associated_docs, array('c2cTools', 'is_summit')));
        // extract highest associated summit, and prepend its name to display this route's name.
        $highest_summit_name = c2cTools::extractHighestName($associated_summits);<commit_msg>Do not try to get associated summit when creating a new route<commit_after><?php
/**
 * routes module actions.
 *
 * @package    c2corg
 * @subpackage routes
 * @version    $Id: actions.class.php 2526 2007-12-18 23:25:31Z alex $
 */
class routesActions extends documentsActions
{
    /**
     * Model class name.
     */
    protected $model_class = 'Route';
    
    /**
     * Executes view action.
     */
    public function executeView()
    {
        parent::executeView();
        
        $this->associated_summits = c2cTools::sortArrayByName(array_filter($this->associated_docs, array('c2cTools', 'is_summit'))); 
        
        $this->associated_huts = array_filter($this->associated_docs, array('c2cTools', 'is_hut'));
        $this->associated_parkings = array_filter($this->associated_docs, array('c2cTools', 'is_parking'));
        
        $associated_outings = Outing::fetchAdditionalFields(array_filter($this->associated_docs,
                                                                         array('c2cTools', 'is_outing')));
        // sort outings array by antichronological order.
        usort($associated_outings, array('c2cTools', 'cmpDate'));
        $this->associated_outings = $associated_outings;

        // extract highest associated summit, and prepend its name to display this route's name.
        $this->highest_summit_name = c2cTools::extractHighestName($this->associated_summits);
        // redefine page title: prepend summit name
        $this->setPageTitle($this->__('route') . ' :: ' . $this->highest_summit_name
                            . $this->__(' :') . ' ' . $this->document->get('name'));
    }

    public function executeHistory()
    {
        parent::executeHistory();
        $this->title_prefix = $this->getHighestSummitName();
        // redefine page title: prepend summit name
        $this->setPageTitle($this->title_prefix . $this->__(' :') . ' ' . $this->document_name . ' :: ' . $this->__('history'));
    }

    public function setEditFormInformation()
    {
        parent::setEditFormInformation();
        if (!$this->new_document)
        {
            $this->title_prefix = $this->getHighestSummitName();
            $this->setPageTitle($this->__('Edition of "%1%"', array('%1%' => $this->title_prefix . $this->__(' :') . ' ' . $this->document->getName())));
        }
    }

    public function executeComment()
    {
        parent::executeComment();
        $this->title_prefix = $this->getHighestSummitName();
        $this->setPageTitle($this->__('Comments') . ' :: ' . $this->title_prefix . $this->__(' :') . ' ' . $this->document_name );
    }

    public function executeDiff()
    {
        parent::executeDiff();
        $this->title_prefix = $this->getHighestSummitName();
        $this->setPageTitle($this->title_prefix . $this->__(' :') . ' ' .
                            $this->new_document->get('name') . ' :: ' . $this->__('diff') . ' ' .
                            $this->getRequestParameter('old') . ' > ' . $this->getRequestParameter('new'));
    }

    protected function getHighestSummitName()
    {
        $id = $this->getRequestParameter('id');
        $user = $this->getUser();
        $prefered_cultures = $user->getCulturesForDocuments();
        $associated_docs = Association::findAllWithBestName($id, $prefered_cultures);
        $associated_summits = c2cTools::sortArrayByName(array_filter($associated_docs, array('c2cTools', 'is_summit')));
        // extract highest associated summit, and prepend its name to display this route's name.
        $highest_summit_name = c2cTools::extractHighestName($associated_summits);
{'fraction_non_alphanumeric': 0.1578363384188627, 'fraction_numerical': 0.008599167822468794, 'mean_word_length': 2.667853509664293, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 111, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '251633', 'n_tokens_mistral': 2198, 'n_tokens_neox': 2081, 'n_words': 346}