]> git.andy128k.dev Git - ipf.git/commitdiff
indexpage_url is added (admin/base.html)
authorAlexander Meteiko <ameteiko@gmail.com>
Mon, 10 May 2010 12:59:20 +0000 (15:59 +0300)
committerAlexander Meteiko <ameteiko@gmail.com>
Mon, 10 May 2010 12:59:20 +0000 (15:59 +0300)
ipf/admin/model.php
ipf/admin/templates/admin/base.html
ipf/admin/views.php

index 53007882fcf4b046d6d2d86ff3a01700b4dbcd18..a1aa76275b2b083715d2f1da9973df061095ddd2 100644 (file)
@@ -372,6 +372,7 @@ class IPF_Admin_Model{
             'perms'=>$this->getPerms($request),
             'lmodel'=>$lmodel,
             'admin_title' => IPF::get('admin_title'),
+            'indexpage_url'=>IPF::get('indexpage_url','/'),
         );
         return IPF_Shortcuts::RenderToResponse($this->_getAddTemplate(), $context, $request);
     }
@@ -422,6 +423,7 @@ class IPF_Admin_Model{
             'perms'=>$this->getPerms($request),
             'lmodel'=>$lmodel,
             'admin_title' => IPF::get('admin_title'),
+            'indexpage_url'=>IPF::get('indexpage_url','/'),
         );
         return IPF_Shortcuts::RenderToResponse($this->_getChangeTemplate(), $context, $request);
     }
@@ -444,6 +446,7 @@ class IPF_Admin_Model{
             'affected'=>array(),
             'ipf_referrer'=>@$request->GET['ipf_referrer'],
             'admin_title' => IPF::get('admin_title'),
+            'indexpage_url'=>IPF::get('indexpage_url','/'),
         );
         return IPF_Shortcuts::RenderToResponse('admin/delete.html', $context, $request);
     }
@@ -568,6 +571,7 @@ class IPF_Admin_Model{
             'search_value' => $this->search_value,
             'lapp'=>$lapp,
             'lmodel'=>$lmodel,
+            'indexpage_url'=>IPF::get('indexpage_url','/'),
         );
         return IPF_Shortcuts::RenderToResponse('admin/items.html', $context, $request);
     }
index 5116e647f8d6c949ab59d22470d98521c315c1de..a48e7366aa562f912d83350016c05e67d0fbe247 100644 (file)
 <div id="container">
     <div id="header">
         <div id="branding">
-            <h1 id="site-name"><a href="/">{$admin_title}</a></h1>
+            <h1 id="site-name"><a href={if isset($indexpage_url)}"{$indexpage_url}"{else}"/"{/if}>{$admin_title}</a></h1>
         </div>
         {block usertools}<div id="user-tools">Welcome, <strong>{$user}</strong>. <a href="{url 'IPF_Admin_Views_Logout'}">Log out</a><br /><span id="ipfver">Version: {$IPF_VER}</span></div>{/block}
     </div>
-       {block breadcrumbs}{/block}
+    {block breadcrumbs}{/block}
     {block content}{/block}
     <div id="footer"></div>
 </div>
index 103a8af5b828dcf276481c530d0ff54b8ae8a935..86fcefb6114bca89fedb2ab603d02128c09a098c 100644 (file)
@@ -48,6 +48,7 @@ function IPF_Admin_Views_Index($request, $match){
         'app_list' => $app_list,
         'admin_log' => $admin_log,
         'admin_title' => IPF::get('admin_title'),
+        'indexpage_url'=>IPF::get('indexpage_url','/'),
     );
     return IPF_Shortcuts::RenderToResponse('admin/index.html', $context, $request);
 }
@@ -212,7 +213,7 @@ function IPF_Admin_Views_ChangePassword($request, $match){
                     'lapp'=>$lapp,
                     'lmodel'=>$lmodel,
                     'admin_title' => IPF::get('admin_title'),
-
+                    'indexpage_url'=>IPF::get('indexpage_url','/'),
                 );
                 return IPF_Shortcuts::RenderToResponse('admin/changepassword.html', $context, $request);
             }
@@ -246,6 +247,7 @@ function IPF_Admin_Views_Login($request, $match){
        'page_title' => IPF::get('admin_title'),
        'form' => $form,
        'admin_title' => IPF::get('admin_title'),
+       'indexpage_url'=>IPF::get('indexpage_url','/'),
     );
     return IPF_Shortcuts::RenderToResponse('admin/login.html', $context, $request);
 }
