-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from b4oshany/production
closed #30 - Added an image uploader and improve vecni backend.
- Loading branch information
Showing
29 changed files
with
1,265 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,4 @@ | |
*.DS_Store | ||
*.swp | ||
.DS_Store | ||
app/configs/settings.ini.php | ||
app/static/css/gen/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
[submodule "app/plugins/twig"] | ||
path = app/plugins/twig | ||
url = git://github.com/fabpot/Twig.git | ||
path = app/plugins/twig | ||
url = git://github.com/fabpot/Twig.git | ||
[submodule "app/plugins/mailer"] | ||
path = app/plugins/mailer | ||
url = [email protected]:PHPMailer/PHPMailer.git | ||
[submodule "app/plugins/less"] | ||
path = app/plugins/less | ||
url = [email protected]:leafo/lessphp.git | ||
path = app/plugins/mailer | ||
url = [email protected]:PHPMailer/PHPMailer.git | ||
[submodule "app/plugins/error"] | ||
path = app/plugins/error | ||
url = [email protected]:JosephLenton/PHP-Error.git | ||
path = app/plugins/error | ||
url = [email protected]:JosephLenton/PHP-Error.git | ||
[submodule "app/plugins/less"] | ||
path = app/plugins/less | ||
url = [email protected]:leafo/lessphp.git | ||
[submodule "app/static/ext/sweetalert"] | ||
path = app/static/ext/sweetalert | ||
url = [email protected]:t4t5/sweetalert.git | ||
path = app/static/ext/sweetalert | ||
url = [email protected]:t4t5/sweetalert.git | ||
[submodule "app/static/ext/jsuploader"] | ||
path = app/static/ext/jsuploader | ||
url = [email protected]:b4oshany/AJAX-Uploader.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
if (!function_exists('autoload')) { | ||
function autoload($className){ | ||
$module_container = "etc".DIRECTORY_SEPARATOR; | ||
$module = $className; | ||
$className = ltrim($className, '\\'); | ||
$fileName = ''; | ||
$namespace = ''; | ||
if ($lastNsPos = strrpos($className, '\\')) { | ||
$namespace = substr($className, 0, $lastNsPos); | ||
$className = substr($className, $lastNsPos + 1); | ||
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; | ||
} | ||
$fileName .= $className.'.php'; | ||
$fileName = $module_container.$fileName; | ||
for($i = 0; $i < 5; $i++){ | ||
//echo $fileName."<br/>"; | ||
if(file_exists($fileName)){ | ||
require_once $fileName; | ||
break; | ||
}else | ||
$fileName = "..".DIRECTORY_SEPARATOR.$fileName; | ||
} | ||
} | ||
spl_autoload_register('\autoload'); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
namespace libs\scifile; | ||
|
||
class File{ | ||
protected $data_file, $accept_types, $type, $min_size, $max_size; | ||
protected static $relative_storage = null; | ||
protected static $absolute_storage = null; | ||
public static $base = null; | ||
protected $name, $title, $extension; | ||
|
||
public function __construct($data_file, $title=""){ | ||
$this->data_file = $data_file; | ||
if(!empty($this->data_file)){ | ||
$this->name = $this->getName(); | ||
$this->extension = $this->getExtension(); | ||
} | ||
$this->title = $title; | ||
} | ||
|
||
/** | ||
* Set storage location of images. | ||
* @param string $absolute - absolute path to storage folder. | ||
* @param string $relative - relative path to storage folder base on the app root. | ||
*/ | ||
public static function register_location($absolute, $relative=null){ | ||
self::$relative_storage = $relative; | ||
self::$absolute_storage = $absolute; | ||
self::mkdir(self::$absolute_storage); | ||
} | ||
|
||
/** | ||
* Builds a file path with the appropriate directory separator. | ||
* @param string $segments,... unlimited number of path segments | ||
* @return string Path | ||
*/ | ||
public static function build_path() { | ||
return join(DIRECTORY_SEPARATOR, func_get_args()); | ||
} | ||
|
||
/** | ||
* Make director recursively, where applicable. | ||
* @param string $dir - Path to make if not exists. It is Default to empty string. | ||
* @return bool - True if the directory has been created or already exists, else | ||
* false. | ||
*/ | ||
public static function mkdir($dir=""){ | ||
if(!$dir){ | ||
$dir = self::$absolute_storage; | ||
} | ||
if(!is_dir($dir)){ | ||
return mkdir($dir, 0775, true); | ||
} | ||
return true; | ||
} | ||
|
||
/** | ||
* Get storage location of images. | ||
* @param string $type - type of storage to get, i.e. absolute or relative path. | ||
*/ | ||
public static function getStorage($type="absolute"){ | ||
if($type=="absolute") | ||
return self::$absoluteStorage; | ||
return self::$relativeStorage; | ||
} | ||
|
||
/** | ||
* Get the name of the file. | ||
* @return string - name of the file. | ||
*/ | ||
public function getName(){ | ||
if(strripos($this->data_file,'/') != false){ | ||
$name = substr($this->data_file, strripos($this->data_file,'/')+1, (strlen($this->data_file) - strripos($this->data_file,'.') + 1)); | ||
}else{ | ||
$name = substr($this->data_file, 0, strripos($this->data_file,'.')); | ||
} | ||
return $name; | ||
} | ||
|
||
/** | ||
* Get the file extension. | ||
* @return string - file extension. | ||
*/ | ||
public function getExtension(){ | ||
return strtolower(strrchr($this->data_file, '.')); | ||
} | ||
|
||
/** | ||
* Change from absolute to relative path based on the app root. | ||
* @param string $path - Absolute path of file/folder. | ||
* @return string - Relative path of file/folder. | ||
*/ | ||
public static function getRelativeFromAbsolute($path){ | ||
if(!empty(self::$base)){ | ||
return str_replace(self::$base, "", $path); | ||
} | ||
return $path; | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
namespace libs\scifile; | ||
|
||
class Image extends File{ | ||
public $image_id; | ||
public $description; | ||
public $category; | ||
public $title; | ||
public $date_created; | ||
public $thumb_url; | ||
public $photo_url; | ||
|
||
private $thumbnail_extension = "-resized"; | ||
|
||
public function get_location($thumbnail=false){ | ||
if($thumbnail) | ||
return $this->thumb_url; | ||
return $this->photo_url; | ||
} | ||
|
||
public function get($format="xml"){ | ||
$thumbnail = $this->get_location(true); | ||
$fullsize = $this->get_location(false); | ||
$name = $this->name; | ||
$title = $this->title; | ||
switch($format){ | ||
default: | ||
return "<img src='$thumbnail' data-target='$fullsize' alt='$title' title='$title' />"; | ||
} | ||
} | ||
} | ||
|
||
?> |
Oops, something went wrong.