Skip to content
Snippets Groups Projects
Select Git revision
  • 1e60170d8b06d61f5dc510d00552660a91661b9d
  • master default
  • disable-new-requests
  • fix-bulletin-view-missing-notes-error
  • add-missing-queue-managers
  • projects-task-53
  • projects-task-51
  • projects-task-43
  • projects-task-24
  • projects-task-31
  • projects-task-32
  • projects-task-8
  • project-setup-docs
  • projects-task-28
  • projects-task-27
  • projects-task-9
  • projects-task-7
  • mass-update-course-codes-in-sections
  • wdn-four
  • learning-outcomes
  • additional-bulletin-pages
  • svn-redesign
  • svn-popups
  • svn-trunk
  • svn-performance
  • svn-tim
26 results

RequestController.php

Blame
  • CustomClass.php 3.96 KiB
    <?php
    
    set_include_path(dirname(dirname(dirname(__DIR__))).'/src'.PATH_SEPARATOR.dirname(dirname(dirname(__DIR__))).'/vendor/php');
    
    
    require_once 'UNL/Templates.php';
    
    class CustomClass
    {
        public $template;
        
        function __construct()
        {
            $this->template = UNL_Templates::factory('Fixed');
            $this->autoGenerate('Department of Mathematics', 'Math');
        }
        
        function autoGenerateBreadcrumbs($unitShortName, array $organization = array('name' => 'UNL', 'url' => 'http://www.unl.edu/'), $delimiter = ' | ')
        {
            $fileName             = array_shift(explode('.', array_pop(explode(DIRECTORY_SEPARATOR, htmlentities($_SERVER['SCRIPT_NAME'])))));
            $generatedBreadcrumbs = '';
            $generatedDocTitle    = '';
            
            $isIndexPage = preg_match('/index/', $fileName);
            
            $searchFor = array($_SERVER['DOCUMENT_ROOT'], '_');
            $replaceWith = array($unitShortName, ' ');
            
            $keys = explode(DIRECTORY_SEPARATOR, str_replace($searchFor, $replaceWith, getcwd()));
            $values = array();
            
            for ($i = count($keys)-1; $i >= 0; $i--) {
                array_push($values, str_replace($_SERVER['DOCUMENT_ROOT'], '', implode(DIRECTORY_SEPARATOR, explode(DIRECTORY_SEPARATOR, getcwd(), -$i)).DIRECTORY_SEPARATOR));
            }
            
            for ($i = 0; $i < count($keys)  - $isIndexPage ; $i++) {
                $generatedBreadcrumbs .= '<li><a href="'. $values[$i] .'">' . ucwords($keys[$i]) .' </a></li> '; 
                $generatedDocTitle    .= ucwords($keys[$i]) . $delimiter;
            }
        
            if ($isIndexPage) {
                $generatedBreadcrumbs .= '<li>'. ucwords(end($keys)) .'</li></ul>';
                $generatedDocTitle    .= ucwords(end($keys));
            } else {
                $generatedBreadcrumbs .= '<li>'. ucwords($fileName) .'</li></ul>';
                $generatedDocTitle    .= ucwords($fileName);
            }
            
            $doctitle    = '<title>' . $organization['name'] . $delimiter . $generatedDocTitle . '</title>';
            $breadcrumbs = '<ul><li class="first"><a href="'.$organization['url'].'">'.$organization['name'].'</a></li> ' . $generatedBreadcrumbs;
        
            $this->template->doctitle = $doctitle;
            $this->template->breadcrumbs = $breadcrumbs;
        }
        
        /**
         * This function finds an html file with the content of the body file and
         * inserts it into the template.
         *
         * @param string $unitName Name of the department/unit
         * 
         * @return void
         */
        function autoGenerateBody($unitName)
        {
            // The file that has the body is in the same dir with the same base file name.
            $bodyFile = array_shift(explode('.', array_pop(explode(DIRECTORY_SEPARATOR, htmlentities($_SERVER['SCRIPT_NAME']))))) . '.html';
        
            $maincontentarea_array = file($bodyFile);
            $maincontentarea       = implode(' ', $maincontentarea_array);