@@ -255,6 +257,7 @@ function IPF_Admin_Views_Logout($request, $match){
     $context = array(
        'page_title' => IPF::get('admin_title'),
        'admin_title' => IPF::get('admin_title'),
+       'indexpage_url'=>IPF::get('indexpage_url','/'),
     );
     return IPF_Shortcuts::RenderToResponse('admin/logout.html', $context, $request);
 }
@@ -267,25 +270,25 @@ function cmp($a, $b){
 }
 
 function dir_recursive($dir, $path=DIRECTORY_SEPARATOR, $level=''){
-       $dirtree = array();
-       if ($level=='')
-               $dirtree[] = array('path'=>'', 'name'=>'Root Folder');
-       $dd = array();
+    $dirtree = array();
+    if ($level=='')
+        $dirtree[] = array('path'=>'', 'name'=>'Root Folder');
+    $dd = array();
     if ($dh = @opendir($dir)) {
         while (($file = readdir($dh)) !== false) {
-               if (($file=='.') || ($file=='..')) continue;
-               if (filetype($dir . $file)=='dir')
-                       $dd[] = $file;
+            if (($file=='.') || ($file=='..')) continue;
+            if (filetype($dir . $file)=='dir')
+                $dd[] = $file;
         }
-               closedir($dh);
-       sort($dd);
-       foreach($dd as $file){
-               $dirtree[] = array('path'=>$path.$file, 'name'=>$level.$file);
-               $dirtree = array_merge($dirtree, dir_recursive($dir.$file.DIRECTORY_SEPARATOR, $path.$file.DIRECTORY_SEPARATOR, $level.'--'));
-       }        
+        closedir($dh);
+        sort($dd);
+        foreach($dd as $file){
+            $dirtree[] = array('path'=>$path.$file, 'name'=>$level.$file);
+            $dirtree = array_merge($dirtree, dir_recursive($dir.$file.DIRECTORY_SEPARATOR, $path.$file.DIRECTORY_SEPARATOR, $level.'--'));
+        }        
     }
     return $dirtree;
-       //print_r($dirtree);
+    //print_r($dirtree);
 }
 
 function IPF_Admin_Views_FileBrowser($request, $match){
@@ -303,26 +306,26 @@ function IPF_Admin_Views_FileBrowser($request, $match){
     $dir = $upload_path.$curr_dir;
 
     if ($request->method=="GET"){
-       if (@$request->GET['delete']){
-               $del = $dir.$request->GET['delete'];
-               @IPF_Utils::removeDirectories($del);
-       }
+        if (@$request->GET['delete']){
+            $del = $dir.$request->GET['delete'];
+            @IPF_Utils::removeDirectories($del);
+        }
     }
     
     if ($request->method=="POST"){
-       if (@$request->POST['new_folder']!='')
-               @mkdir($dir.$request->POST['new_folder']);
-
-       if (@$request->POST['new_name']!='')
-               @rename($dir.$request->POST['old_name'], $dir.$request->POST['new_name']);
-               
-       if (@$request->POST['action']=='move'){
-               @rename($dir.$request->POST['old_name'], $upload_path.$request->POST['move'].DIRECTORY_SEPARATOR.$request->POST['old_name']);
-       }
-       if (@$_FILES['file']){
-                       $uploadfile = $dir . basename($_FILES['file']['name']);
-                       @move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile); 
-       }
+        if (@$request->POST['new_folder']!='')
+            @mkdir($dir.$request->POST['new_folder']);
+
+        if (@$request->POST['new_name']!='')
+            @rename($dir.$request->POST['old_name'], $dir.$request->POST['new_name']);
+            
+        if (@$request->POST['action']=='move'){
+            @rename($dir.$request->POST['old_name'], $upload_path.$request->POST['move'].DIRECTORY_SEPARATOR.$request->POST['old_name']);
+        }
+        if (@$_FILES['file']){
+            $uploadfile = $dir . basename($_FILES['file']['name']);
+            @move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile); 
+        }
     }
     
     $id = 1;
