Skip to content
Permalink
01ce3fbff7
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
127 lines (110 sloc) 4 KB
<?php
/*
* COmanage Match Breadcrumbs
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link http://www.internet2.edu/comanage COmanage Project
* @package match
* @since COmanage Match v1.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/
use \Cake\Utility\Inflector;
if($this->request->getRequestTarget(false) != '/') {
// Don't bother rendering breadcrumbs if we're already at the top page
$action = $this->template;
// $this->name = Models
$modelsName = $this->name;
$this->Breadcrumbs->setTemplates([
'wrapper' => '{{content}}',
'item' => '<a href="{{url}}"{{innerAttrs}}>{{title}}</a>{{separator}}',
'itemWithoutLink' => '<span{{innerAttrs}}>{{title}}</span>{{separator}}',
'separator' => '<span{{innerAttrs}}>{{separator}}</span>'
]);
$this->Breadcrumbs->prepend(
__('match.meta.match'),
['controller' => 'matchgrids',
'action' => 'select']
);
if(!empty($vv_cur_mg)
&& ($modelsName != 'Matchgrids' || $action != 'manage')) {
// Link to matchgrid if set
$this->Breadcrumbs->add(
$vv_cur_mg->table_name,
['controller' => 'matchgrids',
'action' => 'manage',
$vv_cur_mg->id ]
);
}
if(!empty($vv_primary_link_obj)
&& !empty($vv_primary_link_model)
&& $vv_primary_link_model != 'Matchgrids') {
// If the primary link is not matchgrid, render a link to it (and the parent index).
// We'll need to calculate the controller name.
if(!empty($vv_cur_mg->id)) {
// We currently assume the parent of a primary link is matchgrid, which
// might or might not always be true in the future.
$this->Breadcrumbs->add(
__('match.ct.'.$vv_primary_link_model, [99]),
['controller' => \Cake\Utility\Inflector::dasherize($vv_primary_link_model),
'action' => 'index',
'matchgrid_id' => $vv_cur_mg->id]
);
}
$this->Breadcrumbs->add(
$vv_primary_link_obj->name,
['controller' => \Cake\Utility\Inflector::dasherize($vv_primary_link_model),
'action' => 'edit',
$vv_primary_link_obj->id]
);
}
if($action != 'index' && $action != 'manage'
&& !($modelsName == 'Matchgrids' && $action == 'pending')) {
// Default parent is index, to which we might need to append the Primary Link ID
$crumbLinkText = 'match.ct.'.$modelsName;
$target = [
'controller' => Inflector::dasherize($modelsName),
'action' => 'index'
];
if(!empty($vv_primary_link) && !empty($vv_primary_link_obj->id)) {
$target[$vv_primary_link] = $vv_primary_link_obj->id;
}
// Non-index special cases
if ($modelsName == 'Matchgrids' && $action == 'reconcile') {
$crumbLinkText = 'match.ac.PendingRequests';
$target = [
'controller' => Inflector::dasherize($modelsName),
'action' => 'pending',
$vv_cur_mg->id // will always be set for reconcile
];
}
$this->Breadcrumbs->add(
__($crumbLinkText, [99]),
$target
);
}
if(!empty($vv_title)) {
$this->Breadcrumbs->add(
$vv_title
);
}
print $this->Breadcrumbs->render(
[],
['separator' => ' &gt; ']
);
}