From 29c1913f47976c8a1f6a0232d590344b8ac1be1b Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 26 Apr 2013 11:42:09 +1000 Subject: [PATCH] Theme work with focusbusiness and baseadmin Improvements to NAVBAR, updates to StaticList methods, other minor items Enable product category rendering and other minor improvements Added ADSL-large category price plan --- application/classes/Auth/OSB.php | 81 +- application/classes/Company.php | 2 +- application/classes/Config.php | 14 +- application/classes/Controller/Account.php | 24 +- application/classes/Controller/Login.php | 2 + .../classes/Controller/TemplateDefault.php | 27 +- application/classes/Controller/Tree.php | 131 - .../classes/Controller/User/Account.php | 61 +- application/classes/Controller/Welcome.php | 10 +- application/classes/Kohana.php | 48 +- application/classes/Menu.php | 29 + application/classes/Model/Account.php | 32 +- application/classes/Model/Country.php | 2 + application/classes/Model/Currency.php | 1 + application/classes/Model/Group.php | 2 +- application/classes/Model/Module.php | 2 +- application/classes/Model/Module/Method.php | 31 +- application/classes/ORM.php | 2 +- application/classes/ORM/OSB.php | 133 +- application/classes/Request.php | 26 + application/classes/StaticList.php | 57 +- application/classes/StaticList/Module.php | 12 +- application/classes/StaticList/PriceType.php | 10 +- .../classes/StaticList/RecurSchedule.php | 32 +- application/classes/StaticList/RecurType.php | 10 +- application/classes/StaticList/SweepType.php | 10 +- application/classes/StaticList/Title.php | 6 +- application/classes/StaticList/YesNo.php | 10 +- application/classes/URL.php | 1 - application/config/config.php | 5 +- application/media/js/jquery.jstree-1.0rc3.js | 4551 ----------------- .../js/jquery.jstree.themes/apple/bg.jpg | Bin 331 -> 0 bytes .../media/js/jquery.jstree.themes/apple/d.png | Bin 7765 -> 0 bytes .../jquery.jstree.themes/apple/dot_for_ie.gif | Bin 43 -> 0 bytes .../js/jquery.jstree.themes/apple/style.css | 61 - .../jquery.jstree.themes/apple/throbber.gif | Bin 1849 -> 0 bytes .../js/jquery.jstree.themes/classic/d.gif | Bin 3003 -> 0 bytes .../js/jquery.jstree.themes/classic/d.png | Bin 7535 -> 0 bytes .../classic/dot_for_ie.gif | Bin 43 -> 0 bytes .../js/jquery.jstree.themes/classic/style.css | 77 - .../jquery.jstree.themes/classic/throbber.gif | Bin 1849 -> 0 bytes .../js/jquery.jstree.themes/default-rtl/d.gif | Bin 2872 -> 0 bytes .../js/jquery.jstree.themes/default-rtl/d.png | Bin 7459 -> 0 bytes .../jquery.jstree.themes/default-rtl/dots.gif | Bin 132 -> 0 bytes .../default-rtl/style.css | 84 - .../default-rtl/throbber.gif | Bin 1849 -> 0 bytes .../js/jquery.jstree.themes/default/d.gif | Bin 2944 -> 0 bytes .../js/jquery.jstree.themes/default/d.png | Bin 7635 -> 0 bytes .../js/jquery.jstree.themes/default/style.css | 74 - .../jquery.jstree.themes/default/throbber.gif | Bin 1849 -> 0 bytes application/media/js/yaml/yaml-focusfix.js | 72 - application/media/theme/yaml/css/base.css | 250 - application/media/theme/yaml/css/content.css | 225 - .../media/theme/yaml/css/images/bg_body.gif | Bin 7227 -> 0 bytes .../media/theme/yaml/css/images/bg_dotted.png | Bin 127 -> 0 bytes .../media/theme/yaml/css/images/bg_head.png | Bin 228 -> 0 bytes .../media/theme/yaml/css/images/bg_logo.png | Bin 915 -> 0 bytes .../theme/yaml/css/images/bg_main_bottom.png | Bin 262 -> 0 bytes .../theme/yaml/css/images/bg_main_top.png | Bin 260 -> 0 bytes .../yaml/css/navigation/images/bg_hnav1.png | Bin 306 -> 0 bytes .../css/navigation/images/bg_hnav1_hover.png | Bin 406 -> 0 bytes .../css/navigation/images/bg_hnav2_hover.png | Bin 291 -> 0 bytes .../theme/yaml/css/navigation/nav_buttons.css | 16 - application/media/theme/yaml/css/page.css | 14 - .../theme/yaml/css/print/print_100_draft.css | 74 - .../media/theme/yaml/css/screen/basemod.css | 39 - .../theme/yaml/css/screen/contentmod.css | 145 - application/views/account/user/edit.php | 145 +- .../views/account/user/resetpassword.php | 33 +- .../views/theme/baseadmin/pages/navbar.php | 10 + application/views/theme/yaml/page.php | 115 - .../Product/Category/Template/Adslcompare.php | 22 + .../Category/Template/Adslcomparelarge.php | 22 + modules/adsl/classes/Service/Traffic/Adsl.php | 2 - .../category/list/adslcompare-large.php | 75 + .../product/category/list/adslcompare.php | 61 + modules/cart/classes/Model/Cart.php | 2 +- modules/domain/classes/Service/Domain.php | 2 - .../email/classes/Model/Email/Template.php | 2 +- modules/export/classes/Export/Quicken.php | 2 +- .../Product/Category/Template/Hostcompare.php | 22 + .../product/category/list/hostcompare.php | 52 + .../classes/Controller/Task/Invoice.php | 4 +- .../invoice/classes/Invoice/Tcpdf/Default.php | 2 +- modules/invoice/classes/Model/Invoice.php | 4 +- modules/invoice/views/invoice/user/email.php | 2 +- modules/invoice/views/invoice/user/view.php | 4 +- .../classes/Controller/Admin/Product.php | 225 +- .../product/classes/Controller/Product.php | 72 +- .../classes/Controller/Product/Category.php | 39 - modules/product/classes/Model/Product.php | 107 +- .../classes/Model/Product/Category.php | 86 +- .../Model/Product/Category/Translate.php | 2 + .../classes/Product/Category/Template.php | 25 + .../Product/Category/Template/Supercat.php | 20 + .../media/theme/focusbusiness/pages/plans.css | 442 ++ .../views/product/admin/ajaxtranslate.php | 26 + .../views/product/admin/ajaxtranslateform.php | 15 - modules/product/views/product/admin/edit.php | 76 + .../product/views/product/admin/update.php | 59 - .../product/category/admin/ajaxtranslate.php | 18 + .../views/product/category/admin/edit.php | 36 + .../product/views/product/category/list.php | 7 - .../views/product/category/list/supercat.php | 27 + .../views/product/category/list_item.php | 8 - .../product/views/product/category/view.php | 40 - modules/product/views/product/view.php | 95 +- modules/service/classes/Model/Service.php | 14 +- .../service/classes/Model/Service/Change.php | 2 +- .../service/classes/Model/Service/Plugin.php | 2 +- .../service/views/service/admin/update.php | 2 +- modules/service/views/service/admin/view.php | 2 +- modules/service/views/service/user/view.php | 2 +- modules/ssl/views/ssl/admin/add_view.php | 2 +- 114 files changed, 1732 insertions(+), 6797 deletions(-) delete mode 100644 application/classes/Controller/Tree.php create mode 100644 application/classes/Menu.php delete mode 100644 application/media/js/jquery.jstree-1.0rc3.js delete mode 100644 application/media/js/jquery.jstree.themes/apple/bg.jpg delete mode 100644 application/media/js/jquery.jstree.themes/apple/d.png delete mode 100644 application/media/js/jquery.jstree.themes/apple/dot_for_ie.gif delete mode 100644 application/media/js/jquery.jstree.themes/apple/style.css delete mode 100644 application/media/js/jquery.jstree.themes/apple/throbber.gif delete mode 100644 application/media/js/jquery.jstree.themes/classic/d.gif delete mode 100644 application/media/js/jquery.jstree.themes/classic/d.png delete mode 100644 application/media/js/jquery.jstree.themes/classic/dot_for_ie.gif delete mode 100644 application/media/js/jquery.jstree.themes/classic/style.css delete mode 100644 application/media/js/jquery.jstree.themes/classic/throbber.gif delete mode 100644 application/media/js/jquery.jstree.themes/default-rtl/d.gif delete mode 100644 application/media/js/jquery.jstree.themes/default-rtl/d.png delete mode 100644 application/media/js/jquery.jstree.themes/default-rtl/dots.gif delete mode 100644 application/media/js/jquery.jstree.themes/default-rtl/style.css delete mode 100644 application/media/js/jquery.jstree.themes/default-rtl/throbber.gif delete mode 100644 application/media/js/jquery.jstree.themes/default/d.gif delete mode 100644 application/media/js/jquery.jstree.themes/default/d.png delete mode 100644 application/media/js/jquery.jstree.themes/default/style.css delete mode 100644 application/media/js/jquery.jstree.themes/default/throbber.gif delete mode 100644 application/media/js/yaml/yaml-focusfix.js delete mode 100644 application/media/theme/yaml/css/base.css delete mode 100644 application/media/theme/yaml/css/content.css delete mode 100644 application/media/theme/yaml/css/images/bg_body.gif delete mode 100644 application/media/theme/yaml/css/images/bg_dotted.png delete mode 100644 application/media/theme/yaml/css/images/bg_head.png delete mode 100644 application/media/theme/yaml/css/images/bg_logo.png delete mode 100644 application/media/theme/yaml/css/images/bg_main_bottom.png delete mode 100644 application/media/theme/yaml/css/images/bg_main_top.png delete mode 100644 application/media/theme/yaml/css/navigation/images/bg_hnav1.png delete mode 100644 application/media/theme/yaml/css/navigation/images/bg_hnav1_hover.png delete mode 100644 application/media/theme/yaml/css/navigation/images/bg_hnav2_hover.png delete mode 100644 application/media/theme/yaml/css/navigation/nav_buttons.css delete mode 100644 application/media/theme/yaml/css/page.css delete mode 100644 application/media/theme/yaml/css/print/print_100_draft.css delete mode 100644 application/media/theme/yaml/css/screen/basemod.css delete mode 100644 application/media/theme/yaml/css/screen/contentmod.css create mode 100644 application/views/theme/baseadmin/pages/navbar.php delete mode 100644 application/views/theme/yaml/page.php create mode 100644 modules/adsl/classes/Product/Category/Template/Adslcompare.php create mode 100644 modules/adsl/classes/Product/Category/Template/Adslcomparelarge.php create mode 100644 modules/adsl/views/product/category/list/adslcompare-large.php create mode 100644 modules/adsl/views/product/category/list/adslcompare.php create mode 100644 modules/host/classes/Product/Category/Template/Hostcompare.php create mode 100644 modules/host/views/product/category/list/hostcompare.php delete mode 100644 modules/product/classes/Controller/Product/Category.php create mode 100644 modules/product/classes/Product/Category/Template.php create mode 100644 modules/product/classes/Product/Category/Template/Supercat.php create mode 100644 modules/product/media/theme/focusbusiness/pages/plans.css create mode 100644 modules/product/views/product/admin/ajaxtranslate.php delete mode 100644 modules/product/views/product/admin/ajaxtranslateform.php create mode 100644 modules/product/views/product/admin/edit.php delete mode 100644 modules/product/views/product/admin/update.php create mode 100644 modules/product/views/product/category/admin/ajaxtranslate.php create mode 100644 modules/product/views/product/category/admin/edit.php delete mode 100644 modules/product/views/product/category/list.php create mode 100644 modules/product/views/product/category/list/supercat.php delete mode 100644 modules/product/views/product/category/list_item.php delete mode 100644 modules/product/views/product/category/view.php diff --git a/application/classes/Auth/OSB.php b/application/classes/Auth/OSB.php index 3f2e01d2..549d1b6e 100644 --- a/application/classes/Auth/OSB.php +++ b/application/classes/Auth/OSB.php @@ -31,82 +31,21 @@ class Auth_OSB extends Auth_ORM { if (Config::sitemode() == Kohana::DEVELOPMENT) SystemMessage::add(array('title'=>'Debug','type'=>'debug','body'=>Debug::vars(array('user'=>$uo->username,'r'=>$role)))); - if (! empty($role)) { - // Get the module details - $mo = ORM::factory('Module',array('name'=>Request::current()->controller())); - if (! $mo->loaded() OR ! $mo->status) { - SystemMessage::add(array( - 'title'=>'Module is not defined or active in the Database', - 'type'=>'warning', - 'body'=>sprintf('Module not defined: %s',Request::current()->controller()), - )); + if (! empty($role) AND Request::current()->mmo()) { + // If the role has the authorisation to run the method + $gmo = ORM::factory('Group_Method') + ->where('method_id','=',Request::current()->mmo()->id); - } else { - if (Request::current()->directory()) - $method_name = sprintf('%s_%s',Request::current()->directory(),Request::current()->action()); - else - $method_name = Request::current()->action(); - - // Get the method number - $mmo = ORM::factory('Module_Method',array('module_id'=>$mo->id,'name'=>$method_name)); - if (! $mmo->loaded()) { - SystemMessage::add(array( - 'title'=>'Method is not defined or active in the Database', - 'type'=>'warning', - 'body'=>sprintf('Method not defined: %s for %s',Request::current()->action(),$mo->name), - )); - - } else { - // If the role has the authorisation to run the method - $gmo = ORM::factory('Group_Method') - ->where('method_id','=',$mmo->id); - - $roles = ''; - foreach ($gmo->find_all() as $gm) { - $roles .= ($roles ? '|' : '').$gm->group->name; - - // $gm->group->id == 0 means all users. - if ($gm->group->id == 0 OR $uo->has_any('group',$gm->group->list_childgrps(TRUE))) { - $status = TRUE; - $roles = ''; - - break; - } - } - - if (! $status) { - if (Config::sitemode() == Kohana::DEVELOPMENT) - SystemMessage::add(array( - 'title'=>'User is not authorised in Database', - 'type'=>'debug', - 'body'=>sprintf('Role(s) checked: %s
User: %s
Module: %s
Method: %s',$roles,$uo->username,$mo->name,$mmo->name), - )); - } + foreach ($gmo->find_all() as $gm) + // $gm->group->id == 0 means all users. + if ($gm->group->id == 0 OR $uo->has_any('group',$gm->group->list_childgrps(TRUE))) { + $status = TRUE; + break; } - } - - if (Config::sitemode() == Kohana::DEVELOPMENT) - SystemMessage::add(array( - 'title'=>'Debug', - 'type'=>'debug', - 'body'=>sprintf('User: %s, Module: %s, Method: %s, Role: %s, Status: %s, Data: %s', - $uo->username,Request::current()->controller(),Request::current()->action(),$role,$status,$debug))); // There is no role, so the method should be allowed to run as anonymous - } else { - if (Config::sitemode() == Kohana::DEVELOPMENT) - SystemMessage::add(array( - 'title'=>'Debug', - 'type'=>'debug', - 'body'=>sprintf('User: %s, Module: %s, Method: %s, Status: %s, Data: %s', - $uo->username,Request::current()->controller(),Request::current()->action(),'No Role Default Access',$debug))); - + } else $status = TRUE; - } - - } else { - if (Config::sitemode() == Kohana::DEVELOPMENT) - SystemMessage::add(array('title'=>'Debug','type'=>'debug','body'=>'No user logged in')); } return $status; diff --git a/application/classes/Company.php b/application/classes/Company.php index 42d20934..213a1ff9 100644 --- a/application/classes/Company.php +++ b/application/classes/Company.php @@ -63,7 +63,7 @@ class Company { } public function language() { - return $this->so->language->iso; + return $this->so->language; } public function logo() { diff --git a/application/classes/Config.php b/application/classes/Config.php index 45ee3119..07a801b4 100644 --- a/application/classes/Config.php +++ b/application/classes/Config.php @@ -88,6 +88,10 @@ class Config extends Kohana_Config { return ($ao = Auth::instance()->get_user() AND is_object($ao)) ? HTML::anchor(URL::link('user','account/edit'),$ao->name()) : HTML::anchor('login',_('Login')); } + public static function logout_uri() { + return ($ao = Auth::instance()->get_user() AND is_object($ao)) ? HTML::anchor('logout','Logout',array('class'=>'lnk_logout')) : ''; + } + public static function logo() { return HTML::image(static::logo_uri(),array('class'=>'headlogo','alt'=>_('Logo'))); } @@ -110,11 +114,15 @@ class Config extends Kohana_Config { if (! count($result)) { // We need to know our site here, so that we can subsequently load our enabled modules. if (PHP_SAPI === 'cli') { - if (! $site = Minion_CLI::options('site')) + if (! ($site = Minion_CLI::options('site'))) { // @todo Need to figure out how to make this CLI error nicer. - throw new Minion_Exception_InvalidTask(_('Cant figure out the site, use --site= for CLI')); - else + #throw new Minion_Exception_InvalidTask(_('Cant figure out the site, use --site= for CLI')); + echo _('Cant figure out the site, use --site= for CLI')."\n"; + die(); + + } else $_SERVER['SERVER_NAME'] = $site; + } foreach (ORM::factory('Module')->list_external() as $mo) diff --git a/application/classes/Controller/Account.php b/application/classes/Controller/Account.php index 4f68068d..1b28e451 100644 --- a/application/classes/Controller/Account.php +++ b/application/classes/Controller/Account.php @@ -11,23 +11,25 @@ */ class Controller_Account extends Controller_TemplateDefault { public function action_group() { + // List all available groups for this user. $output = ''; - $cg = $this->ao->group->find_all(); - - foreach ($cg as $go) { + foreach ($this->ao->groups() as $go) $output .= sprintf('Group %s: %s
',$go->id,$go->display('name')); - foreach ($go->list_childgrps(TRUE) as $cgo) - $output .= sprintf('- %s: %s (%s)
',$cgo->id,$cgo->display('name'),$cgo->parent_id); + Block::factory() + ->title('Group Structure') + ->body($output); - $output .= sprintf('END Group %s

',$go->id); - } + // List all available methods for this user. + $output = ''; - Block::add(array( - 'title'=>'Group Structure', - 'body'=>$output, - )); + foreach ($this->ao->methods() as $mmo) + $output .= sprintf('Module: %s, Method %s: %s
',$mmo->module->name,$mmo->name,$mmo->url()); + + Block::factory() + ->title('Available Methods') + ->body($output); } } ?> diff --git a/application/classes/Controller/Login.php b/application/classes/Controller/Login.php index 076fb38f..2a880956 100644 --- a/application/classes/Controller/Login.php +++ b/application/classes/Controller/Login.php @@ -87,6 +87,8 @@ class Controller_Login extends lnApp_Controller_Login { 'style'=>array('css/login.css'=>'screen'), )); } + + $this->template->shownavbar = FALSE; } } ?> diff --git a/application/classes/Controller/TemplateDefault.php b/application/classes/Controller/TemplateDefault.php index e7ed22d7..b23f5d4d 100644 --- a/application/classes/Controller/TemplateDefault.php +++ b/application/classes/Controller/TemplateDefault.php @@ -16,36 +16,11 @@ class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault { protected $ao; public function __construct(Request $request, Response $response) { - if (Config::theme()) - $this->template = Config::theme().'/page'; + $this->template = Config::theme().'/page'; return parent::__construct($request,$response); } - protected function _headimages() { - // This is where we should be able to change our country - // @todo To implement - $co = Config::country(); - HeadImages::add(array( - 'img'=>sprintf('img/country/%s.png',strtolower($co->two_code)), - 'attrs'=>array('onclick'=>"target='_blank';",'title'=>$co->display('name')) - )); - - return HeadImages::factory(); - } - - protected function _left() { - if ($this->template->left) - return $this->template->left; - - elseif (Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__)) - return Controller_Tree::js(); - } - - protected function _right() { - return ($this->template->right) ? $this->template->right : ''; - } - public function before() { // If our action doesnt exist, no point processing any further. if (! method_exists($this,'action_'.Request::current()->action())) diff --git a/application/classes/Controller/Tree.php b/application/classes/Controller/Tree.php deleted file mode 100644 index f6e27a8b..00000000 --- a/application/classes/Controller/Tree.php +++ /dev/null @@ -1,131 +0,0 @@ -request->param('id')) AND isset($_REQUEST['id'])) ? substr($_REQUEST['id'],2) : $this->request->param('id'); - $user = Auth::instance()->get_user(); - - if ($user) { - if (! $id) { - $modules = array(); - foreach ($user->groups() as $go) - foreach ($go->list_parentgrps(TRUE) as $cgo) - foreach ($cgo->module_method->find_all() as $mmo) - if ($mmo->menu_display AND empty($modules[$mmo->module_id])) - $modules[$mmo->module_id] = $mmo->module; - - Sort::MAsort($modules,'name'); - - foreach ($modules as $id => $mo) - if (! $mo->parent_id) - array_push($data,array('id'=>$id,'name'=>$mo->name,'state'=>'closed')); - - } else { - $idx = NULL; - if (preg_match('/_/',$id)) - list($id,$idx) = explode('_',$id,2); - - $mo = ORM::factory('Module',$id); - - $methods = array(); - if ($mo->loaded()) { - foreach ($mo->module_method->find_all() as $mmo) - if ($mmo->menu_display) - foreach ($mmo->group->find_all() as $gmo) - if ($user->has_any('group',$gmo->list_childgrps(TRUE))) - $methods[$mmo->id] = $mmo; - - Sort::MASort($modules,'name'); - - $subdata = array(); - foreach ($methods as $id => $mmo) { - if (preg_match('/_/',$mmo->name)) { - list($mode,$action) = explode('_',$mmo->name); - - $url = URL::link($mode,$mmo->module->name.'/'.$action,TRUE); - - } else { - $url = URL::site($mmo->module->name.'/'.$mmo->name); - } - - // We can split our menus into sub menus using the _ char. - if (preg_match('/_/',$mmo->name)) { - list($sub,$name) = explode('_',$mmo->name,2); - $subdata[$sub][$name]['name'] = preg_replace('/^(.*: )/','',$mmo->notes); - $subdata[$sub][$name]['id'] = sprintf('%s_%s',$mmo->module_id,$id); - $subdata[$sub][$name]['href'] = (empty($details['page']) ? $url : $details['page']); - - } else { - // We dont want to show these items again, if we can through on a submenu - if (! $idx) - array_push($data,array( - 'id'=>sprintf('%s_%s',$mmo->module_id,$id), - 'name'=>$mmo->name, - 'state'=>'none', - 'attr_id'=>sprintf('%s_%s',$mmo->module->name,$id), - 'attr_href'=>(empty($details['page']) ? $url : $details['page']) - )); - } - } - - // If our sub menus only have 1 branch, then we'll display it as normal. - if (count($subdata) == 1) { - $sk = array_keys($subdata); - $idx = array_shift($sk); - } - - if ($idx) - foreach ($subdata[$idx] as $k=>$v) { - array_push($data,array( - 'id'=>$v['id'], - 'name'=>$v['name'], - 'state'=>'none', - 'attr_id'=>$v['id'], - 'attr_href'=>$v['href'] - )); - } - - else - foreach ($subdata as $t=>$x) - array_push($data,array('id'=>$mmo->module_id.'_'.$t,'name'=>$t,'state'=>'closed')); - - } - } - } - - $this->output = array(); - - foreach ($data as $branch) { - array_push($this->output,array( - 'attr'=>array('id'=>sprintf('B_%s',$branch['id'])), - 'state'=>$branch['state'], - 'data'=>array('title'=>$branch['name']), - 'attr'=>array('id'=>sprintf('N_%s',$branch['id']),'href'=>empty($branch['attr_href']) ? URL::site(sprintf('%s/menu',$branch['name'])) : $branch['attr_href']), - ) - ); - } - - return parent::action_json($data); - } -} -?> diff --git a/application/classes/Controller/User/Account.php b/application/classes/Controller/User/Account.php index 49075694..60b737eb 100644 --- a/application/classes/Controller/User/Account.php +++ b/application/classes/Controller/User/Account.php @@ -25,34 +25,34 @@ class Controller_User_Account extends Controller_Account { // Run validation and save if ($this->ao->changed()) if ($this->ao->check()) { - SystemMessage::add(array( - 'title'=>_('Record updated'), - 'type'=>'info', - 'body'=>_('Your account record has been updated.') - )); + SystemMessage::factory() + ->title('Record updated') + ->type('success') + ->body(_('Your account record has been updated.')); $this->ao->save(); } else { $output = ''; + + // @todo Need to check that this still works with the new bootstrap theming foreach ($this->ao->validation()->errors('forms/login') as $field => $error) $output .= sprintf('
  • %s %s
  • ',$field,$error); if ($output) $output = sprintf('',$output); - SystemMessage::add(array( - 'title'=>_('Record NOT updated'), - 'type'=>'error', - 'body'=>_('Your updates didnt pass validation.').'
    '.$output, - )); + SystemMessage::factory() + ->title(_('Record NOT updated')) + ->type('error') + ->body(_('Your updates didnt pass validation.').'
    '.$output); } - Block::add(array( - 'title'=>sprintf('%s: %s - %s',_('Account Edit'),$this->ao->accnum(),$this->ao->name(TRUE)), - 'body'=>View::factory($this->viewpath()) - ->set('record',$this->ao), - )); + Block::factory() + ->title(sprintf('Account: %s',$this->ao->accnum())) + ->title_icon('icon-wrench') + ->type('form-horizontal') + ->body(View::factory('account/user/edit')->set('o',$this->ao)); } public function action_resetpassword() { @@ -66,11 +66,10 @@ class Controller_User_Account extends Controller_Account { // Run validation and save if ($this->ao->changed()) if ($this->ao->check()) { - SystemMessage::add(array( - 'title'=>_('Record updated'), - 'type'=>'info', - 'body'=>_('Your account record has been updated.') - )); + SystemMessage::factory() + ->title('Record updated') + ->type('success') + ->body(_('Your account record has been updated.')); $this->ao->save(); @@ -80,25 +79,27 @@ class Controller_User_Account extends Controller_Account { HTTP::redirect('login'); } else { + // @todo Need to check that this still works with the new bootstrap theming $output = ''; + foreach ($this->ao->validation()->errors('forms/login') as $field => $error) $output .= sprintf('
  • %s %s
  • ',$field,$error); if ($output) $output = sprintf('',$output); - SystemMessage::add(array( - 'title'=>_('Record NOT updated'), - 'type'=>'error', - 'body'=>_('Your updates didnt pass validation.').'
    '.$output, - )); + SystemMessage::factory() + ->title(_('Record NOT updated')) + ->type('error') + ->body(_('Your updates didnt pass validation.').'
    '.$output); } - Block::add(array( - 'title'=>_('Password Reset'), - 'body'=>View::factory($this->viewpath()) - ->set('record',$this->ao), - )); + // @todo To add JS password validation (minimum length and both values equal) + Block::factory() + ->title(sprintf('Password Reset: %s',$this->ao->accnum())) + ->title_icon('icon-cog') + ->type('form-horizontal') + ->body(View::factory('account/user/resetpassword')->set('o',$this->ao)); } } ?> diff --git a/application/classes/Controller/Welcome.php b/application/classes/Controller/Welcome.php index 29ccdcc8..9e17c1e6 100644 --- a/application/classes/Controller/Welcome.php +++ b/application/classes/Controller/Welcome.php @@ -16,8 +16,14 @@ class Controller_Welcome extends Controller_TemplateDefault { if (! Kohana::$config->load('config')->appname) HTTP::redirect('guide/app'); - // @todo This should be in the DB or something. - HTTP::redirect('product/categorys'); + $output = ''; + + $output = View::factory('pages/welcome'); + Style::factory() + ->type('file') + ->data('media/css/pages/welcome.css'); + + $this->template->content = $output; } public function action_breadcrumb() { diff --git a/application/classes/Kohana.php b/application/classes/Kohana.php index 74b52840..7ff34ee2 100644 --- a/application/classes/Kohana.php +++ b/application/classes/Kohana.php @@ -10,6 +10,47 @@ * @license http://dev.osbill.net/license.html */ abstract class Kohana extends Kohana_Core { + /** + * Work out our Class Name as per Kohana's standards + */ + public static function classname($name) { + return str_replace(' ','_',ucwords(strtolower(str_replace('_',' ',$name)))); + } + + /** + * Find files using a multi-site enabled application + * + * In order of precedence, we'll return: + * 1) site-theme file, ie: site/X/THEME/${file} + * 2) site file, ie: site/X/${file} + * 3) theme file, ie: THEME/${file} + * 4) normal search, ie: ${file} + */ + public static function find_file($dir,$file,$ext=NULL,$array=FALSE) { + // Limit our scope to the following dirs + // @note, we cannot have classes checked, since Config() doesnt exist yet + $dirs = array('views','media'); + + if (! in_array($dir,$dirs) OR PHP_SAPI === 'cli') + return parent::find_file($dir,$file,$ext,$array); + + // Our search order. + $prefixes = array( + sprintf('site/%s/%s/',Config::siteid(),Config::theme()), + sprintf('site/%s/',Config::siteid()), + Config::theme().'/', + '', + ); + + foreach ($prefixes as $p) { + if ($x = parent::find_file($dir,$p.$file,$ext,$array)) + return $x; + } + + // We found a site path. + return $x; + } + /** * @compat Restore KH 3.1 functionality * @var boolean True if Kohana is running from the command line @@ -45,12 +86,5 @@ abstract class Kohana extends Kohana_Core { return $result; } - - /** - * Work out our Class Name as per Kohana's standards - */ - public static function classname($name) { - return str_replace(' ','_',ucwords(strtolower(str_replace('_',' ',$name)))); - } } ?> diff --git a/application/classes/Menu.php b/application/classes/Menu.php new file mode 100644 index 00000000..c2614a98 --- /dev/null +++ b/application/classes/Menu.php @@ -0,0 +1,29 @@ +get_user(); + + foreach ($uo->methods() as $mmo) + if ($mmo->menu_display AND preg_match('/^'.$type.'_/',$mmo->name)) + if (empty($result[$mmo->id])) + $result[$mmo->id] = $mmo; + + return $result; + } +} +?> diff --git a/application/classes/Model/Account.php b/application/classes/Model/Account.php index 184516d5..08e0b9ba 100644 --- a/application/classes/Model/Account.php +++ b/application/classes/Model/Account.php @@ -35,7 +35,7 @@ class Model_Account extends Model_Auth_UserDefault { array('Config::date',array(':value')), ), 'status'=>array( - array('StaticList_YesNo::display',array(':value')), + array('StaticList_YesNo::get',array(':value')), ), ); @@ -50,7 +50,14 @@ class Model_Account extends Model_Auth_UserDefault { * Get the groups that an account belongs to */ public function groups() { - return $this->group->where_active()->find_all(); + $result = array(); + + foreach ($this->group->where_active()->find_all() as $go) + foreach ($go->list_parentgrps(TRUE) as $cgo) + if (empty($result[$cgo->id])) + $result[$cgo->id] = $cgo; + + return $result; } /** @@ -100,6 +107,27 @@ class Model_Account extends Model_Auth_UserDefault { return $alo->saved(); } + /** + * This function will extract the available methods for this account + * This is used both for menu options and method security + */ + public function methods() { + static $result = array(); + + // @todo We may want to optimise this with some session caching. + if ($result) + return $result; + + foreach ($this->groups() as $go) + foreach ($go->module_method->find_all() as $mmo) + if (empty($result[$mmo->id])) + $result[$mmo->id] = $mmo; + + Sort::MAsort($result,'module->name,name'); + + return $result; + } + /** * Return an account name */ diff --git a/application/classes/Model/Country.php b/application/classes/Model/Country.php index 0ea2d2bd..9fcca48a 100644 --- a/application/classes/Model/Country.php +++ b/application/classes/Model/Country.php @@ -10,6 +10,8 @@ * @license http://dev.osbill.net/license.html */ class Model_Country extends ORM_OSB { + protected $_form = array('id'=>'id','value'=>'name'); + public function currency() { return ORM::factory('Currency')->where('country_id','=',$this->id)->find(); } diff --git a/application/classes/Model/Currency.php b/application/classes/Model/Currency.php index 8248ecce..c00b8879 100644 --- a/application/classes/Model/Currency.php +++ b/application/classes/Model/Currency.php @@ -10,5 +10,6 @@ * @license http://dev.osbill.net/license.html */ class Model_Currency extends ORM_OSB { + protected $_form = array('id'=>'id','value'=>'name'); } ?> diff --git a/application/classes/Model/Group.php b/application/classes/Model/Group.php index d3e3557c..1e56e8f3 100644 --- a/application/classes/Model/Group.php +++ b/application/classes/Model/Group.php @@ -33,7 +33,7 @@ class Model_Group extends Model_Auth_RoleDefault { protected $_display_filters = array( 'status'=>array( - array('StaticList_YesNo::display',array(':value')), + array('StaticList_YesNo::get',array(':value')), ), ); diff --git a/application/classes/Model/Module.php b/application/classes/Model/Module.php index 07cff3ab..0be4513d 100644 --- a/application/classes/Model/Module.php +++ b/application/classes/Model/Module.php @@ -31,7 +31,7 @@ class Model_Module extends ORM_OSB { array('strtoupper',array(':value')), ), 'status'=>array( - array('StaticList_YesNo::display',array(':value')), + array('StaticList_YesNo::get',array(':value')), ), ); diff --git a/application/classes/Model/Module/Method.php b/application/classes/Model/Module/Method.php index 1124aa4e..81bcac2d 100644 --- a/application/classes/Model/Module/Method.php +++ b/application/classes/Model/Module/Method.php @@ -10,6 +10,10 @@ * @license http://dev.osbill.net/license.html */ class Model_Module_Method extends ORM_OSB { + // This module doesnt keep track of column updates automatically + protected $_created_column = FALSE; + protected $_updated_column = FALSE; + // Relationships protected $_belongs_to = array( 'module'=>array(), @@ -25,19 +29,24 @@ class Model_Module_Method extends ORM_OSB { 'name'=>'ASC', ); - protected $_display_filters = array( - 'menu_display'=>array( - array('StaticList_YesNo::display',array(':value')), - ), - ); + /** + * Calculate the description for this method on any menu link + */ + public function menu_display() { + // @todo The test for value equal 1 is for legacy, remove when all updated. + if ($this->menu_display AND $this->menu_display != 1) + return $this->menu_display; + else + return sprintf('%s: %s',$this->module->name,$this->name); + } - // This module doesnt keep track of column updates automatically - protected $_created_column = FALSE; - protected $_updated_column = FALSE; + public function url() { + if (! preg_match('/_/',$this->name)) + return NULL; - // Return the method name. - public function name() { - return sprintf('%s::%s',$this->module->name,$this->name); + list($type,$action) = preg_split('/_/',$this->name,2); + + return URL::link($type,$this->module->name.'/'.$action); } } ?> diff --git a/application/classes/ORM.php b/application/classes/ORM.php index d1125d91..40452060 100644 --- a/application/classes/ORM.php +++ b/application/classes/ORM.php @@ -47,7 +47,7 @@ abstract class ORM extends Kohana_ORM { if (isset($this->_object_formated[$column])) return $this->_object_formated[$column]; else - return HTML::nbsp($value); + return $value; } /** diff --git a/application/classes/ORM/OSB.php b/application/classes/ORM/OSB.php index b4304f82..756918ed 100644 --- a/application/classes/ORM/OSB.php +++ b/application/classes/ORM/OSB.php @@ -21,6 +21,9 @@ abstract class ORM_OSB extends ORM { // Our attribute values that need to be stored as serialized protected $_serialize_column = array(); + // Our attributes that should be converted to NULL when empty + protected $_nullifempty = array(); + // Our attributes used in forms. protected $_form = array(); @@ -36,6 +39,52 @@ abstract class ORM_OSB extends ORM { ); } + /** + * Try and (un)serialize our data, and if it fails, just return it. + */ + private function _serialize($data,$set=FALSE) { + try { + return $set ? serialize($data) : unserialize($data); + + // Maybe the data serialized? + } catch (Exception $e) { + return $data; + } + } + + /** + * Retrieve and Store DB BLOB data. + */ + private function _blob($data,$set=FALSE) { + try { + return $set ? gzcompress($this->_serialize($data,$set)) : $this->_serialize(gzuncompress($data)); + + // Maybe the data isnt compressed? + } catch (Exception $e) { + return $this->_serialize($data,$set); + } + } + + /** + * If a column is marked to be nullified if it is empty, this is where it is done. + */ + private function _nullifempty(array $array) { + foreach ($array as $k=>$v) { + if (is_array($v)) { + if (is_null($x=$this->_nullifempty($v))) + unset($array[$k]); + else + $array[$k] = $x; + + } else + if (! $v) + unset($array[$k]); + + } + + return count($array) ? $array : NULL; + } + /** * Auto process some data as it comes from the database * @see parent::__get() @@ -52,9 +101,10 @@ abstract class ORM_OSB extends ORM { // In case our blob hasnt been saved as one. try { - $this->_object[$column] = $this->blob($this->_object[$column]); + $this->_object[$column] = $this->_blob($this->_object[$column]); } catch(Exception $e) { +echo Debug::vars($e);die(); // @todo Log this exception echo Kohana_Exception::text($e), "\n"; echo debug_print_backtrace(); @@ -116,23 +166,6 @@ abstract class ORM_OSB extends ORM { } } - final public static function xform($table,$blank=FALSE) { - return ORM::factory($table)->formselect($blank); - } - - /** - * Retrieve and Store DB BLOB data. - */ - private function blob($data,$set=FALSE) { - try { - return $set ? gzcompress(serialize($data)) : unserialize(gzuncompress($data)); - - // Maybe the data isnt compressed? - } catch (Exception $e) { - return $set ? serialize($data) : unserialize($data); - } - } - public function config($key) { $mc = Config::instance()->module_config($this->_object_name); @@ -176,18 +209,6 @@ abstract class ORM_OSB extends ORM { return TRUE; } - public function xformselect($blank) { - $result = array(); - - if ($blank) - $result[] = ''; - - foreach ($this->find_all() as $o) - $result[$o->{$this->_form['id']}] = $o->{$this->_form['value']}; - - return $result; - } - public function keyget($column,$key=NULL) { if (is_null($key) OR ! is_array($this->$column)) return $this->$column; @@ -202,10 +223,19 @@ abstract class ORM_OSB extends ORM { public function save(Validation $validation = NULL) { // Find any fields that have changed, and process them. if ($this->_changed) - foreach ($this->_changed as $c) + foreach ($this->_changed as $c) { + // Convert to NULL + if (in_array($c,$this->_nullifempty)) { + if (is_array($this->_object[$c])) + $this->_object[$c] = $this->_nullifempty($this->_object[$c]); + + elseif (! $this->_object[$c]) + $this->_object[$c] = NULL; + } + // Any fields that are blobs, and encode them. - if ($this->_table_columns[$c]['data_type'] == 'blob') { - $this->_object[$c] = $this->blob($this->_object[$c],TRUE); + if (! is_null($this->_object[$c]) AND $this->_table_columns[$c]['data_type'] == 'blob') { + $this->_object[$c] = $this->_blob($this->_object[$c],TRUE); // We need to reset our auto_convert flag if (isset($this->_table_columns[$c]['auto_convert'])) @@ -215,14 +245,51 @@ abstract class ORM_OSB extends ORM { } elseif (is_array($this->_object[$c]) AND in_array($c,$this->_serialize_column)) { $this->_object[$c] = serialize($this->_object[$c]); } + } return parent::save($validation); } + public function status($render=FALSE) { + if (! isset($this->_table_columns['status'])) + return NULL; + + if (! $render) + return $this->display('status'); + + return View::factory(Config::theme().'/status') + ->set('label',$this->status ? 'label-success' : '') + ->set('status',$this->display('status')); + } + + /** + * Function help to find records that are active + */ + public function list_active() { + return $this->_where_active()->find_all(); + } + public function list_count($active=TRUE) { $x=($active ? $this->_where_active() : $this); return $x->find_all()->count(); } + + /** + * Return an array of data that can be used in a SELECT statement. + * The ID and VALUE is defined in the model for the select. + */ + public function list_select($blank=FALSE) { + $result = array(); + + if ($blank) + $result[] = ''; + + if ($this->_form AND array_intersect(array('id','value'),$this->_form)) + foreach ($this->find_all() as $o) + $result[$o->{$this->_form['id']}] = $o->{$this->_form['value']}; + + return $result; + } } ?> diff --git a/application/classes/Request.php b/application/classes/Request.php index 48910874..9b9e3716 100644 --- a/application/classes/Request.php +++ b/application/classes/Request.php @@ -27,5 +27,31 @@ class Request extends Kohana_Request { return parent::directory($directory); } + + /** + * Get our Module_Method object for this request + */ + public function mmo() { + static $result = FALSE; + + if (is_null($result) OR $result) + return $result; + + $result = NULL; + + $mo = ORM::factory('Module',array('name'=>$this->_controller)); + + if ($mo->loaded() AND $mo->status) { + $method = strtolower($this->_directory ? sprintf('%s_%s',$this->_directory,$this->_action) : $this->_action); + + // Get the method number + $mmo = ORM::factory('Module_Method',array('module_id'=>$mo->id,'name'=>$method)); + + if ($mmo->loaded()) + $result = $mmo; + } + + return $result; + } } ?> diff --git a/application/classes/StaticList.php b/application/classes/StaticList.php index d22700f8..05df60a2 100644 --- a/application/classes/StaticList.php +++ b/application/classes/StaticList.php @@ -10,33 +10,16 @@ * @license http://dev.osbill.net/license.html */ abstract class StaticList { - // This is our list of items that will be rendered - protected $list = array(); + // Our Static Items List + abstract protected function _table(); - /** - * Each static list type must provide the table function that contains - * the table of list and values. - */ - abstract protected function table(); - - public static function factory() { - throw new Kohana_Exception(':class is calling :method, when it should have its own method', - array(':class'=>get_called_class(),':method'=>__METHOD__)); - } - - /** - * Display a static name for a value - * - * @param key $id value to render - * @see _display() - */ - public static function display($value) { - return static::_display($value); - } + // To get an individual item from the table + // @note This must be declared in the child class due to static scope + //abstract public static function get($value); // Due to static scope, sometimes we need to call this function from the child class. - protected static function _display($id) { - $table = static::factory()->table(); + protected function _get($id) { + $table = $this->_table(); if (! $table) return 'No Table'; @@ -47,10 +30,13 @@ abstract class StaticList { } /** - * Lists our available keys + * Setup our class instantiation + * @note This must be declared in the child class due to static scope */ - public static function keys() { - return array_keys(static::factory()->table()); + public static function factory() { + $x = get_called_class(); + + return new $x; } /** @@ -59,13 +45,24 @@ abstract class StaticList { * @param string Form name to render * @param string Default value to populate in the Form input. */ - public static function form($name,$default='',$addblank=FALSE) { - $table = static::factory()->table(); + public static function form($name,$default='',$addblank=FALSE,array $attributes=NULL) { + $table = static::factory()->_table(); if ($addblank) $table = array_merge(array(''=>' '),$table); - return Form::Select($name,$table,$default); + return Form::Select($name,$table,$default,$attributes); + } + + /** + * Lists our available keys + */ + public static function keys() { + return array_keys(static::factory()->_table()); + } + + public static function table() { + return static::factory()->_table(); } } ?> diff --git a/application/classes/StaticList/Module.php b/application/classes/StaticList/Module.php index b166e34d..ffd33df5 100644 --- a/application/classes/StaticList/Module.php +++ b/application/classes/StaticList/Module.php @@ -12,6 +12,9 @@ class StaticList_Module extends StaticList { protected static $record = array(); + protected function _table() { + } + /** * Display a static name for a value */ @@ -81,13 +84,8 @@ class StaticList_Module extends StaticList { return Form::select($name,$x,$default,$attributes); } - protected function table($module=NULL) { - if (is_null($module)) - throw new Kohana_Exception('Module is a required attribute.'); - } - - public static function factory() { - return new StaticList_Module; + public static function get($value) { + return static::factory()->_get($value); } } ?> diff --git a/application/classes/StaticList/PriceType.php b/application/classes/StaticList/PriceType.php index 9c903af0..fd7f3af8 100644 --- a/application/classes/StaticList/PriceType.php +++ b/application/classes/StaticList/PriceType.php @@ -10,7 +10,7 @@ * @license http://dev.osbill.net/license.html */ class StaticList_PriceType extends StaticList { - protected function table() { + protected function _table() { return array( 0=>_('One-time Charge'), 1=>_('Recurring Membership/Subscription'), @@ -18,12 +18,8 @@ class StaticList_PriceType extends StaticList { ); } - public static function factory() { - return new StaticList_PriceType; - } - - public static function display($value) { - return static::_display($value); + public static function get($value) { + return static::factory()->_get($value); } } ?> diff --git a/application/classes/StaticList/RecurSchedule.php b/application/classes/StaticList/RecurSchedule.php index cb613ef1..4cd38d0c 100644 --- a/application/classes/StaticList/RecurSchedule.php +++ b/application/classes/StaticList/RecurSchedule.php @@ -10,7 +10,7 @@ * @license http://dev.osbill.net/license.html */ class StaticList_RecurSchedule extends StaticList { - protected function table() { + protected function _table() { return array( 0=>_('Weekly'), 1=>_('Monthly'), @@ -22,34 +22,8 @@ class StaticList_RecurSchedule extends StaticList { ); } - public static function factory() { - return new StaticList_RecurSchedule; - } - - public static function display($value) { - return static::_display($value); - } - - /** - * Renders the price display for a product - * - * @uses product - */ - public static function form($name,$product='',$default='',$addblank=FALSE) { - if (empty($product)) - throw new Kohana_Exception('Product is a required field for :method',array(':method'=>__METHOD__)); - - $x = ''; - $table = static::factory()->table(); - - foreach ($product->get_price_array() as $term => $price) { - $x[$term] = sprintf('%s %s',Currency::display(Tax::add($price['price_base'])),$table[$term]); - - if ($price['price_setup'] > 0) - $x[$term] .= sprintf(' + %s %s',Currency::display(Tax::add($price['price_setup'])),_('Setup')); - } - - return Form::select($name,$x,$default); + public static function get($value) { + return static::factory()->_get($value); } } ?> diff --git a/application/classes/StaticList/RecurType.php b/application/classes/StaticList/RecurType.php index cad3a14f..0b670ed1 100644 --- a/application/classes/StaticList/RecurType.php +++ b/application/classes/StaticList/RecurType.php @@ -10,19 +10,15 @@ * @license http://dev.osbill.net/license.html */ class StaticList_RecurType extends StaticList { - protected function table() { + protected function _table() { return array( 0=>_('Bill on Aniversary Date of Subscription'), 1=>_('Bill on Fixed Schedule'), ); } - public static function factory() { - return new StaticList_RecurType; - } - - public static function display($value) { - return static::_display($value); + public static function get($value) { + return static::factory()->_get($value); } } ?> diff --git a/application/classes/StaticList/SweepType.php b/application/classes/StaticList/SweepType.php index e35c079b..1a27965c 100644 --- a/application/classes/StaticList/SweepType.php +++ b/application/classes/StaticList/SweepType.php @@ -10,7 +10,7 @@ * @license http://dev.osbill.net/license.html */ class StaticList_SweepType extends StaticList { - protected function table() { + protected function _table() { return array( 0=>_('Daily'), 1=>_('Weekly'), @@ -22,12 +22,8 @@ class StaticList_SweepType extends StaticList { ); } - public static function factory() { - return new StaticList_SweepType; - } - - public static function display($value) { - return static::_display($value); + public static function get($value) { + return static::factory()->_get($value); } } ?> diff --git a/application/classes/StaticList/Title.php b/application/classes/StaticList/Title.php index 0324ee6f..0afa8045 100644 --- a/application/classes/StaticList/Title.php +++ b/application/classes/StaticList/Title.php @@ -10,7 +10,7 @@ * @license http://dev.osbill.net/license.html */ class StaticList_Title extends StaticList { - protected function table() { + protected function _table() { return array( 'mr'=>_('Mr'), 'ms'=>_('Ms'), @@ -21,8 +21,8 @@ class StaticList_Title extends StaticList { ); } - public static function factory() { - return new StaticList_Title; + public static function get($value) { + return static::factory()->_get($value); } } ?> diff --git a/application/classes/StaticList/YesNo.php b/application/classes/StaticList/YesNo.php index e43bb413..b72c96f3 100644 --- a/application/classes/StaticList/YesNo.php +++ b/application/classes/StaticList/YesNo.php @@ -10,19 +10,15 @@ * @license http://dev.osbill.net/license.html */ class StaticList_YesNo extends StaticList { - protected function table() { + protected function _table() { return array( 0=>_('No'), 1=>_('Yes'), ); } - public static function factory() { - return new StaticList_YesNo; - } - - public static function display($value) { - return static::_display($value); + public static function get($value) { + return static::factory()->_get($value); } } ?> diff --git a/application/classes/URL.php b/application/classes/URL.php index f7fb0a69..303ef1fc 100644 --- a/application/classes/URL.php +++ b/application/classes/URL.php @@ -13,7 +13,6 @@ class URL extends Kohana_URL { // Our method paths for different functions public static $method_directory = array( 'admin'=>'a', - 'affiliate'=>'affiliate', // @todo To retire 'reseller'=>'r', 'task'=>'task', 'user'=>'u', diff --git a/application/config/config.php b/application/config/config.php index da15b4bf..0c4da93e 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -13,7 +13,6 @@ return array( 'appname' => 'OS Billing', // Our application name, as shown in the title bar of pages - 'cache_type' => 'file', 'email_from' => array('noreply@graytech.net.au'=>'Graytech Hosting'), 'email_admin_only'=> array( // 'adsl_traffic_notice'=>array('deon@leenooks.vpn'=>'Deon George'), @@ -24,8 +23,8 @@ return array( ), 'bsb' => '633-000', // @todo This should come from the DB 'accnum' => '120 440 821', // @todo This should come from the DB - 'theme' => 'yaml', // @todo This should be in the DB - 'theme_admin' => 'yaml', // @todo This should be in the DB + 'theme' => 'focusbusiness', // @todo This should be in the DB + 'theme_admin' => 'baseadmin', // @todo This should be in the DB 'tmpdir' => '/tmp', ); ?> diff --git a/application/media/js/jquery.jstree-1.0rc3.js b/application/media/js/jquery.jstree-1.0rc3.js deleted file mode 100644 index 21fc01b5..00000000 --- a/application/media/js/jquery.jstree-1.0rc3.js +++ /dev/null @@ -1,4551 +0,0 @@ -/* - * jsTree 1.0-rc3 - * http://jstree.com/ - * - * Copyright (c) 2010 Ivan Bozhanov (vakata.com) - * - * Licensed same as jquery - under the terms of either the MIT License or the GPL Version 2 License - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - * - * $Date: 2011-02-09 01:17:14 +0200 (ср, 09 февр 2011) $ - * $Revision: 236 $ - */ - -/*jslint browser: true, onevar: true, undef: true, bitwise: true, strict: true */ -/*global window : false, clearInterval: false, clearTimeout: false, document: false, setInterval: false, setTimeout: false, jQuery: false, navigator: false, XSLTProcessor: false, DOMParser: false, XMLSerializer: false*/ - -"use strict"; - -// top wrapper to prevent multiple inclusion (is this OK?) -(function () { if(jQuery && jQuery.jstree) { return; } - var is_ie6 = false, is_ie7 = false, is_ff2 = false; - -/* - * jsTree core - */ -(function ($) { - // Common functions not related to jsTree - // decided to move them to a `vakata` "namespace" - $.vakata = {}; - // CSS related functions - $.vakata.css = { - get_css : function(rule_name, delete_flag, sheet) { - rule_name = rule_name.toLowerCase(); - var css_rules = sheet.cssRules || sheet.rules, - j = 0; - do { - if(css_rules.length && j > css_rules.length + 5) { return false; } - if(css_rules[j].selectorText && css_rules[j].selectorText.toLowerCase() == rule_name) { - if(delete_flag === true) { - if(sheet.removeRule) { sheet.removeRule(j); } - if(sheet.deleteRule) { sheet.deleteRule(j); } - return true; - } - else { return css_rules[j]; } - } - } - while (css_rules[++j]); - return false; - }, - add_css : function(rule_name, sheet) { - if($.jstree.css.get_css(rule_name, false, sheet)) { return false; } - if(sheet.insertRule) { sheet.insertRule(rule_name + ' { }', 0); } else { sheet.addRule(rule_name, null, 0); } - return $.vakata.css.get_css(rule_name); - }, - remove_css : function(rule_name, sheet) { - return $.vakata.css.get_css(rule_name, true, sheet); - }, - add_sheet : function(opts) { - var tmp = false, is_new = true; - if(opts.str) { - if(opts.title) { tmp = $("style[id='" + opts.title + "-stylesheet']")[0]; } - if(tmp) { is_new = false; } - else { - tmp = document.createElement("style"); - tmp.setAttribute('type',"text/css"); - if(opts.title) { tmp.setAttribute("id", opts.title + "-stylesheet"); } - } - if(tmp.styleSheet) { - if(is_new) { - document.getElementsByTagName("head")[0].appendChild(tmp); - tmp.styleSheet.cssText = opts.str; - } - else { - tmp.styleSheet.cssText = tmp.styleSheet.cssText + " " + opts.str; - } - } - else { - tmp.appendChild(document.createTextNode(opts.str)); - document.getElementsByTagName("head")[0].appendChild(tmp); - } - return tmp.sheet || tmp.styleSheet; - } - if(opts.url) { - if(document.createStyleSheet) { - try { tmp = document.createStyleSheet(opts.url); } catch (e) { } - } - else { - tmp = document.createElement('link'); - tmp.rel = 'stylesheet'; - tmp.type = 'text/css'; - tmp.media = "all"; - tmp.href = opts.url; - document.getElementsByTagName("head")[0].appendChild(tmp); - return tmp.styleSheet; - } - } - } - }; - - // private variables - var instances = [], // instance array (used by $.jstree.reference/create/focused) - focused_instance = -1, // the index in the instance array of the currently focused instance - plugins = {}, // list of included plugins - prepared_move = {}; // for the move_node function - - // jQuery plugin wrapper (thanks to jquery UI widget function) - $.fn.jstree = function (settings) { - var isMethodCall = (typeof settings == 'string'), // is this a method call like $().jstree("open_node") - args = Array.prototype.slice.call(arguments, 1), - returnValue = this; - - // if a method call execute the method on all selected instances - if(isMethodCall) { - if(settings.substring(0, 1) == '_') { return returnValue; } - this.each(function() { - var instance = instances[$.data(this, "jstree_instance_id")], - methodValue = (instance && $.isFunction(instance[settings])) ? instance[settings].apply(instance, args) : instance; - if(typeof methodValue !== "undefined" && (settings.indexOf("is_") === 0 || (methodValue !== true && methodValue !== false))) { returnValue = methodValue; return false; } - }); - } - else { - this.each(function() { - // extend settings and allow for multiple hashes and $.data - var instance_id = $.data(this, "jstree_instance_id"), - a = [], - b = settings ? $.extend({}, true, settings) : {}, - c = $(this), - s = false, - t = []; - a = a.concat(args); - if(c.data("jstree")) { a.push(c.data("jstree")); } - b = a.length ? $.extend.apply(null, [true, b].concat(a)) : b; - - // if an instance already exists, destroy it first - if(typeof instance_id !== "undefined" && instances[instance_id]) { instances[instance_id].destroy(); } - // push a new empty object to the instances array - instance_id = parseInt(instances.push({}),10) - 1; - // store the jstree instance id to the container element - $.data(this, "jstree_instance_id", instance_id); - // clean up all plugins - b.plugins = $.isArray(b.plugins) ? b.plugins : $.jstree.defaults.plugins.slice(); - b.plugins.unshift("core"); - // only unique plugins - b.plugins = b.plugins.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(","); - - // extend defaults with passed data - s = $.extend(true, {}, $.jstree.defaults, b); - s.plugins = b.plugins; - $.each(plugins, function (i, val) { - if($.inArray(i, s.plugins) === -1) { s[i] = null; delete s[i]; } - else { t.push(i); } - }); - s.plugins = t; - - // push the new object to the instances array (at the same time set the default classes to the container) and init - instances[instance_id] = new $.jstree._instance(instance_id, $(this).addClass("jstree jstree-" + instance_id), s); - // init all activated plugins for this instance - $.each(instances[instance_id]._get_settings().plugins, function (i, val) { instances[instance_id].data[val] = {}; }); - $.each(instances[instance_id]._get_settings().plugins, function (i, val) { if(plugins[val]) { plugins[val].__init.apply(instances[instance_id]); } }); - // initialize the instance - setTimeout(function() { if(instances[instance_id]) { instances[instance_id].init(); } }, 0); - }); - } - // return the jquery selection (or if it was a method call that returned a value - the returned value) - return returnValue; - }; - // object to store exposed functions and objects - $.jstree = { - defaults : { - plugins : [] - }, - _focused : function () { return instances[focused_instance] || null; }, - _reference : function (needle) { - // get by instance id - if(instances[needle]) { return instances[needle]; } - // get by DOM (if still no luck - return null - var o = $(needle); - if(!o.length && typeof needle === "string") { o = $("#" + needle); } - if(!o.length) { return null; } - return instances[o.closest(".jstree").data("jstree_instance_id")] || null; - }, - _instance : function (index, container, settings) { - // for plugins to store data in - this.data = { core : {} }; - this.get_settings = function () { return $.extend(true, {}, settings); }; - this._get_settings = function () { return settings; }; - this.get_index = function () { return index; }; - this.get_container = function () { return container; }; - this.get_container_ul = function () { return container.children("ul:eq(0)"); }; - this._set_settings = function (s) { - settings = $.extend(true, {}, settings, s); - }; - }, - _fn : { }, - plugin : function (pname, pdata) { - pdata = $.extend({}, { - __init : $.noop, - __destroy : $.noop, - _fn : {}, - defaults : false - }, pdata); - plugins[pname] = pdata; - - $.jstree.defaults[pname] = pdata.defaults; - $.each(pdata._fn, function (i, val) { - val.plugin = pname; - val.old = $.jstree._fn[i]; - $.jstree._fn[i] = function () { - var rslt, - func = val, - args = Array.prototype.slice.call(arguments), - evnt = new $.Event("before.jstree"), - rlbk = false; - - if(this.data.core.locked === true && i !== "unlock" && i !== "is_locked") { return; } - - // Check if function belongs to the included plugins of this instance - do { - if(func && func.plugin && $.inArray(func.plugin, this._get_settings().plugins) !== -1) { break; } - func = func.old; - } while(func); - if(!func) { return; } - - // context and function to trigger events, then finally call the function - if(i.indexOf("_") === 0) { - rslt = func.apply(this, args); - } - else { - rslt = this.get_container().triggerHandler(evnt, { "func" : i, "inst" : this, "args" : args, "plugin" : func.plugin }); - if(rslt === false) { return; } - if(typeof rslt !== "undefined") { args = rslt; } - - rslt = func.apply( - $.extend({}, this, { - __callback : function (data) { - this.get_container().triggerHandler( i + '.jstree', { "inst" : this, "args" : args, "rslt" : data, "rlbk" : rlbk }); - }, - __rollback : function () { - rlbk = this.get_rollback(); - return rlbk; - }, - __call_old : function (replace_arguments) { - return func.old.apply(this, (replace_arguments ? Array.prototype.slice.call(arguments, 1) : args ) ); - } - }), args); - } - - // return the result - return rslt; - }; - $.jstree._fn[i].old = val.old; - $.jstree._fn[i].plugin = pname; - }); - }, - rollback : function (rb) { - if(rb) { - if(!$.isArray(rb)) { rb = [ rb ]; } - $.each(rb, function (i, val) { - instances[val.i].set_rollback(val.h, val.d); - }); - } - } - }; - // set the prototype for all instances - $.jstree._fn = $.jstree._instance.prototype = {}; - - // load the css when DOM is ready - $(function() { - // code is copied from jQuery ($.browser is deprecated + there is a bug in IE) - var u = navigator.userAgent.toLowerCase(), - v = (u.match( /.+?(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1], - css_string = '' + - '.jstree ul, .jstree li { display:block; margin:0 0 0 0; padding:0 0 0 0; list-style-type:none; } ' + - '.jstree li { display:block; min-height:18px; line-height:18px; white-space:nowrap; margin-left:18px; min-width:18px; } ' + - '.jstree-rtl li { margin-left:0; margin-right:18px; } ' + - '.jstree > ul > li { margin-left:0px; } ' + - '.jstree-rtl > ul > li { margin-right:0px; } ' + - '.jstree ins { display:inline-block; text-decoration:none; width:18px; height:18px; margin:0 0 0 0; padding:0; } ' + - '.jstree a { display:inline-block; line-height:16px; height:16px; color:black; white-space:nowrap; text-decoration:none; padding:1px 2px; margin:0; } ' + - '.jstree a:focus { outline: none; } ' + - '.jstree a > ins { height:16px; width:16px; } ' + - '.jstree a > .jstree-icon { margin-right:3px; } ' + - '.jstree-rtl a > .jstree-icon { margin-left:3px; margin-right:0; } ' + - 'li.jstree-open > ul { display:block; } ' + - 'li.jstree-closed > ul { display:none; } '; - // Correct IE 6 (does not support the > CSS selector) - if(/msie/.test(u) && parseInt(v, 10) == 6) { - is_ie6 = true; - - // fix image flicker and lack of caching - try { - document.execCommand("BackgroundImageCache", false, true); - } catch (err) { } - - css_string += '' + - '.jstree li { height:18px; margin-left:0; margin-right:0; } ' + - '.jstree li li { margin-left:18px; } ' + - '.jstree-rtl li li { margin-left:0px; margin-right:18px; } ' + - 'li.jstree-open ul { display:block; } ' + - 'li.jstree-closed ul { display:none !important; } ' + - '.jstree li a { display:inline; border-width:0 !important; padding:0px 2px !important; } ' + - '.jstree li a ins { height:16px; width:16px; margin-right:3px; } ' + - '.jstree-rtl li a ins { margin-right:0px; margin-left:3px; } '; - } - // Correct IE 7 (shifts anchor nodes onhover) - if(/msie/.test(u) && parseInt(v, 10) == 7) { - is_ie7 = true; - css_string += '.jstree li a { border-width:0 !important; padding:0px 2px !important; } '; - } - // correct ff2 lack of display:inline-block - if(!/compatible/.test(u) && /mozilla/.test(u) && parseFloat(v, 10) < 1.9) { - is_ff2 = true; - css_string += '' + - '.jstree ins { display:-moz-inline-box; } ' + - '.jstree li { line-height:12px; } ' + // WHY?? - '.jstree a { display:-moz-inline-box; } ' + - '.jstree .jstree-no-icons .jstree-checkbox { display:-moz-inline-stack !important; } '; - /* this shouldn't be here as it is theme specific */ - } - // the default stylesheet - $.vakata.css.add_sheet({ str : css_string, title : "jstree" }); - }); - - // core functions (open, close, create, update, delete) - $.jstree.plugin("core", { - __init : function () { - this.data.core.locked = false; - this.data.core.to_open = this.get_settings().core.initially_open; - this.data.core.to_load = this.get_settings().core.initially_load; - }, - defaults : { - html_titles : false, - animation : 500, - initially_open : [], - initially_load : [], - open_parents : true, - notify_plugins : true, - rtl : false, - load_open : false, - strings : { - loading : "Loading ...", - new_node : "New node", - multiple_selection : "Multiple selection" - } - }, - _fn : { - init : function () { - this.set_focus(); - if(this._get_settings().core.rtl) { - this.get_container().addClass("jstree-rtl").css("direction", "rtl"); - } - this.get_container().html(""); - this.data.core.li_height = this.get_container_ul().find("li.jstree-closed, li.jstree-leaf").eq(0).height() || 18; - - this.get_container() - .delegate("li > ins", "click.jstree", $.proxy(function (event) { - var trgt = $(event.target); - // if(trgt.is("ins") && event.pageY - trgt.offset().top < this.data.core.li_height) { this.toggle_node(trgt); } - this.toggle_node(trgt); - }, this)) - .bind("mousedown.jstree", $.proxy(function () { - this.set_focus(); // This used to be setTimeout(set_focus,0) - why? - }, this)) - .bind("dblclick.jstree", function (event) { - var sel; - if(document.selection && document.selection.empty) { document.selection.empty(); } - else { - if(window.getSelection) { - sel = window.getSelection(); - try { - sel.removeAllRanges(); - sel.collapse(); - } catch (err) { } - } - } - }); - if(this._get_settings().core.notify_plugins) { - this.get_container() - .bind("load_node.jstree", $.proxy(function (e, data) { - var o = this._get_node(data.rslt.obj), - t = this; - if(o === -1) { o = this.get_container_ul(); } - if(!o.length) { return; } - o.find("li").each(function () { - var th = $(this); - if(th.data("jstree")) { - $.each(th.data("jstree"), function (plugin, values) { - if(t.data[plugin] && $.isFunction(t["_" + plugin + "_notify"])) { - t["_" + plugin + "_notify"].call(t, th, values); - } - }); - } - }); - }, this)); - } - if(this._get_settings().core.load_open) { - this.get_container() - .bind("load_node.jstree", $.proxy(function (e, data) { - var o = this._get_node(data.rslt.obj), - t = this; - if(o === -1) { o = this.get_container_ul(); } - if(!o.length) { return; } - o.find("li.jstree-open:not(:has(ul))").each(function () { - t.load_node(this, $.noop, $.noop); - }); - }, this)); - } - this.__callback(); - this.load_node(-1, function () { this.loaded(); this.reload_nodes(); }); - }, - destroy : function () { - var i, - n = this.get_index(), - s = this._get_settings(), - _this = this; - - $.each(s.plugins, function (i, val) { - try { plugins[val].__destroy.apply(_this); } catch(err) { } - }); - this.__callback(); - // set focus to another instance if this one is focused - if(this.is_focused()) { - for(i in instances) { - if(instances.hasOwnProperty(i) && i != n) { - instances[i].set_focus(); - break; - } - } - } - // if no other instance found - if(n === focused_instance) { focused_instance = -1; } - // remove all traces of jstree in the DOM (only the ones set using jstree*) and cleans all events - this.get_container() - .unbind(".jstree") - .undelegate(".jstree") - .removeData("jstree_instance_id") - .find("[class^='jstree']") - .andSelf() - .attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); }); - $(document) - .unbind(".jstree-" + n) - .undelegate(".jstree-" + n); - // remove the actual data - instances[n] = null; - delete instances[n]; - }, - - _core_notify : function (n, data) { - if(data.opened) { - this.open_node(n, false, true); - } - }, - - lock : function () { - this.data.core.locked = true; - this.get_container().children("ul").addClass("jstree-locked").css("opacity","0.7"); - this.__callback({}); - }, - unlock : function () { - this.data.core.locked = false; - this.get_container().children("ul").removeClass("jstree-locked").css("opacity","1"); - this.__callback({}); - }, - is_locked : function () { return this.data.core.locked; }, - save_opened : function () { - var _this = this; - this.data.core.to_open = []; - this.get_container_ul().find("li.jstree-open").each(function () { - if(this.id) { _this.data.core.to_open.push("#" + this.id.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:")); } - }); - this.__callback(_this.data.core.to_open); - }, - save_loaded : function () { }, - reload_nodes : function (is_callback) { - var _this = this, - done = true, - current = [], - remaining = []; - if(!is_callback) { - this.data.core.reopen = false; - this.data.core.refreshing = true; - this.data.core.to_open = $.map($.makeArray(this.data.core.to_open), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:"); }); - this.data.core.to_load = $.map($.makeArray(this.data.core.to_load), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:"); }); - if(this.data.core.to_open.length) { - this.data.core.to_load = this.data.core.to_load.concat(this.data.core.to_open); - } - } - if(this.data.core.to_load.length) { - $.each(this.data.core.to_load, function (i, val) { - if(val == "#") { return true; } - if($(val).length) { current.push(val); } - else { remaining.push(val); } - }); - if(current.length) { - this.data.core.to_load = remaining; - $.each(current, function (i, val) { - if(!_this._is_loaded(val)) { - _this.load_node(val, function () { _this.reload_nodes(true); }, function () { _this.reload_nodes(true); }); - done = false; - } - }); - } - } - if(this.data.core.to_open.length) { - $.each(this.data.core.to_open, function (i, val) { - _this.open_node(val, false, true); - }); - } - if(done) { - // TODO: find a more elegant approach to syncronizing returning requests - if(this.data.core.reopen) { clearTimeout(this.data.core.reopen); } - this.data.core.reopen = setTimeout(function () { _this.__callback({}, _this); }, 50); - this.data.core.refreshing = false; - this.reopen(); - } - }, - reopen : function () { - var _this = this; - if(this.data.core.to_open.length) { - $.each(this.data.core.to_open, function (i, val) { - _this.open_node(val, false, true); - }); - } - this.__callback({}); - }, - refresh : function (obj) { - var _this = this; - this.save_opened(); - if(!obj) { obj = -1; } - obj = this._get_node(obj); - if(!obj) { obj = -1; } - if(obj !== -1) { obj.children("UL").remove(); } - else { this.get_container_ul().empty(); } - this.load_node(obj, function () { _this.__callback({ "obj" : obj}); _this.reload_nodes(); }); - }, - // Dummy function to fire after the first load (so that there is a jstree.loaded event) - loaded : function () { - this.__callback(); - }, - // deal with focus - set_focus : function () { - if(this.is_focused()) { return; } - var f = $.jstree._focused(); - if(f) { f.unset_focus(); } - - this.get_container().addClass("jstree-focused"); - focused_instance = this.get_index(); - this.__callback(); - }, - is_focused : function () { - return focused_instance == this.get_index(); - }, - unset_focus : function () { - if(this.is_focused()) { - this.get_container().removeClass("jstree-focused"); - focused_instance = -1; - } - this.__callback(); - }, - - // traverse - _get_node : function (obj) { - var $obj = $(obj, this.get_container()); - if($obj.is(".jstree") || obj == -1) { return -1; } - $obj = $obj.closest("li", this.get_container()); - return $obj.length ? $obj : false; - }, - _get_next : function (obj, strict) { - obj = this._get_node(obj); - if(obj === -1) { return this.get_container().find("> ul > li:first-child"); } - if(!obj.length) { return false; } - if(strict) { return (obj.nextAll("li").size() > 0) ? obj.nextAll("li:eq(0)") : false; } - - if(obj.hasClass("jstree-open")) { return obj.find("li:eq(0)"); } - else if(obj.nextAll("li").size() > 0) { return obj.nextAll("li:eq(0)"); } - else { return obj.parentsUntil(".jstree","li").next("li").eq(0); } - }, - _get_prev : function (obj, strict) { - obj = this._get_node(obj); - if(obj === -1) { return this.get_container().find("> ul > li:last-child"); } - if(!obj.length) { return false; } - if(strict) { return (obj.prevAll("li").length > 0) ? obj.prevAll("li:eq(0)") : false; } - - if(obj.prev("li").length) { - obj = obj.prev("li").eq(0); - while(obj.hasClass("jstree-open")) { obj = obj.children("ul:eq(0)").children("li:last"); } - return obj; - } - else { var o = obj.parentsUntil(".jstree","li:eq(0)"); return o.length ? o : false; } - }, - _get_parent : function (obj) { - obj = this._get_node(obj); - if(obj == -1 || !obj.length) { return false; } - var o = obj.parentsUntil(".jstree", "li:eq(0)"); - return o.length ? o : -1; - }, - _get_children : function (obj) { - obj = this._get_node(obj); - if(obj === -1) { return this.get_container().children("ul:eq(0)").children("li"); } - if(!obj.length) { return false; } - return obj.children("ul:eq(0)").children("li"); - }, - get_path : function (obj, id_mode) { - var p = [], - _this = this; - obj = this._get_node(obj); - if(obj === -1 || !obj || !obj.length) { return false; } - obj.parentsUntil(".jstree", "li").each(function () { - p.push( id_mode ? this.id : _this.get_text(this) ); - }); - p.reverse(); - p.push( id_mode ? obj.attr("id") : this.get_text(obj) ); - return p; - }, - - // string functions - _get_string : function (key) { - return this._get_settings().core.strings[key] || key; - }, - - is_open : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-open"); }, - is_closed : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-closed"); }, - is_leaf : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-leaf"); }, - correct_state : function (obj) { - obj = this._get_node(obj); - if(!obj || obj === -1) { return false; } - obj.removeClass("jstree-closed jstree-open").addClass("jstree-leaf").children("ul").remove(); - this.__callback({ "obj" : obj }); - }, - // open/close - open_node : function (obj, callback, skip_animation) { - obj = this._get_node(obj); - if(!obj.length) { return false; } - if(!obj.hasClass("jstree-closed")) { if(callback) { callback.call(); } return false; } - var s = skip_animation || is_ie6 ? 0 : this._get_settings().core.animation, - t = this; - if(!this._is_loaded(obj)) { - obj.children("a").addClass("jstree-loading"); - this.load_node(obj, function () { t.open_node(obj, callback, skip_animation); }, callback); - } - else { - if(this._get_settings().core.open_parents) { - obj.parentsUntil(".jstree",".jstree-closed").each(function () { - t.open_node(this, false, true); - }); - } - if(s) { obj.children("ul").css("display","none"); } - obj.removeClass("jstree-closed").addClass("jstree-open").children("a").removeClass("jstree-loading"); - if(s) { obj.children("ul").stop(true, true).slideDown(s, function () { this.style.display = ""; t.after_open(obj); }); } - else { t.after_open(obj); } - this.__callback({ "obj" : obj }); - if(callback) { callback.call(); } - } - }, - after_open : function (obj) { this.__callback({ "obj" : obj }); }, - close_node : function (obj, skip_animation) { - obj = this._get_node(obj); - var s = skip_animation || is_ie6 ? 0 : this._get_settings().core.animation, - t = this; - if(!obj.length || !obj.hasClass("jstree-open")) { return false; } - if(s) { obj.children("ul").attr("style","display:block !important"); } - obj.removeClass("jstree-open").addClass("jstree-closed"); - if(s) { obj.children("ul").stop(true, true).slideUp(s, function () { this.style.display = ""; t.after_close(obj); }); } - else { t.after_close(obj); } - this.__callback({ "obj" : obj }); - }, - after_close : function (obj) { this.__callback({ "obj" : obj }); }, - toggle_node : function (obj) { - obj = this._get_node(obj); - if(obj.hasClass("jstree-closed")) { return this.open_node(obj); } - if(obj.hasClass("jstree-open")) { return this.close_node(obj); } - }, - open_all : function (obj, do_animation, original_obj) { - obj = obj ? this._get_node(obj) : -1; - if(!obj || obj === -1) { obj = this.get_container_ul(); } - if(original_obj) { - obj = obj.find("li.jstree-closed"); - } - else { - original_obj = obj; - if(obj.is(".jstree-closed")) { obj = obj.find("li.jstree-closed").andSelf(); } - else { obj = obj.find("li.jstree-closed"); } - } - var _this = this; - obj.each(function () { - var __this = this; - if(!_this._is_loaded(this)) { _this.open_node(this, function() { _this.open_all(__this, do_animation, original_obj); }, !do_animation); } - else { _this.open_node(this, false, !do_animation); } - }); - // so that callback is fired AFTER all nodes are open - if(original_obj.find('li.jstree-closed').length === 0) { this.__callback({ "obj" : original_obj }); } - }, - close_all : function (obj, do_animation) { - var _this = this; - obj = obj ? this._get_node(obj) : this.get_container(); - if(!obj || obj === -1) { obj = this.get_container_ul(); } - obj.find("li.jstree-open").andSelf().each(function () { _this.close_node(this, !do_animation); }); - this.__callback({ "obj" : obj }); - }, - clean_node : function (obj) { - obj = obj && obj != -1 ? $(obj) : this.get_container_ul(); - obj = obj.is("li") ? obj.find("li").andSelf() : obj.find("li"); - obj.removeClass("jstree-last") - .filter("li:last-child").addClass("jstree-last").end() - .filter(":has(li)") - .not(".jstree-open").removeClass("jstree-leaf").addClass("jstree-closed"); - obj.not(".jstree-open, .jstree-closed").addClass("jstree-leaf").children("ul").remove(); - this.__callback({ "obj" : obj }); - }, - // rollback - get_rollback : function () { - this.__callback(); - return { i : this.get_index(), h : this.get_container().children("ul").clone(true), d : this.data }; - }, - set_rollback : function (html, data) { - this.get_container().empty().append(html); - this.data = data; - this.__callback(); - }, - // Dummy functions to be overwritten by any datastore plugin included - load_node : function (obj, s_call, e_call) { this.__callback({ "obj" : obj }); }, - _is_loaded : function (obj) { return true; }, - - // Basic operations: create - create_node : function (obj, position, js, callback, is_loaded) { - obj = this._get_node(obj); - position = typeof position === "undefined" ? "last" : position; - var d = $("
  • "), - s = this._get_settings().core, - tmp; - - if(obj !== -1 && !obj.length) { return false; } - if(!is_loaded && !this._is_loaded(obj)) { this.load_node(obj, function () { this.create_node(obj, position, js, callback, true); }); return false; } - - this.__rollback(); - - if(typeof js === "string") { js = { "data" : js }; } - if(!js) { js = {}; } - if(js.attr) { d.attr(js.attr); } - if(js.metadata) { d.data(js.metadata); } - if(js.state) { d.addClass("jstree-" + js.state); } - if(!js.data) { js.data = this._get_string("new_node"); } - if(!$.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); } - $.each(js.data, function (i, m) { - tmp = $(""); - if($.isFunction(m)) { m = m.call(this, js); } - if(typeof m == "string") { tmp.attr('href','#')[ s.html_titles ? "html" : "text" ](m); } - else { - if(!m.attr) { m.attr = {}; } - if(!m.attr.href) { m.attr.href = '#'; } - tmp.attr(m.attr)[ s.html_titles ? "html" : "text" ](m.title); - if(m.language) { tmp.addClass(m.language); } - } - tmp.prepend(" "); - if(!m.icon && js.icon) { m.icon = js.icon; } - if(m.icon) { - if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); } - else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); } - } - d.append(tmp); - }); - d.prepend(" "); - if(obj === -1) { - obj = this.get_container(); - if(position === "before") { position = "first"; } - if(position === "after") { position = "last"; } - } - switch(position) { - case "before": obj.before(d); tmp = this._get_parent(obj); break; - case "after" : obj.after(d); tmp = this._get_parent(obj); break; - case "inside": - case "first" : - if(!obj.children("ul").length) { obj.append("