Exemplo n.º 1
0
 function test_clean()
 {
     $bread_crumb = new BreadCrumb();
     $ret = $bread_crumb->clean();
     $tmp = $bread_crumb->get_links();
     self::assertEquals(count($tmp), 0);
 }
 public function transform(BreadCrumb $breadCrumb)
 {
     $result = $breadCrumb->getRoot();
     $isFirst = true;
     foreach ($breadCrumb->getNodes() as $node) {
         if ($isFirst) {
             $isFirst = false;
             if ($breadCrumb->getDepth() > 1) {
                 $result .= "/" . $node->getPropertyName();
             }
             continue;
         }
         $result .= "/" . $node->getTemplateName();
         if ($node->getTemplateIndex() != 0) {
             $result .= "/" . $node->getTemplateIndex();
         }
     }
     return $result;
 }
Exemplo n.º 3
0
     }
     if ($cf->isValid()) {
         $cf->Save();
         //$cf->FailTransaction();
         $cf->CommitTransaction();
         if ($permission->Check('company', 'edit')) {
             Redirect::Page(URLBuilder::getURL(NULL, 'CompanyList.php'));
         } else {
             Redirect::Page(URLBuilder::getURL(NULL, '../index.php'));
         }
         break;
     }
     $cf->FailTransaction();
 default:
     if (isset($id)) {
         BreadCrumb::setCrumb($title);
         $clf = new CompanyListFactory();
         if ($permission->Check('company', 'edit')) {
             $clf->GetByID($id);
         } else {
             $id = $current_company->getId();
             $clf->GetByID($id);
         }
         foreach ($clf as $company) {
             //Debug::Arr($company,'Company', __FILE__, __LINE__, __METHOD__,10);
             $company_data = array('id' => $company->getId(), 'parent' => $company->getParent(), 'status' => $company->getStatus(), 'product_edition' => $company->getProductEdition(), 'name' => $company->getName(), 'short_name' => $company->getShortName(), 'business_number' => $company->getBusinessNumber(), 'originator_id' => $company->getOriginatorID(), 'data_center_id' => $company->getDataCenterID(), 'address1' => $company->getAddress1(), 'address2' => $company->getAddress2(), 'city' => $company->getCity(), 'province' => $company->getProvince(), 'country' => $company->getCountry(), 'postal_code' => $company->getPostalCode(), 'work_phone' => $company->getWorkPhone(), 'fax_phone' => $company->getFaxPhone(), 'admin_contact' => $company->getAdminContact(), 'billing_contact' => $company->getBillingContact(), 'support_contact' => $company->getSupportContact(), 'logo_file_name' => $company->getLogoFileName(NULL, FALSE), 'enable_second_last_name' => $company->getEnableSecondLastName(), 'created_date' => $company->getCreatedDate(), 'created_by' => $company->getCreatedBy(), 'updated_date' => $company->getUpdatedDate(), 'updated_by' => $company->getUpdatedBy(), 'deleted_date' => $company->getDeletedDate(), 'deleted_by' => $company->getDeletedBy());
         }
     }
     //Select box options;
     $company_data['status_options'] = $cf->getOptions('status');
     $company_data['country_options'] = $cf->getOptions('country');
Exemplo n.º 4
0
 * $Revision: 7487 $
 * $Id: ViewScheduleWeek.php 7487 2012-08-15 22:35:09Z ipso $
 * $Date: 2012-08-15 15:35:09 -0700 (Wed, 15 Aug 2012) $
 */
