Browse files

Add admin part. Introduce some interfaces and implementations

  • Loading branch information...
1 parent f478854 commit 4c5565250babaeecb0d8e2ef9228f61f7a5c43d1 @ccc-prototype ccc-prototype committed Aug 24, 2011
View
2 .gitignore
@@ -4,3 +4,5 @@ nbproject/
_data/cache/
_data/log/*.log
**/*.orig
+
+*/*/managed/*
View
6 .htaccess
@@ -0,0 +1,6 @@
+Options -Indexes
+
+DirectoryIndex index.php
+AddDefaultCharset UTF-8
+php_flag log_errors on
+php_value error_log ./_data/log/error.log
View
6 autoload.php
@@ -4,8 +4,8 @@ function __autoload($class_name) {
$class_folder = 'classes';
//Lookup in same directory
$class_paths[] = dirname(__FILE__) . '/';
- $class_paths[] = $_SERVER['DOCUMENT_ROOT'] . "/app/$class_folder/";
- $class_paths[] = $_SERVER['DOCUMENT_ROOT'] . "/admin/app/$class_folder/";
+ $class_paths[] = $_SERVER['DOCUMENT_ROOT'] . "/core/$class_folder/";
+ $class_paths[] = $_SERVER['DOCUMENT_ROOT'] . "/core/admin/$class_folder/";
$class_paths[] = dirname($_SERVER['SCRIPT_FILENAME']) . "/$class_folder/";
$class_paths[] = dirname(__FILE__) . "/$class_folder/";
//$CLASS_PATHS
@@ -115,4 +115,4 @@ function array_replace_recursive($array, $array1) {
return $array;
}
}
-?>
+?>
View
10 core/admin/classes/Administrable.class.php
@@ -0,0 +1,10 @@
+<?
+/**
+ * Marker interface with only one method, which returns administrable directory
+ * @author nevil
+ */
+interface Administrable {
+
+ function getAdministeredDir($subDir='', $relativePath=true);
+}
+?>
View
24 core/admin/classes/admin_imageService.class.php
@@ -0,0 +1,24 @@
+<?
+/**
+ * Interface for images adminstration.
+ *
+ * @author nevil
+ */
+interface admin_imageService {
+
+ /**
+ * Delete specified image from $imgDir
+ */
+ function deleteImg($imgDir, $img);
+
+ /**
+ * Updates current image. Candidate img is taken from _FILES[$imgCandidate] array
+ */
+ function updateImg($imgDir, $currentImg, $imgCandidate);
+
+ /**
+ * Inserts image to imgDir. Img is taken from _FILES[$imgCandidate] array
+ */
+ function insertImg($imgDir, $imgCandidate);
+}
+?>
View
19 core/admin/classes/admin_imageServiceImpl.class.php
@@ -0,0 +1,19 @@
+<?
+/**
+ * Implementation of image service admin functionality
+ *
+ * @author nevil
+ */
+class admin_imageServiceImpl extends CommonService implements admin_imageService {
+
+ public function deleteImg($imgDir, $img) {
+ $this->fileUtils->removeFile($img, $imgDir);
+ }
+ public function insertImg($imgDir, $imgCandidate) {
+ $this->fileUtils->saveFile($imgDir, $imgCandidate);
+ }
+ public function updateImg($imgDir, $currentImg, $imgCandidate) {
+ $this->fileUtils->saveFileAs($currentImg, $imgDir, $imgCandidate);
+ }
+}
+?>
View
21 core/admin/classes/core_admin_Controller.class.php
@@ -0,0 +1,21 @@
+<?
+/**
+ * Description of core_admin_Controller
+ *
+ * @author nevil
+ */
+class core_admin_Controller extends core_Controller {
+
+ protected function getDir() {
+ return '/core/admin/';
+ }
+
+ protected function getJS() {
+ $jsDir = $this->getAbsoluteDir() . Config::$JS_DIR_PREFIX;
+ $result = array($this->getDir() => $this->lookUpResources($jsDir));
+ $jsDir = $_SERVER['DOCUMENT_ROOT'].parent::getDir() . Config::$JS_DIR_PREFIX;
+ $result = array_merge($result, array(parent::getDir() => $this->lookUpResources($jsDir)));
+ return $result;
+ }
+}
+?>
View
148 core/admin/resources/css/adm_style.css
@@ -0,0 +1,148 @@
+#center {
+ width: 100%;
+ margin:0px auto;
+}
+
+#head, #footer{
+ height:60px;
+ border-bottom:2px solid #6C1A26;
+ border-top: 2px solid #6C1A26;
+ background-image: url(../img/bg_support.jpg);
+ position:relative;
+ overflow:hidden;
+}
+#content_container #menu{
+ float:left
+}
+
+#content_container .main_content{
+ padding-left: 10px;
+ float:left;
+ width: 85%;
+}
+
+.main_content {
+ padding-top: 10px !important;
+}
+
+div.preview > img {
+ border: 1px solid #000000;
+}
+
+div.img_editor {
+ padding-bottom: 10px;
+ padding-right: 10px;
+ float: left;
+ text-align: center;
+}
+
+.button {
+ background-image: url(/core/resources/img/button_bg.gif) !important;
+ color: #FFFFFF !important;
+}
+
+.img_editor .buttons, .edit_item .buttons, .edit_contacts .buttons{
+ width: 240px;
+}
+.img_editor .buttons {
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.buttons a {
+ background: url("../img/bg_support.jpg") repeat scroll 0 0 transparent;
+ border: 2px solid #6C1A26;
+}
+
+.buttons a, a.back {
+ color: #FFFFFF;
+ display: block;
+ float: left;
+ font-size: 10px;
+ height: 16px;
+ line-height: 16px;
+ margin-right: 4px;
+ overflow: hidden;
+ padding: 0 5px;
+ text-decoration: none !important;
+ width: auto;
+}
+
+.buttons {
+ width: 100% !important;
+}
+
+
+.img_editor .buttons a:first-child {
+ float: left;
+}
+
+.img_editor .buttons a:last-child {
+ float: right;
+}
+
+.buttons a {
+ display: inline;
+ float: none !important;
+ padding: 0 25px;
+ /* width: 100%;*/
+}
+
+.form .buttons {
+ padding-top: 10px;
+ text-align: center;
+}
+
+.img_editor div#newimg a {
+ float: inherit;
+}
+
+#newimg_container {
+ width: 340px;
+ text-align: left;
+}
+
+#newimg_container .buttons {
+ margin-left: 0px;
+}
+
+.item_label {
+ font-size: 16px;
+}
+
+.select {
+ background-color: #1A1016;
+}
+
+.form_container input, .form_container textarea {
+ width: 60%;
+}
+
+input {
+ color:#838182;
+}
+
+label {
+ border: 0 none;
+ display: block;
+ float: left;
+ font-size: 12px;
+/* height: 11px;*/
+/* line-height: 14px;*/
+ margin: 0 0 4px;
+ padding: 3px 5px 0 0;
+ text-align: right;
+ width: 20%;
+}
+
+.textarea, .input {
+ display: inline;
+ float: none;
+ height: auto !important;
+ width: 70%;
+}
+
+span, strong {
+ font-weight: bolder;
+ font-size: 16px;
+}
View
63 core/admin/resources/css/style.css
@@ -0,0 +1,63 @@
+html, body{
+ width:100%;
+ height:100%;
+ margin:0px;
+ padding:0px;
+ overflow:auto;
+}
+
+body {
+ margin:0px;
+ padding:0px;
+ font-family:Verdana, Arial, Helvetica, sans-serif;
+ font-size:11px;
+ color:#596563;
+ background-color:#1a1617;
+}
+
+html > body{
+ width:100%;
+ height:100%;
+}
+
+#center{
+ margin:0px auto;
+ width: 98%;
+}
+
+.main_content{
+ height:auto;
+ margin:0px auto;
+ padding-top: 30px;
+ font-size: 14px;
+}
+
+a {
+ text-decoration:none;
+ outline:none;
+}
+
+a:hover {
+ text-decoration:none;
+ outline:none;
+}
+
+a:focus, a:visited, object:focus {
+ text-decoration:none;
+ outline:none;
+}
+
+img {
+ border:0px;
+}
+
+.clear {
+ height:1px;
+ font-family:Arial, Helvetica, sans-serif;
+ font-size:2px;
+ margin:0px;
+ padding:0px;
+ overflow:hidden;
+ display:block;
+ clear:both;
+}
View
BIN core/admin/resources/img/bg_support.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN core/admin/resources/img/edit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN core/admin/resources/img/remove.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
5 core/admin/resources/js/admin.js
@@ -0,0 +1,5 @@
+
+function reloadPage(data) {
+// alert(data);
+ window.location.reload();
+}
View
5 core/classes/ResourceUtils.class.php
@@ -8,6 +8,7 @@ class ResourceUtils {
private static $instance;
private function __construct() {
+
}
/**
@@ -30,7 +31,9 @@ public static function getInstance() {
* @return img
*/
public function getResizableImg($imgSrc, $width=0, $height=0, $title='') {
- return '<img src="/resize_image.php?src=' . $imgSrc . '&w=' . $width . '&h=' . $height . '" title="' . $title . '"/>';
+ return '<img src="/resize_image.php?src=' . $imgSrc .
+ ($width > 0 ? '&w=' . $width : '') .
+ ($height > 0 ? '&h=' . $height : '') . '" title="' . $title . '"/>';
}
/**
View
7 resize_image.php
@@ -1,7 +1,7 @@
<?
define('CACHE_SIZE', 1000); // number of files to store before clearing cache
define('CACHE_CLEAR', 20); // maximum number of files to delete on each cache clear
-define('CACHE_USE', TRUE); // use the cache files? (mostly for testing)
+define('CACHE_USE', true); // use the cache files? (mostly for testing)
define('VERSION', '1.25'); // version number (to force a cache refresh)
define('DIRECTORY_CACHE', $_SERVER['DOCUMENT_ROOT'] . '/_data/cache'); // cache directory
define('MAX_WIDTH', 1500); // maximum image width
@@ -471,14 +471,15 @@ function check_cache($mime_type) {
function show_cache_file($mime_type) {
// use browser cache if available to speed up page load
+ $cache_file = get_cache_file($mime_type);
+
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
- if (strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) < strtotime('now')) {
+ if (strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == filemtime($cache_file)) {
header('HTTP/1.1 304 Not Modified');
die ();
}
}
- $cache_file = get_cache_file($mime_type);
if (file_exists($cache_file)) {

0 comments on commit 4c55652

Please sign in to comment.