If you're interested in introducing administrative or dashboard functionality, then refer to class-library-admin.php
Автор: Patrick Daly (patrick@developdaly.com)
Пример #1
0
 /**
  * Get the name of this face.
  *
  * @return string The name of this face.
  */
 public function getName()
 {
     if (is_null($this->name)) {
         $this->name = $this->library->getFaceName($this->key);
     }
     return $this->name;
 }
 static function getObjectStructure()
 {
     global $user;
     //Load Libraries for lookup values
     $library = new Library();
     $library->orderBy('displayName');
     if ($user->hasRole('libraryAdmin')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $library->libraryId = $homeLibrary->libraryId;
     }
     $library->find();
     $libraryList = array();
     while ($library->fetch()) {
         $libraryList[$library->libraryId] = $library->displayName;
     }
     require_once ROOT_DIR . '/sys/Browse/BrowseCategory.php';
     $browseCategories = new BrowseCategory();
     $browseCategories->orderBy('label');
     $browseCategories->find();
     $browseCategoryList = array();
     while ($browseCategories->fetch()) {
         $browseCategoryList[$browseCategories->textId] = $browseCategories->label . " ({$browseCategories->textId})";
     }
     $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of the hours within the database'), 'libraryId' => array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'A link to the library which the location belongs to'), 'browseCategoryTextId' => array('property' => 'browseCategoryTextId', 'type' => 'enum', 'values' => $browseCategoryList, 'label' => 'Browse Category', 'description' => 'The browse category to display '), 'weight' => array('property' => 'weight', 'type' => 'numeric', 'label' => 'Weight', 'weight' => 'Defines how lists are sorted within the widget.  Lower weights are displayed to the left of the screen.', 'required' => true));
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
Пример #3
0
    public static function Main()
    {
        ob_start();
        $lib = new Library();
        $lib->f();
        var_dump(new LibX());
        $x = 1;
        if ($x) {
            class Q
            {
            }
        }
        eval('	
				class P extends Q { }
			');
        eval('	
				class A extends C { }
				class D extends A { }
				class E extends LibX { }
			');
        class F extends P
        {
        }
        var_dump(new Q(), new P(), new A(), new D(), new E(), new F());
        $out = ob_get_contents();
        ob_end_clean();
        $EXPECTED = "object(LibX)(0) {\r\n}\r\nobject(Q)(0) {\r\n}\r\nobject(P)(0) {\r\n}\r\nobject(A)(0) {\r\n}\r\nobject(D)(0) {\r\n}\r\nobject(E)(0) {\r\n}\r\nobject(F)(0) {\r\n}\r\n";
        echo $out == $EXPECTED ? "OK" : "ERROR", "\n";
    }
Пример #4
0
 public function showfileAction()
 {
     $strContent = null;
     $strPathFile = $this->params()->fromRoute('path');
     if (!empty($strPathFile)) {
         $strPathFile = base64_decode($strPathFile);
         $booForceDownload = strtolower($this->params()->fromRoute('force_download'));
         if (!empty($booForceDownload)) {
             $booForceDownload = base64_decode($booForceDownload);
         }
         if (file_exists($strPathFile)) {
             $library = new Library();
             if ($booForceDownload == 'true' || stripos($library->getMimeContentFromFile($strPathFile), 'image/') === false) {
                 header('Content-Description: File Transfer');
                 header('Content-Type: application/octet-stream');
                 header('Content-Disposition: attachment; filename="' . end(explode('/', $strPathFile)) . '"');
                 header('Content-Transfer-Encoding: binary');
                 header('Expires: 0');
                 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                 header('Pragma: public');
                 header('Content-Length: ' . filesize($strPathFile));
             } else {
                 header('Content-Type: ' . $library->getMimeContentFromFile($strPathFile) . ';');
             }
             readfile($strPathFile);
         } else {
             $strContent = 'Arquivo inexistente!';
         }
     } else {
         $strContent = 'Parâmetros incorretos!';
     }
     return $this->getViewClearContent($strContent);
 }
Пример #5
0
 public function checkoutValidaiton()
 {
     $validation = new Library();
     $validation->getValidationOk();
     if ($validation->getValidationOk()) {
         echo "Success";
     } else {
         echo "Fail";
     }
 }
 function getLibraryName()
 {
     if ($this->libraryId == -1) {
         return 'Shared Digital Collection';
     } else {
         $library = new Library();
         $library->libraryId = $this->libraryId;
         $library->find(true);
         return $library->displayName;
     }
 }
Пример #7
0
 public function getComments($menuId)
 {
     $rows = $this->db->query("SELECT * FROM comment WHERE menu_id=%i", $menuId)->fetchAll();
     foreach ($rows as &$row) {
         $row['comment_id'] = (int) $row['comment_id'];
     }
     array_unshift($rows, new \Dibi\Row(array('id' => 0, 'comment_id' => null)));
     $tree = $this->library->convertToTree($rows, 'id', 'comment_id', 'comments');
     $tree[0]['comments'] = $this->library->removeKeys($tree[0]['comments'], 'comments');
     return $tree[0]['comments'];
 }
 public function return_book($copyId)
 {
     include 'connection.php';
     $lib = new Library();
     $lib->addCopy($copyId);
     date_default_timezone_set('America/Chicago');
     $date = date('Y-m-d');
     $sql = "UPDATE Group8_loanHistory SET returned='" . $date . "' WHERE copyId = '" . $copyId . "' and username = '******'";
     //$sql = "delete from Group8_loanHistory where copyId = '".$copyId."' and username = '******' and returned is null";
     if ($conn->query($sql) === false) {
         die('Invalid query: ' . $conn->error);
     }
     include 'close_connection.php';
 }
Пример #9
0
 /**
  * The recursive method powering addRouteFor(Request).
  * 
  * @param array Part of a path in reverse order.
  * @param int Current index of path part array - decrements with each step.
  * @param Route The route being added
  * 
  * @return FindRouteResult
  */
 private function addRouteRecursively(&$pathParts, $index, $route)
 {
     // Base Case
     if ($index < 0) {
         foreach ($route->methods as $method) {
             if (isset($this->m[$method])) {
                 Library::import('recess.framework.routing.DuplicateRouteException');
                 throw new DuplicateRouteException($method . ' ' . str_replace('//', '/', $route->path), $route->fileDefined, $route->lineDefined);
             }
             $this->m[$method] = new Rt($route);
         }
         return;
     }
     $nextPart = $pathParts[$index];
     if ($nextPart[0] != '$') {
         $childrenArray =& $this->s;
         $nextKey = $nextPart;
         $isParam = false;
     } else {
         $childrenArray =& $this->p;
         $nextKey = substr($nextPart, 1);
         $isParam = true;
     }
     if (!isset($childrenArray[$nextKey])) {
         $child = new RtNode();
         if ($isParam) {
             $child->c = $nextKey;
         }
         $childrenArray[$nextKey] = $child;
     } else {
         $child = $childrenArray[$nextKey];
     }
     $child->addRouteRecursively($pathParts, $index - 1, $route);
 }
 function isValidForUser($locationCode, $eContentFieldData)
 {
     $sharing = $this->getSharing($locationCode, $eContentFieldData);
     if ($sharing == 'shared') {
         $searchLibrary = Library::getSearchLibrary();
         if ($searchLibrary == null || $searchLibrary->econtentLocationsToInclude == 'all' || strlen($searchLibrary->econtentLocationsToInclude) == 0 || strpos($searchLibrary->econtentLocationsToInclude, $locationCode) !== FALSE) {
             return true;
         } else {
             return false;
         }
     } else {
         if ($sharing == 'library') {
             $searchLibrary = Library::getSearchLibrary();
             if ($searchLibrary == null || $searchLibrary->includeOutOfSystemExternalLinks || strlen($searchLibrary->ilsCode) > 0 && strpos($locationCode, $searchLibrary->ilsCode) === 0) {
                 return true;
             } else {
                 return false;
             }
         } else {
             $searchLibrary = Library::getSearchLibrary();
             $searchLocation = Location::getSearchLocation();
             if ($searchLibrary->includeOutOfSystemExternalLinks || strpos($locationCode, $searchLocation->code) === 0) {
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
Пример #11
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     // Using factory
     // Getting an instance of a model User example
     $user = ModelFactory::getInstance('User');
     // Getting an instance of a Library String
     $stringLib = LibraryFactory::getInstance('String');
     // Getting an instance of a Filter DateRange
     $dateRange = FilterFactory::getInstance('DateRange');
     // Getting an instance of a Type User
     $userType = TypeFactory::getInstance('User');
     // Perform an access check
     AccessCheckFactory::getInstance('User')->canAccess(auth()->user()->id, 'view');
     // Using facade
     // Getting an instance of a model User example
     $user = \Model::getInstance('User');
     // Getting an instance of a Library String
     $stringLib = \Library::getInstance('String');
     // Getting an instance of a Filter DateRange
     $dateRange = \Filter::getInstance('DateRange');
     // Getting an instance of a Type User
     $userType = \Type::getInstance('User');
     // Passing data to view example
     $this->view->fullname = auth()->user()->fullname;
     // Perform an access check
     \AccessCheck::getInstance('User')->canAccess(1, 'view');
     return $this->view('dashboard');
 }
Пример #12
0
 public function thumb($uniqueId, $width, $height, $method, $filename)
 {
     // only image can get thumbnails, existing files and valid resize method name
     if (!$this->MediaFile->isImage() || !($ImageFile = $this->MediaFile->file()) || !method_exists($ImageFile, $method)) {
         return false;
     }
     $filename = STATIC_DIR . 'img/public/' . $uniqueId . '/' . $width . 'x' . $height . '/' . $method . '/' . $filename;
     $width = (int) $width > 0 ? (int) $width : null;
     $height = (int) $height > 0 ? (int) $height : null;
     // resize Image
     try {
         $ImageFile->{$method}($width, $height, true, false);
         // apply sharpen filter if available and image is small
         if (function_exists('imageconvolution') && $width < 400 && $height < 400) {
             Library::load('ephFrame.lib.file.image.ImageSharpenFilter');
             $sharpenFilter = new ImageSharpenFilter();
             $ImageFile->applyFilter($sharpenFilter);
         }
     } catch (ImageToLargeToLoadException $e) {
         $ImageFile = new Image($width, $height);
         $ImageFile->backgroundColor('ffffe0')->border('e6db55', 1, 0);
         $ImageFile->text(Image::CENTERED, Image::CENTERED, 'image to large to' . LF . 'create thumbnail', 'b8ad4c', 1);
     }
     $ImageFile->saveAs($filename, $this->thumbQuality);
     $this->redirect(WEBROOT . $filename);
 }
Пример #13
0
 protected function expand($class, $reflection, $descriptor)
 {
     if (is_array($this->values[0])) {
         $this->httpMethods = $this->values[0];
     } else {
         $this->httpMethods = array($this->values[0]);
     }
     if (isset($this->values[1])) {
         $this->path = $this->values[1];
     }
     $controller = Library::getFullyQualifiedClassName($class);
     $controllerMethod = $reflection->getName();
     if (strpos($this->path, Library::pathSeparator) === 0) {
         // Absolute Route
         $route = new Route($controller, $controllerMethod, $this->httpMethods, $this->path);
         $descriptor->methodUrls[$controllerMethod] = $this->path;
     } else {
         // Relative Route
         $route = new Route($controller, $controllerMethod, $this->httpMethods, $descriptor->routesPrefix . $this->path);
         $descriptor->methodUrls[$controllerMethod] = $descriptor->routesPrefix . $this->path;
     }
     $route->fileDefined = $reflection->getFileName();
     $route->lineDefined = $reflection->getStartLine();
     $descriptor->routes[] = $route;
 }
Пример #14
0
 public function __construct($config = array())
 {
     parent::__construct();
     $this->config = $config;
     $this->config['driver'] = 'recaptcha';
     loader::library('captcha', $this->config);
 }
Пример #15
0
 public function __construct()
 {
     Cowl::timer('cowl init');
     @session_start();
     // I know that the @-notation is frowned upon, but adding it to session_start saves us unnecessary warnings
     Cache::setDir(COWL_CACHE_DIR);
     Current::initialize(COWL_DIR);
     if (COWL_CLI) {
         $this->parseCLIPath();
     } else {
         $this->parseRequestPath();
     }
     Cowl::timer('cowl set defaults');
     // Get and set all directories for various things.
     list($commands_dir, $model_dir, $validators_dir, $library_dir, $view_dir, $helpers_dir, $helpers_app_dir, $drivers_dir, $app_dir, $view_layout_dir, $validator_error_messages, $lang) = Current::$config->gets('paths.commands', 'paths.model', 'paths.validators', 'paths.library', 'paths.view', 'paths.helpers', 'paths.helpers_app', 'paths.drivers', 'paths.app', 'paths.layouts', 'paths.validator_messages', 'lang');
     Controller::setDir($commands_dir);
     DataMapper::setMappersDir($model_dir);
     DataMapper::setObjectsDir($model_dir);
     Validator::setPath($validators_dir);
     Validator::loadStrings($validator_error_messages, $lang);
     Templater::setBaseDir($view_dir);
     Templater::setLayoutDir($view_layout_dir);
     Library::setPath($library_dir);
     Helpers::setPath($helpers_dir);
     Helpers::setAppPath($helpers_app_dir);
     Database::setPath($drivers_dir);
     StaticServer::setDir($app_dir);
     Cowl::timerEnd('cowl set defaults');
     Cowl::timer('cowl plugins load');
     Current::$plugins = new Plugins();
     Cowl::timerEnd('cowl plugins load');
     // Load default helper
     Helpers::load('standard', 'form');
     Cowl::timerEnd('cowl init');
 }
Пример #16
0
 /**
  * Get details of a benchmark.
  *
  * @param $name string benchmark name
  *
  * @return void
  */
 public function details($name)
 {
     // Config Check : Are Benchmarks enabled
     if ($this->config['enabled']) {
         return parent::details($name);
     }
 }
Пример #17
0
 public function __construct()
 {
     $library = Library::getActive();
     if (is_object($library)) {
         $this->controller = $library->getController();
     }
 }
Пример #18
0
 public function before()
 {
     $this->nocversion = 'none';
     $path = $this->request->route->path;
     if ($path != 'auth/login') {
         $this->check_license($path);
     }
     parent::before();
     //$auth = Auth::instance();
     //Auth::instance()->login('hrvoje','hajduk81');
     /*
     if(!$this->check_license())
     \Response::redirect(\Config::get('base_url').'/ajax/license');
     */
     $uri_string = explode('/', Uri::string());
     if (count($uri_string) > 1 and $uri_string[0] == 'auth' and $uri_string[1] == 'login') {
         return;
     }
     if ($path != '_root_') {
         if (\Sentry::check()) {
             $this->user = Sentry::user()->get('id');
             $this->username = Sentry::user()->get('username');
             return;
         } else {
             $this->user = false;
             $this->username = '';
             \Response::redirect(\Config::get('base_url') . 'auth/login');
         }
     }
 }
Пример #19
0
 public function __construct($config = array())
 {
     parent::__construct();
     foreach ($config as $item => $value) {
         $this->{$item} = $value;
     }
 }
Пример #20
0
 /**
  * Get a photo from this album by its key
  *
  * @param int $key key of the photo to get
  * @return Photo photo with the given key, or null iff not found
  */
 public function getPhoto($key)
 {
     if (!in_array($key, $this->data['KeyList'])) {
         return null;
     }
     return $this->library->getPhoto($key);
 }
 function isValidForUser($locationCode, $eContentFieldData)
 {
     $sharing = $this->getSharing($locationCode, $eContentFieldData);
     if ($sharing == 'shared') {
         return true;
     } else {
         if ($sharing == 'library') {
             $searchLibrary = Library::getSearchLibrary();
             if ($searchLibrary == null || strlen($searchLibrary->ilsCode) > 0 && strpos($locationCode, $searchLibrary->ilsCode) === 0) {
                 global $user;
                 if ($user) {
                     $patronHomeLibrary = Library::getPatronHomeLibrary();
                     return $patronHomeLibrary == null || strlen($patronHomeLibrary->ilsCode) > 0 && strpos($locationCode, $patronHomeLibrary->ilsCode) === 0;
                 } else {
                     return true;
                 }
             } else {
                 return false;
             }
         } else {
             //Just share with the specific location
             $searchLocation = Location::getSearchLocation();
             if (!$searchLocation) {
                 return true;
             } elseif (strpos($locationCode, $searchLocation->code) === 0) {
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
Пример #22
0
 static function getObjectStructure()
 {
     $library = new Library();
     $library->orderBy('displayName');
     $library->find();
     $libraryList = array();
     while ($library->fetch()) {
         $libraryList[$library->libraryId] = $library->displayName;
     }
     $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of the holiday within the database'), 'libraryId' => array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'A link to the library'), 'date' => array('property' => 'date', 'type' => 'date', 'label' => 'Date', 'description' => 'The date of a holiday.', 'required' => true), 'name' => array('property' => 'name', 'type' => 'text', 'label' => 'Holiday Name', 'description' => 'The name of a holiday'));
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
Пример #23
0
 /**
  * Initialize the plugin by loading admin scripts & styles and adding a
  * settings page and menu.
  *
  * @since     1.0.0
  */
 private function __construct()
 {
     $plugin = Library::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     add_action('init', array($this, 'register'));
     /* Fire our meta box setup function on the post editor screen. */
     add_action('load-post.php', array($this, 'library_meta_boxes_setup'));
 }
Пример #24
0
 public function save($quality = 100)
 {
     $contents = Library::getContentsFromGDResource($this->resource, $this->format, $quality);
     $format = $this->format;
     $extension = $this->getExtensionFromFormat($format);
     $mime = $this->getMimeFromFormat($format);
     return array('contents' => $contents, 'format' => $format, 'extension' => $extension, 'mime' => $mime);
 }
Пример #25
0
 public function __construct($config = array())
 {
     parent::__construct();
     if (!empty($config['public_key']) && !empty($config['private_key'])) {
         $this->_public_key = $config['public_key'];
         $this->_private_key = $config['private_key'];
     }
 }
Пример #26
0
 public function getMenu($languageId = null)
 {
     if (empty($languageId)) {
         $languageId = $this->languageId;
     }
     if (!isset($this->menu[$languageId])) {
         $sql = "SELECT m.id,m.menu_id,m.type_id,t.text,t.url,visibility,IF(url IS NULL AND sort = 0, 255, sort) AS sort\n \t\t\tFROM [menu] m\n\t\t\tLEFT JOIN [name_has_text] nht ON m.name_id=nht.name_id AND language_id=%i\n\t\t\tLEFT JOIN [text] t ON t.id=nht.text_id\n\t\t\tWHERE site_id=%i\n\t\t\tORDER BY m.visibility,[sort],[id]";
         $rows = $this->db->query($sql, $languageId, $this->siteId)->fetchAll();
         foreach ($rows as &$row) {
             $row['menu_id'] = (int) $row['menu_id'];
         }
         array_unshift($rows, new \Dibi\Row(array('id' => 0, 'menu_id' => null)));
         $tree = $this->library->convertToTree($rows, 'id', 'menu_id', 'items');
         $tree[0]['items'] = $this->library->removeKeys($tree[0]['items'], 'items');
         $this->menu[$languageId] = $tree;
     }
     return $this->menu[$languageId];
 }
Пример #27
0
 public function handleEdit()
 {
     $book = Library::findOrFail(Input::get('library'));
     $book->book_name = Input::get('book_name');
     $book->book_copy = Input::get('copy');
     $book->updated_by_id = Auth::id();
     $book->update();
     return Redirect::action('AdminLibraryController@index')->with('flash_edit_success', 'Hurray!You have updated a new Book');
 }
Пример #28
0
 public function before()
 {
     //remove all data from previus installation....
     Sentry::logout();
     Config::load('Sentry', true);
     Cookie::delete('sentry_rm');
     Session::delete(Config::get('sentry.session.user'));
     Session::delete(Config::get('sentry.session.provider'));
     parent::before();
 }
Пример #29
0
 public function getMenu($type = 'visible')
 {
     if (!isset($this->menu[$type])) {
         $sql = "SELECT m.id,m.menu_id,m.type_id AS type,t.text,t.url,m.visibility FROM [menu] m\n\t\t\tJOIN [name_has_text] nht ON m.name_id=nht.name_id AND language_id=%i\n\t\t\tJOIN [text] t ON t.id=nht.text_id\n\t\t\tWHERE site_id=%i AND m.visibility = %s\n\t\t\tORDER BY [sort],[id]";
         $rows = $this->db->query($sql, $this->getLanguageId(), $this->siteId, $type)->fetchAll();
         foreach ($rows as &$row) {
             $row['menu_id'] = (int) $row['menu_id'];
         }
         if ($type == 'visible') {
             array_unshift($rows, new DibiRow(array('id' => 0, 'menu_id' => null)));
             $tree = $this->library->convertToTree($rows, 'id', 'menu_id', 'items');
             $tree[0]['items'] = $this->library->removeKeys($tree[0]['items'], 'items');
             $this->menu[$type] = $tree;
         } else {
             $this->menu[$type] = $rows;
         }
     }
     return $this->menu[$type];
 }
Пример #30
0
 public function __construct($searchObject, $params)
 {
     global $library;
     global $configArray;
     // Save the basic parameters:
     $this->searchObject = $searchObject;
     // Parse the additional parameters:
     $params = explode(':', $params);
     $section = empty($params[0]) ? 'ResultsTop' : $params[0];
     $iniFile = isset($params[1]) ? $params[1] : 'facets';
     // Load the desired facet information:
     $searchLibrary = Library::getActiveLibrary();
     $searchLocation = Location::getActiveLocation();
     $config = getExtraConfigArray($iniFile);
     if ($searchObject->getSearchType() == 'genealogy') {
         $this->mainFacets = array();
     } else {
         $searchLibrary = Library::getActiveLibrary();
         $searchLocation = Location::getActiveLocation();
         $userLocation = Location::getUserHomeLocation();
         $hasSearchLibraryFacets = $searchLibrary != null && count($searchLibrary->facets) > 0;
         $hasSearchLocationFacets = $searchLocation != null && count($searchLocation->facets) > 0;
         if ($hasSearchLocationFacets) {
             $facets = $searchLocation->facets;
         } elseif ($hasSearchLibraryFacets) {
             $facets = $searchLibrary->facets;
         } else {
             $facets = Library::getDefaultFacets();
         }
         foreach ($facets as $facet) {
             if ($facet->showAboveResults == 1) {
                 $facetName = $facet->facetName;
                 if (isset($searchLibrary)) {
                     if ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                         $facetName = 'availability_toggle_' . $searchLibrary->subdomain;
                     }
                 }
                 if (isset($userLocation)) {
                     if ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                         $facetName = 'availability_toggle_' . $userLocation->code;
                     }
                 }
                 if (isset($searchLocation)) {
                     if ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                         $facetName = 'availability_toggle_' . $searchLocation->code;
                     }
                 }
                 $this->facets[$facetName] = $facet->displayName;
                 $this->facetSettings[$facetName] = $facet;
             }
         }
     }
     // Load other relevant settings:
     $this->baseSettings = array('rows' => $config['Results_Settings']['top_rows'], 'cols' => $config['Results_Settings']['top_cols']);
 }