コード例 #1
0
 /**
  * Returns instance of the Zend_Cache_Core configured with the options from the application configuration.
  * 
  * @param string $name, optional The name of the cache - general by default. This name is used in the configuration.
  * @return Zend_Cache_Core
  */
 public static function getCache($name = self::GENERAL_CACHE)
 {
     static $instances = array();
     if (!isset($instances[$name])) {
         $manager = OpenSKOS_Application_BootstrapAccess::getBootstrap()->getPluginResource('cachemanager')->getCacheManager();
         $instances[$name] = $manager->getCache($name);
     }
     return $instances[$name];
 }
コード例 #2
0
ファイル: Export.php プロジェクト: rubensworks/OpenSKOS
 /**
  * Gets the path to the dir where the export files should be placed.
  *
  * @return string
  */
 public function getExportFilesDirPath()
 {
     $editorOptions = OpenSKOS_Application_BootstrapAccess::getOption('editor');
     if (isset($editorOptions['export']['filesPath'])) {
         $mainDirPath = $editorOptions['export']['filesPath'];
     } else {
         $mainDirPath = APPLICATION_PATH . '/../public/data/export';
     }
     $mainDirPath = rtrim($mainDirPath, '/') . '/';
     return $mainDirPath;
 }
コード例 #3
0
 /**
  * @return array
  */
 protected function setConceptLanguages()
 {
     //@FIXME it's a good idea to have a settings class that deals with .ini parameters, verification & default values.
     $editorSettings = OpenSKOS_Application_BootstrapAccess::getOption('editor');
     $languages = array();
     $this->_conceptLanguages = array();
     if (isset($editorSettings['languages'])) {
         $languages = $editorSettings['languages'];
     }
     foreach ($languages as $languageCode => $languageName) {
         foreach (self::$languageSensitiveClasses as $class) {
             foreach (self::$classes[$class] as $fieldName) {
                 if (isset($this[$fieldName . '@' . $languageCode])) {
                     $this->_conceptLanguages[] = $languageCode;
                     break;
                 }
             }
         }
     }
     $this->_conceptLanguages = array_unique($this->_conceptLanguages);
     return $this->_conceptLanguages;
 }
コード例 #4
0
 /**
  * Gets a list of concepts matching the search options.
  * 
  * @param array $searchOptions
  * @return array An array with the labels of the schemes
  */
 public function searchConcepts($searchOptions)
 {
     $editorOptions = OpenSKOS_Application_BootstrapAccess::getOption('editor');
     $availableOptions = Editor_Forms_SearchOptions::getAvailableSearchOptions();
     $availableOptions['conceptSchemes'] = $this->getAllConceptSchemeUriTitlesMap();
     $query = OpenSKOS_Solr_Queryparser_Editor::factory()->parse($searchOptions, $editorOptions['languages'], $availableOptions, $this->_getCurrentTenant());
     // Pagination
     $queryParams = array();
     if (isset($searchOptions['start']) && !empty($searchOptions['start'])) {
         $queryParams['start'] = $searchOptions['start'];
     }
     if (isset($searchOptions['rows']) && !empty($searchOptions['rows'])) {
         $queryParams['rows'] = $searchOptions['rows'];
     }
     //@TODO: implement language specific sort by using prefLabelSort@... Solr fields
     $queryParams['sort'] = 'prefLabelSort asc';
     $response = Api_Models_Concepts::factory()->setQueryParams($queryParams)->getConcepts($query);
     $response = $response['response'];
     $result = array();
     $result['numFound'] = $response['numFound'];
     $result['data'] = array();
     if (isset($response['start'])) {
         $result['start'] = $response['start'];
     }
     if ($response['numFound'] > 0) {
         foreach ($response['docs'] as &$record) {
             $result['data'][] = new Api_Models_Concept($record);
         }
     }
     return $result;
 }
コード例 #5
0
 /**
  * Builds the path to the concept scheme icon.
  * Returns empty string if the file does not exist. 
  * 
  * @param srtring $uuid
  * @param OpenSKOS_Db_Table_Row_Tenant $tenant optional, Default null. If not set the currently logged one will be used.
  * @return string
  */
 public static function buildIconPath($uuid, $tenant = null)
 {
     $editorOptions = OpenSKOS_Application_BootstrapAccess::getBootstrap()->getOption('editor');
     if (null === $tenant) {
         $tenant = OpenSKOS_Db_Table_Tenants::fromIdentity();
     }
     // We always need tenant for getting icon path.
     if (null !== $tenant) {
         if (isset($editorOptions['schemeIcons']) && isset($editorOptions['schemeIcons']['assignPath'])) {
             $iconsAssignPath = APPLICATION_PATH . $editorOptions['schemeIcons']['assignPath'] . '/' . $tenant->code;
         } else {
             $iconsAssignPath = APPLICATION_PATH . Editor_Forms_UploadIcon::DEFAULT_ASSIGN_PATH . '/' . $tenant->code;
         }
         if (isset($editorOptions['schemeIcons']) && isset($editorOptions['schemeIcons']['assignHttpPath'])) {
             $iconsAssignHttpPath = $editorOptions['schemeIcons']['assignHttpPath'] . '/' . $tenant->code;
         } else {
             $iconsAssignHttpPath = Editor_Forms_UploadIcon::DEFAULT_ASSIGN_HTTP_PATH . '/' . $tenant->code;
         }
         if (isset($editorOptions['schemeIcons']) && isset($editorOptions['schemeIcons']['extension'])) {
             $iconsExtension = $editorOptions['schemeIcons']['extension'];
         } else {
             $iconsExtension = 'png';
         }
         if (is_file($iconsAssignPath . '/' . $uuid . '.' . $iconsExtension)) {
             return $iconsAssignHttpPath . '/' . $uuid . '.' . $iconsExtension . '?nocache=' . time();
         } else {
             return '';
         }
     } else {
         return '';
     }
 }
コード例 #6
0
ファイル: Collection.php プロジェクト: rubensworks/OpenSKOS
 public function getConceptsBaseUri()
 {
     if (isset($this->conceptsBaseUrl) && !empty($this->conceptsBaseUrl)) {
         return $this->conceptsBaseUrl;
     } else {
         $editorOptions = OpenSKOS_Application_BootstrapAccess::getOption('editor');
         if (isset($editorOptions['conceptSchemesDefaultBaseUri'])) {
             return $editorOptions['conceptSchemesDefaultBaseUri'];
         } else {
             return '';
         }
     }
 }