Skip to content

Commit 1556424

Browse files
committed
Added support for UI libraries
1 parent 887f610 commit 1556424

File tree

170 files changed

+126956
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+126956
-7
lines changed

Dataface/Application.php

+112-1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,114 @@ class Dataface_Application {
178178

179179
private $pageTitle = null;
180180

181+
/**
182+
* Array of UI libraries that have been loaded.
183+
*/
184+
private $uiLibraries = array();
185+
public $UI_LIBRARY_PATH = XFAPPROOT.'uilibs' . PATH_SEPARATOR .XFROOT.'uilibs';
186+
187+
/**
188+
* Gets the UI library search path - the paths where it will
189+
* search for UI libraries.
190+
* @return string Paths separated by path separator char.
191+
*/
192+
public function getUILibraryPath() {
193+
return $this->UI_LIBRARY_PATH;
194+
}
195+
196+
/**
197+
* Sets the search paths to look for UI libraries.
198+
* @param string $path A path in format like PATH or LD_LIBRARY_PATH. Paths separated by PATH_SEPARATOR. (e.g. semicolon on windows, and colon on unix).
199+
*/
200+
public function setUILibraryPath($path) {
201+
$this->UI_LIBRARY_PATH = $path;
202+
}
203+
204+
/**
205+
* Appends path to the UI library search paths.
206+
* @param string $path The path to add.
207+
* @return void.
208+
*/
209+
public function appendUILibraryPath($path) {
210+
$this->UI_LIBRARY_PATH .= PATH_SEPARATOR . $path;
211+
}
212+
213+
/**
214+
* Prepends path to the UI library search paths.
215+
* @param string $path The path to add.
216+
* @return void
217+
*/
218+
public function prependUILibraryPath($path) {
219+
$this->UI_LIBRARY_PATH = $path . PATH_SEPARATOR . $this->UI_LIBRARY_PATH;
220+
}
221+
222+
/**
223+
* Gets the search paths that will be searched to load
224+
* UI libraries, as an array.
225+
*
226+
* @return array Array of paths to directories to search for uilibs.
227+
*/
228+
public function getUILibraryPaths() {
229+
return explode(PATH_SEPARATOR, $this->UI_LIBRARY_PATH);
230+
}
231+
232+
/**
233+
* Loads a UI library. A UI library consists of a file
234+
* located at uilibs/$name/$name.uilib.html. This file will
235+
* be included in the head of the document, so it should
236+
* contain an HTML snippet that loads the necessary CSS and javascript
237+
* files for the UI library to work.
238+
*
239+
* The $name.uilib.html file should use the {{LIBROOT}} placeholder
240+
* as the URL to the uilib's directory so that it knows how to reference
241+
* its CSS and Javascript files.
242+
*
243+
* @param string $name The name of the UI library to load.
244+
* @return boolean True if the library was loaded. False otherwise.
245+
*/
246+
public function loadUILibrary($name) {
247+
if (!isset($this->uiLibraries[$name])) {
248+
$this->uiLibraries[$name] = $name;
249+
250+
251+
foreach ($this->getUILibraryPaths() as $p) {
252+
253+
if (strpos($p, XFAPPROOT) === 0) {
254+
$baseUrl = DATAFACE_SITE_URL;
255+
$basePath = XFAPPROOT;
256+
} else if (strpos($p, XFROOT) === 0) {
257+
$baseUrl = DATAFACE_URL;
258+
$basePath = XFROOT;
259+
} else {
260+
continue;
261+
}
262+
if (strlen($baseUrl) == 0) {
263+
$baseUrl = '/';
264+
}
265+
if (substr($baseUrl, -1) != "/") {
266+
$baseUrl .= '/';
267+
}
268+
269+
$filePath = $p.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.$name.'.uilib.html';
270+
//echo "Filepath: $filePath;";
271+
//echo "BaseUrl: $baseUrl;";
272+
if (file_exists($filePath)) {
273+
274+
$fileUrl = $baseUrl .
275+
substr($filePath, strlen($basePath));
276+
$fileUrl = str_replace(DIRECTORY_SEPARATOR, '/', $fileUrl);
277+
$libRoot = substr($fileUrl, 0, strrpos($fileUrl, '/'));
278+
$content = file_get_contents($filePath);
279+
$content = str_replace('{{LIBROOT}}', $libRoot, $content);
280+
$this->addHeadContent($content);
281+
return true;
282+
}
283+
284+
}
285+
}
286+
return false;
287+
}
288+
181289
/**
182290
* @private
183291
*/
@@ -1125,6 +1233,10 @@ public static function &getInstance($conf=null){
11251233
}
11261234

11271235

1236+
/**
1237+
* Adds javascript strings for use in javascript internationalization.
1238+
* @param array(string=>string) $strings
1239+
*/
11281240
public function addJSStrings($strings){
11291241
$jsStrings = json_encode($strings);
11301242
$this->addHeadContent(<<<END
@@ -1874,7 +1986,6 @@ function addHeadContent($content){
18741986
$this->headContent[] = $content;
18751987
}
18761988

1877-
18781989
/**
18791990
* @brief Returns the nav item info for a key. This is a wrapper around the nav items defined
18801991
* in the [_tables] section of the conf.ini file.

Dataface/Table.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -550,12 +550,12 @@ function __construct($tablename, $db=null, $quiet=false){
550550

551551
if (strpos($this->tablename, '_tmp_') === 0) {
552552
// This is just a temporary table.
553-
$iniPath = realpath(DATAFACE_SITE_PATH.'/tables/'.basename($this->tablename).'/fields.ini');
553+
$iniPath = realpath($this->basePath().'/tables/'.basename($this->tablename).'/fields.ini');
554554
if (!$iniPath) {
555-
$iniPath = realpath(DATAFACE_SITE_PATH.'/tables/'.basename($this->tablename).'/fields.ini.php');
555+
$iniPath = realpath($this->basePath().'/tables/'.basename($this->tablename).'/fields.ini.php');
556556
}
557-
$delegateClass = realpath(DATAFACE_SITE_PATH.'/tables/'.basename($this->tablename).'/'.basename($this->tablename).'.php');
558-
557+
$delegateClass = $this->_delegateFilePath();
558+
559559
$sqlQuery = null;
560560
//echo "ini path $iniPath ".$this->tablename;
561561
if (file_exists($iniPath)) {
@@ -567,13 +567,15 @@ function __construct($tablename, $db=null, $quiet=false){
567567
if (file_exists($delegateClass)) {
568568
import($delegateClass);
569569
$delClassName = 'tables_'.basename($this->tablename);
570-
570+
571571
if (!class_exists($delClassName)) {
572572
throw new Exception("Delegate class ".$delegateClass." file exists but no class is defined in it");
573573
}
574574

575-
$delObj = new $delClassName;
575+
$delObj = new $delClassName;
576+
$this->_delegate = $delObj;
576577
if (method_exists($delObj, '__sql__')) {
578+
577579
$sqlQuery = $delObj->__sql__();
578580
}
579581
}

uilibs/semantic-ui/LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Semantic Org
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

uilibs/semantic-ui/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# CSS Distribution
2+
3+
This repository is automatically synced with the main [Semantic UI](https://github.com/Semantic-Org/Semantic-UI) repository to provide lightweight CSS only version of Semantic UI.
4+
5+
This package **does not support theming** and includes generated CSS files of the default theme only.
6+
7+
You can view more on Semantic UI at [LearnSemantic.com](http://www.learnsemantic.com) and [Semantic-UI.com](http://www.semantic-ui.com)

0 commit comments

Comments
 (0)