@@ -331,38 +334,38 @@ function IPF_Admin_Views_FileBrowser($request, $match){
     if ($dh = @opendir($dir)) {
         while (($file = readdir($dh)) !== false) {
             if ($file=='.')
-                       continue;
-               if (($curr_dir=='') && ($file=='..'))
-                       continue;
-               if (filetype($dir . $file)=='dir'){
-                       $dirs[] = array('id'=>$id, 'name'=>$file);
-                       $id++;
-               }
-               else{
-                       
-                       $sx = getimagesize($dir.$file);
-                       if ($sx){
-                               $image = '1';
-                               $type = str_replace('image/','',$sx['mime']).' '.$sx[0].'x'.$sx[1];
-                               if ($sx[0]<=200){
-                                       $zw = $sx[0];
-                                       $zh = $sx[1];
-                               }
-                               else {
-                                       $zw = 200;
-                                       $prop = (float)$sx[1] / (float)$sx[0];
-                                       $zh = (int)(200.0 * $prop);
-                               }
-                       }
-                       else {
-                               $image = '0';
-                               $type = 'binary';
-                               $zw = 200;
-                               $zh = 150;
-                       }
-                       $files[] = array('id'=>$id, 'name'=>$file, 'image'=>$image, 'type'=>$type, 'zw'=>$zw, 'zh'=>$zh, 'size'=>filesize($dir . $file));
-                       $id++;
-               }
+                continue;
+            if (($curr_dir=='') && ($file=='..'))
+                continue;
+            if (filetype($dir . $file)=='dir'){
+                $dirs[] = array('id'=>$id, 'name'=>$file);
+                $id++;
+            }
+            else{
+                
+                $sx = getimagesize($dir.$file);
+                if ($sx){
+                    $image = '1';
+                    $type = str_replace('image/','',$sx['mime']).' '.$sx[0].'x'.$sx[1];
+                    if ($sx[0]<=200){
+                        $zw = $sx[0];
+                        $zh = $sx[1];
+                    }
+                    else {
+                        $zw = 200;
+                        $prop = (float)$sx[1] / (float)$sx[0];
+                        $zh = (int)(200.0 * $prop);
+                    }
+                }
+                else {
+                    $image = '0';
+                    $type = 'binary';
+                    $zw = 200;
+                    $zh = 150;
+                }
+                $files[] = array('id'=>$id, 'name'=>$file, 'image'=>$image, 'type'=>$type, 'zw'=>$zw, 'zh'=>$zh, 'size'=>filesize($dir . $file));
+                $id++;
+            }
         }
         closedir($dh);
     }
@@ -370,23 +373,24 @@ function IPF_Admin_Views_FileBrowser($request, $match){
     usort(&$files, 'cmp');
     
     $dirtree = dir_recursive($upload_path);
-        
+
     $pth = explode(DIRECTORY_SEPARATOR,$curr_dir);
     $path = array();
     $cd = '/admin/filebrowser/';
     foreach($pth as $p){
-       $cd.=$p.DIRECTORY_SEPARATOR;
-       $path[] = array('cd'=>$cd, 'name'=>$p);
+        $cd.=$p.DIRECTORY_SEPARATOR;
+        $path[] = array('cd'=>$cd, 'name'=>$p);
     }
         
     $context = array(
         'page_title' => __('File Browser'),
         'dirtree' => $dirtree,
         'dirs' => $dirs,
-       'files' => $files,
-       'path' => $path,
+        'files' => $files,
+        'path' => $path,
         'upload_url' => $upload_url,
-       'curr_dir' => $curr_dir,
+        'curr_dir' => $curr_dir,
+        'indexpage_url'=>IPF::get('indexpage_url','/'),
     );
     return IPF_Shortcuts::RenderToResponse('admin/filebrowser.html', $context, $request);
 }
@@ -394,14 +398,14 @@ function IPF_Admin_Views_FileBrowser($request, $match){
 function IPF_Admin_Views_FileBrowserRename($request, $match){
     $ca = IPF_Admin_App::checkAdminAuth($request);
     if ($ca!==true) return $ca;
-       
+    
     $old_name = @$request->POST['old_value'];
-       $name = @$request->POST['value'];
-       $curr_dir = @$request->POST['curr_dir'];
-       if ($name=='')
+    $name = @$request->POST['value'];
+    $curr_dir = @$request->POST['curr_dir'];
+    if ($name=='')
         $name==$old_name;
     else
-       $name = $name;
+        $name = $name;
     return new IPF_HTTP_Response($name);
 }