require_once '../../includes/global.inc.php';
require_once Environment::getBasePath() . 'includes/Interface.inc.php';
require_once Environment::getBasePath() . 'classes/misc/arr_multisort.class.php';
//Debug::setVerbosity(11);
if (!$permission->Check('schedule', 'enabled') or !($permission->Check('schedule', 'view') or $permission->Check('schedule', 'view_own') or $permission->Check('schedule', 'view_child'))) {
    $permission->Redirect(FALSE);
    //Redirect
}
$smarty->assign('title', TTi18n::gettext($title = 'My Schedule'));
// See index.php
//BreadCrumb::setCrumb($title);
BreadCrumb::setCrumb($title, str_replace('ViewScheduleWeek.php', 'ViewSchedule.php', $_SERVER['REQUEST_URI']));
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('do', 'page', 'sort_column', 'sort_order', 'filter_data')));
URLBuilder::setURL($_SERVER['SCRIPT_NAME'], array('sort_column' => $sort_column, 'sort_order' => $sort_order, 'page' => $page));
if (isset($filter_data['start_date']) and $filter_data['start_date'] != '') {
    $filter_data['start_date'] = TTDate::parseDateTime($filter_data['start_date']);
} else {
    $filter_data['start_date'] = time();
}
if (!isset($filter_data['show_days']) or isset($filter_data['show_days']) and $filter_data['show_days'] == '') {
    $filter_data['show_days'] = 1;
}
$filter_data['show_days'] = $filter_data['show_days'] * 7;
//Get Permission Hierarchy Children first, as this can be used for viewing, or editing.
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_function_DisplayBreadCrumbs($params, &$smarty)
{
    return BreadCrumb::Display();
}
Exemplo n.º 6
0
 /**
  * This function returns two results:
  * [triples: the generated triples, metaTriples: meta triples 2: the used templates]
  *
  * Unfortunately I haven't renamed the variables yet - result
  * is the array containing the result TRIPLES!! - its not this
  * 2 element.
  *
  */
 private function myGenerate(BreadCrumb $breadCrumb, $value)
 {
     // result is the array containing: triples, meta triples, used templates
     $result = array(array(), array(), array());
     $rootSubjectUri = RDFTriple::page($breadCrumb->getRoot());
     // this array is only relevant on depth 0
     $relatedClasses = array();
     //$metaTriples = array();
     //$usedTemplateNames = array();
     // 'parent' means the parent of the value - thus subject and predicate
     $parentName = $this->breadCrumbTransformer->transform($breadCrumb);
     $parentResource = RDFTriple::page($parentName);
     $parentPropertyName = null;
     $tmp = $breadCrumb->peekTop(0);
     if (isset($tmp)) {
         $parentPropertyName = $tmp->getPropertyName();
     }
     // Get all templates on this site, indexed by name
     // (there may be multiple templates with the same name)
     $nameToTemplates = SimpleWikiTemplateMatcher::match($value);
     //print_r($value);
     //print_r($nameToTemplates);
     //echo "NOW COMES THE STORM\n";
     foreach ($nameToTemplates as $templateName => $templates) {
         if (strlen($templateName) < 1) {
             continue;
         }
         //echo "GOT TEMPLATE NAME $templateName\n";
         $templateName = $this->mediaWikiUtil->toCanonicalWikiCase($templateName);
         if (!$this->templateNameFilter->doesAccept($templateName)) {
             continue;
         }
         $templateUri = RDFTriple::URI(DB_TEMPLATE_NS . $templateName, false);
         $result[2][$templateName] = 1;
         // Get annotations for the template - if there are any
         $lookupName = "Template:{$templateName}/doc";
         if ($breadCrumb->getDepth() == 0) {
             $ta = $this->templateDb->getTemplateAnnotation($lookupName);
             // Create the triples for "relatesToClass"
             // But only for the page itself (not for sub templates)
             // if no related class exists, default to rdf:type owl:Thing
             if (isset($ta)) {
                 foreach ($ta->getRelatedClasses() as $item) {
                     $relatedClasses[$item] = 1;
                 }
             }
         }
         foreach ($templates as $templateIndex => $template) {
             //echo "GOT TEMPLATE INDEX $templateIndex\n";
             // Iterate over all arguments
             $arguments = $template->getArguments();
             foreach ($arguments as $argumentName => $values) {
                 //echo "GOT ARGUMENT NAME $argumentName\n";
                 // propertyNs defaults to DB_PROPERTY_NS unless there
                 // exists a mapping in the templatedb. In that case it will
                 // be set to DB_ONTOLOGY_NS
                 $propertyNs = DB_PROPERTY_NS;
                 $pa = null;
                 if (isset($ta)) {
                     $pas = $ta->getPropertyAnnotations();
                     if (array_key_exists($argumentName, $pas)) {
                         $pa = $pas[$argumentName];
                         $propertyNs = DB_ONTOLOGY_NS;
                     }
                 }
                 //print_r($ta);
                 //echo "PROPERTY NS : $lookupName - $argumentName = $propertyNs\n";
                 // Fake a property mapping if there was none in the db
                 // This maps argumentName back to iteself
                 if (!isset($pa)) {
                     // If there was no mapping we might ignore it
                     // depending on an option (We can prevent this extractor
                     // to generate triples with properties in the
                     // dbp:property namespace
                     // We allow such triples on subResources though.
                     if ($this->allowUnmappedProperties != true && $breadCrumb->getDepth() == 0) {
                         continue;
                     }
                     // If there was no mapping, also rename numeric
                     // argument names (e.g. 1 becomes property1)
                     // this is just cosmetic for the result
                     if (is_numeric($argumentName)) {
                         $argumentName = "property{$argumentName}";
                     }
                     $pa = new PropertyAnnotation($argumentName);
                     $pa->addMapping(new PropertyMapping($argumentName));
                 }
                 foreach ($pa->getMappings() as $pm) {
                     $parseHint = $pm->getParseHint();
                     //echo "Mapping $argumentName : {$pm->getRenamedValue()}\n\n";
                     // if the renamed value is not set, use the original
                     // name
                     // otherwise use the mapped value
                     if (!isEmptyString($pm->getRenamedValue())) {
                         $argumentName = $pm->getRenamedValue();
                     }
                     $argumentName = trim($argumentName);
                     //echo "Mapping $argumentName : {$pm->getRenamedValue()}\n\n";
                     // Skip empty properties
                     // FIXME does that even happen?
                     if (strlen($argumentName) < 1) {
                         continue;
                     }
                     //echo "TN = $templateName, AN = $argumentName\n";
                     $childBreadcrumb = $breadCrumb->createClone();
                     $childBreadcrumb->push(new BreadcrumbNode($templateName, $templateIndex, $argumentName));
                     //$templateChildName = $this->breadcrumbToSubject($childBreadcrumb);
                     $templateChildName = $this->breadCrumbTransformer->transform($childBreadcrumb);
                     // If there is no parse hint we might be able to derive it
                     if (!isset($parseHint)) {
                         $parseHint = $this->deriveParseHintFromName($argumentName);
                     }
                     // Attempt to obtain a triple generator
                     $tripleGenerator = $this->getTripleGenerator($parseHint);
                     // If we DONT have a triple generator
                     // we fall through to default handling
                     $localResult = array(array(), array(), array());
                     if (isset($tripleGenerator)) {
                         foreach ($values as $valueIndex => $value) {
                             //echo "GOT VALUE $value\n";
                             $value = trim($value);
                             // Skip empty values
                             if ($value == "") {
                                 continue;
                             }
                             //echo "PROCESSING $templateChildName - $argumentName $value\n";
                             $tmp = $tripleGenerator->generate($templateChildName, $argumentName, $value);
                             $localResult[0] = array_merge($localResult[0], $tmp);
                             //echo "LOCALRESULT\n";
                             //print_r($localResult[0]);
                             //print_r($triples);
                             //echo "\nSigh\n";
                             //if(isset($triples))
                             //    $result = array_merge($result, $triples);
                         }
                         // append the generated triples
                         //continue;
                     } else {
                         // No parse hint - default handling
                         // if property date and object an timespan
                         // we extract it with following special case
                         $argumentName = propertyToCamelCase($argumentName);
                         $argumentName = encodeLocalName($argumentName);
                         if (in_array($argumentName, $GLOBALS['W2RCFG']['ignoreProperties'])) {
                             continue;
                         }
                         // turn the argument name into a property name
                         $propertyName = $propertyNs . $argumentName;
                         foreach ($values as $valueIndex => $value) {
                             $value = trim($value);
                             // Skip empty values
                             if ($value == "") {
                                 continue;
                             }
                             if ($argumentName == "date") {
                                 $value = str_replace("[", "", $value);
                                 $value = str_replace("]", "", $value);
                                 $value = str_replace("&ndash;", "-", $value);
                             }
                             // Parse out sub templates
                             // if something was extracted:
                             // .) connect subject with subsubject
                             // .) indicate usage at wikipage
                             $subResources = $this->myGenerate($childBreadcrumb, $value);
                             for ($i = 0; $i < 3; ++$i) {
                                 $localResult[$i] = array_merge($localResult[$i], $subResources[$i]);
                             }
                             //$result = array_merge($result, $triples);
                             //echo "GOT OBJECT $value\n";
                             $localResult[0] = array_merge($localResult[0], parseAttributeValueWrapper($value, $templateChildName, $propertyName, $this->language));
                             //$result = array_merge($result, $triples);
                         }
                     }
                     // For each triple add the ExtractedFromTemplate-Annotation
                     // Exclude triples with wikiPageUsesTemplate as predicate though
                     foreach ($localResult[0] as $triple) {
                         $triple->addExtractedFromTemplateAnnotation($templateUri);
                     }
                     // Add on delete cascade annotation
                     if ($breadCrumb->getDepth() > 1) {
                         foreach ($localResult[0] as $triple) {
                             $triple->addOnDeleteCascadeAnnotation($rootSubjectUri);
                         }
                     }
                     // merge the results
                     //for($i = 0; $i < 3; ++$i)
                     //    $result[$i] = array_merge($result[$i], $localResult[$i]);
                     //}
                     for ($i = 0; $i < 3; ++$i) {
                         $result[$i] = array_merge($result[$i], $localResult[$i]);
                     }
                 }
             }
             /*
             How to connect a sub-subject to the root subject?
                             if($breadCrumb->getDepth() == 0)
                continue;
             
                             // Create the parent-child connection
                             $parentChildTriple = new RDFtriple(
                $parentResource,
                RDFtriple::URI(DB_PROPERTY_NS . encodeLocalName($parentPropertyName), false),
                RDFtriple::page($templateChildName));
             
                             //$result[1][] = $parentChildTriple;
             */
         }
     }
     if (count($relatedClasses) > 0) {
         foreach ($relatedClasses as $relatedClass => $dummy) {
             $result[1][] = new RDFtriple($parentResource, RDFtriple::URI(RDF_TYPE, false), RDFtriple::URI(DB_ONTOLOGY_NS . $relatedClass, false));
         }
     } else {
         if ($breadCrumb->getDepth() == 0) {
             $result[1][] = new RDFtriple($parentResource, RDFtriple::URI(RDF_TYPE, false), RDFtriple::URI(OWL_THING, false));
         }
     }
     // Add the wiki page uses template triples - but only on depth 0
     if ($breadCrumb->getDepth() == 0) {
         foreach ($result[2] as $name => $dummy) {
             $result[1][] = new RDFTriple($parentResource, self::$wikiPageUsesTemplateUri, RDFTriple::URI(DB_TEMPLATE_NS . $name, false));
         }
     }
     $n = count($result[0]) + count($result[1]);
     $this->log(TRACE, "Generated a total of {$n} triples at {$breadCrumb}");
     foreach ($result[0] as $item) {
         $this->log(TRACE, $item);
     }
     foreach ($result[1] as $item) {
         $this->log(TRACE, $item);
     }
     return $result;
 }
 function Logout($session_id = NULL)
 {
     $this->destroyCookie();
     $this->Delete();
     TTLog::addEntry($this->getObject()->getID(), 'Logout', TTi18n::getText('SourceIP') . ': ' . $this->getIPAddress() . ' ' . TTi18n::getText('SessionID') . ': ' . $this->getSessionID() . ' ' . TTi18n::getText('UserID') . ': ' . $this->getObject()->getId(), $this->getObject()->getID(), 'authentication');
     BreadCrumb::Delete();
     return TRUE;
 }
Exemplo n.º 8
0
<?php

define('ROOT_PATH', dirname(__DIR__));
require ROOT_PATH . '/vendor/autoload.php';
require ROOT_PATH . '/test/application.php';
$bc = new BreadCrumb('Application', 'edit', array('controller_postfix' => 'Controller', 'action_postfix' => 'Action'));
$tpl = $bc->render();
echo $tpl . PHP_EOL;