Changeset 221
- Timestamp:
- 03/01/09 13:13:14 (1 year ago)
- Files:
-
- trunk/assets/admin/js/dashboard.js (modified) (4 diffs)
- trunk/modules/dashboard (added)
- trunk/modules/dashboard/language (added)
- trunk/modules/dashboard/language/english (added)
- trunk/modules/dashboard/language/english/dashboard_lang.php (moved) (moved from trunk/system/application/language/english/dashboard_lang.php) (1 diff, 1 prop)
- trunk/modules/dashboard/libraries (added)
- trunk/modules/dashboard/libraries/Dashboard.php (moved) (moved from trunk/system/application/libraries/Dashboard.php) (3 diffs, 1 prop)
- trunk/modules/dashboard/libraries/Statistic_widget.php (added)
- trunk/modules/dashboard/libraries/Widget.php (added)
- trunk/modules/dashboard/views (added)
- trunk/modules/dashboard/views/admin (added)
- trunk/modules/dashboard/views/admin/dashboard (moved) (moved from trunk/system/application/views/admin/dashboard) (1 prop)
- trunk/modules/dashboard/views/admin/dashboard/statistics.php (copied) (copied from trunk/system/application/views/admin/dashboard/statistics.php)
- trunk/system/application/controllers/admin/home.php (modified) (1 diff)
- trunk/user_guide/features/dashboard.html (modified) (2 diffs)
- trunk/user_guide/general/changelog.html (modified) (2 diffs)
- trunk/user_guide/upgrades/upgrade_050.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/assets/admin/js/dashboard.js
r114 r221 12 12 // Get the current dashboard settings from the cookie 13 13 // and position the widgets accordingly 14 // 15 // When the widgets are saved there are saved in a string with the following 16 // format 17 // 18 // {region}[]={widget_id}&...&{widget_id}[]=visible/hidden 19 // 20 // Where the following variables exist: 21 // {region} = The dashboard region, either topsection, leftsection or rightsection 22 // {widget_id} = The widget md5 name hash 23 // 24 // The actual widgets have ID of something like widget_98321j3ky98123jk213 but only ever 25 // the bit after widget_ is stored 14 26 var arr = $.cookie('bep_dashboard'); 15 27 if( arr != null) … … 29 41 // We have a visibility cmd 30 42 if(cmd[1] == 'hidden') 31 $('# '+cmd[0],regions).hide();43 $('#widget_'+cmd[0],regions).hide(); 32 44 } 33 } 45 } 34 46 } 35 47 … … 93 105 // Save the order which the widgets are in 94 106 regions.each(function(){ 95 cookie = cookie + "&" + $(this).sortable("serialize").replace(/widget/g, $(this).attr('id')); 107 var widget = $(this).sortable("serialize").replace(/widget/g, $(this).attr('id')); 108 109 // If no widgets in region, move to next region 110 if(widget == "") return true; 111 112 if(cookie == "") cookie = widget; 113 else cookie = cookie + "&" + widget; 96 114 }); 97 115 … … 99 117 // If it isn't meant to be shown hide the widget 100 118 widgets.each(function(){ 119 newID = $(this).attr('id').replace(/widget_/g, ''); 101 120 if($('div.action img:visible',this).hasClass('db-hidden')){ 102 121 // Cross is showing 103 cookie = cookie + "&" + $(this).attr('id')+ "[]=hidden";122 cookie = cookie + "&" + newID + "[]=hidden"; 104 123 $(this).hide(); 105 124 } 106 125 else{ 107 126 // Tick is showing 108 cookie = cookie + "&" + $(this).attr('id')+ "[]=visible";127 cookie = cookie + "&" + newID + "[]=visible"; 109 128 } 110 129 }); 111 130 112 131 // Save cookie 113 $.cookie('bep_dashboard',cookie .substring(1),{expires: 31});132 $.cookie('bep_dashboard',cookie,{expires: 31}); 114 133 115 134 // Hide the button and display the edit button trunk/modules/dashboard/language/english/dashboard_lang.php
- Property svn:mergeinfo set
r215 r221 36 36 37 37 /* End of file dashboard_lang.php */ 38 /* Location: ./ system/application/language/english/dashboard_lang.php */38 /* Location: ./modules/dashboard/language/english/dashboard_lang.php */ trunk/modules/dashboard/libraries/Dashboard.php
- Property svn:mergeinfo set
r204 r221 14 14 15 15 // --------------------------------------------------------------------------- 16 17 include_once("Widget.php"); 16 18 17 19 /** … … 32 34 */ 33 35 var $widgets = array(); 36 37 function Dashboard() 38 { 39 $this->CI =& get_instance(); 40 41 $this->CI->lang->load('dashboard'); 42 } 34 43 35 44 /** … … 85 94 } 86 95 87 /**88 * Widget class allows widgets to be created for the Dashboard class89 *90 * @package BackendPro91 * @subpackage Libraries92 */93 class Widget94 {95 /**96 * Name of widget97 *98 * @var string99 */100 var $name;101 102 /**103 * Body contents of widget104 *105 * @var string106 */107 var $body;108 109 var $CI;110 111 /**112 * Constructor113 *114 * @access public115 * @param string $name Name of widget116 * @param string $body Body contents of widget117 * @return boolean118 */119 function widget($name = NULL, $body = NULL)120 {121 $this->CI = get_instance();122 if( is_null($name))123 {124 return FALSE;125 }126 127 $this->name = $name;128 $this->body = $body;129 return TRUE;130 }131 132 /**133 * Output widget code134 *135 * @access public136 * @return string137 */138 function output()139 {140 $output = '<div class="widget" id="widget_' . $this->_name_convert() . '">';141 $output.= '<div class="action">' . $this->CI->page->icon('tick') . $this->CI->page->icon('cross') .'</div>';142 $output.= '<div class="header">'.$this->name.'</div>';143 $output.= '<div class="body">'.$this->body.'</div>';144 $output.= '</div>';145 return $output;146 }147 148 /**149 * Covert Widget name150 *151 * Coverts the widget name so it dosn't contain any spaces and is lower case.152 *153 * @access private154 * @return string155 */156 function _name_convert()157 {158 return preg_replace("/ /","_",strtolower($this->name));159 }160 }161 96 /* End of file Dashboard.php */ 162 /* Location: ./ system/application/libraries/Dashboard.php */97 /* Location: ./modules/dashboard/libraries/Dashboard.php */ trunk/modules/dashboard/views/admin/dashboard
- Property svn:mergeinfo set
trunk/system/application/controllers/admin/home.php
r204 r221 27 27 parent::Admin_Controller(); 28 28 29 // Load dashboard language file30 $this->lang->load('dashboard');31 32 29 log_message('debug','BackendPro : Home class loaded'); 33 30 } 34 31 35 function index()36 {37 // Include dashboard Javascript code38 $this->page->set_asset('admin','js','dashboard.js');32 function index() 33 { 34 // Include dashboard Javascript code 35 $this->page->set_asset('admin','js','dashboard.js'); 39 36 40 // Load the dashboard library41 $this->load->library('dashboard');37 // Load the dashboard library 38 $this->load->module_library('dashboard','dashboard'); 42 39 43 // Assign widgets to dashboard 44 $this->dashboard->assign_widget(new widget($this->lang->line('dashboard_example'),$this->lang->line('dashboard_example_body')),'left'); 45 $this->dashboard->assign_widget(new widget($this->lang->line('dashboard_statistics'),$this->_widget_statistics()),'right'); 40 // Load any widget libraries 41 $this->load->module_library('dashboard','Statistic_widget'); 46 42 47 // Load dashboard onto page 48 $data['dashboard'] = $this->dashboard->output(); 43 // Assign widgets to dashboard 44 $this->dashboard->assign_widget(new widget($this->lang->line('dashboard_example'),$this->lang->line('dashboard_example_body')),'left'); 45 $this->dashboard->assign_widget(new widget($this->lang->line('dashboard_statistics'),$this->statistic_widget->create()),'right'); 49 46 50 // Display Page 51 $data['header'] = $this->lang->line('backendpro_dashboard'); 52 $data['page'] = $this->config->item('backendpro_template_admin') . "home"; 53 $this->load->view($this->_container,$data); 54 } 47 // Load dashboard onto page 48 $data['dashboard'] = $this->dashboard->output(); 55 49 56 /** 57 * Generate Statistics Code 58 * 59 * Generate the contents of the statistics widget and return it as a string. 60 * 61 * @access private 62 * @return string 63 */ 64 function _widget_statistics() 65 { 66 $this->load->module_model('auth','user_model'); 67 68 // Get total number of members 69 $query = $this->user_model->getUsers(); 70 $data['total_members'] = $query->num_rows(); 71 72 // Get total number of unactivated members 73 $query = $this->user_model->getUsers(array('users.active'=>'0')); 74 $data['total_unactivated_members'] = $query->num_rows(); 75 76 $data['system_status'] = ($this->preference->item('maintenance_mode')) ? '<font color="red">'.$this->lang->line('dashboard_statistics_offline').'</font>' : '<font color="green">'.$this->lang->line('dashboard_statistics_online').'</font>'; 77 $data['user_registration'] = ($this->preference->item('allow_user_registration')) ? '<font color="green">'.$this->lang->line('dashboard_statistics_online').'</font>' : '<font color="red">'.$this->lang->line('dashboard_statistics_offline').'</font>'; 78 79 return $this->load->view($this->config->item('backendpro_template_admin') . 'dashboard/statistics',$data,TRUE); 80 } 50 // Display Page 51 $data['header'] = $this->lang->line('backendpro_dashboard'); 52 $data['page'] = $this->config->item('backendpro_template_admin') . "home"; 53 $this->load->view($this->_container,$data); 54 } 81 55 } 82 56 /* End of file home.php */ trunk/user_guide/features/dashboard.html
r179 r221 69 69 <code> 70 70 function index()<br /> 71 { <br />72 // <kbd>1.</kbd> Include dashboard Javascript code<br />73 $this- >page->set_asset('admin','js','dashboard.js');<br />71 {<br /> 72 // <var>1</var> Include dashboard Javascript code<br /> 73 $this->page->set_asset('admin','js','dashboard.js');<br /> 74 74 <br /> 75 // <kbd>2.</kbd> Load the dashboard library<br /> 76 $this->load->library('dashboard');<br /> 77 <br /> 78 // <kbd>3.</kbd> Assign widgets to dashboard<br /> 79 $this->dashboard->assign_widget(new widget($this->lang->line('dashboard_example'),$this->lang->line('dashboard_example_body')),'left');<br /> 80 $this->dashboard->assign_widget(new widget($this->lang->line('dashboard_statistics'),<dfn>$this->_widget_statistics()</dfn>),'right');<br /> 75 // <var>2</var> Load the dashboard library<br /> 76 $this->load->module_library('dashboard','dashboard');<br /> 81 77 <br /> 82 // <kbd>4.</kbd> Load dashboard onto page<br /> 83 $data['dashboard'] = $this->dashboard->output();<br /> 78 // <var>3</var> Load any widget libraries<br /> 79 $this->load->module_library('dashboard','Statistic_widget');<br /> 80 <br /> 81 // <var>4</var> Assign widgets to dashboard<br /> 82 $this->dashboard->assign_widget(new widget($this->lang->line('dashboard_example'),$this->lang->line('dashboard_example_body')),'left');<br /> 83 $this->dashboard->assign_widget(new widget($this->lang->line('dashboard_statistics'),$this->statistic_widget->create()),'right');<br /> 84 <br /> 85 // <var>5</var> Load dashboard onto page<br /> 86 $data['dashboard'] = $this->dashboard->output();<br /> 84 87 <br /> 85 88 // Display Page<br /> 86 $data['header'] = $this->lang->line('backendpro_dashboard');<br /> 87 $data['page'] = $this->config->item('backendpro_template_admin') . "home";<br /> 88 $this->load->view($this->_container,$data);<br /> 89 }<br /> 90 <br /> 91 function <dfn>_widget_statistics()</dfn><br /> 92 {<br /> 93 // Generate widget contents, e.g table of data<br /> 94 return $contents;<br /> 89 $data['header'] = $this->lang->line('backendpro_dashboard');<br /> 90 $data['page'] = $this->config->item('backendpro_template_admin') . "home";<br /> 91 $this->load->view($this->_container,$data);<br /> 95 92 } 96 93 </code> … … 105 102 of the <a href="#dashboard">Dashboard class</a>, storing it in <dfn>$this->dashboard</dfn>.</li> 106 103 104 <li>Here we load any widget classes. These basicly contain code to create the view for the widget. 105 The advantage of having them in their own classes is to improve code readability. Please see <dfn>modules/dashboard/libraries/Statistics_widget.php</dfn> 106 for an example. I would advise creating a similar class for every widget.</li> 107 107 108 <li>This section is where I create and assign widgets to the dashboard. As you can see two widgets are created 108 and assigned to the dashboard object. More details of the class methods used can be found below.</li>109 and assigned to the dashboard object.</li> 109 110 110 111 <li>This last section generates the dashboard code.</li> 111 112 </ol> 112 113 <p>You will notice a private function in the example above called <dfn>_widget_statistics()</dfn>. This function114 is used to generate the body contents of the statistics widget. The reason the code is in a function instead of inline115 with the rest of the dashboard code is just to make it easier to read. <strong>I would advise you also put widget body116 creation code inside their own functions to make your script more readable.</strong></p>117 113 118 114 <h2>Guarding a Widget</h2> trunk/user_guide/general/changelog.html
r220 r221 63 63 <h3>Modifications</h3> 64 64 <ul> 65 <li>Moved some of the dashboard files into their own module to tidy the file system up a bit. Also have created a new class to store to Statistics Widget creation code it.</li> 65 66 <li>Improved the <dfn>is_user()</dfn> method so if <dfn>$config['sess_use_database']</dfn> is <var>FALSE</var> then extra user checks are performed. For this to work the value returned by validateLogin() has changed, See <a href="http://trac2.assembla.com/backendpro/ticket/80">Enhancement #80</a></li> 66 67 <li>Removed PHP short tags from files, See <a href="http://trac2.assembla.com/backendpro/ticket/42">Task #42</a></li> … … 73 74 <h3>Bug Fixes</h3> 74 75 <ul> 76 <li>The dashboard widget system now restores moved widgets, See <a href="http://trac2.assembla.com/backendpro/ticket/64">Bug #64</a></li> 75 77 <li>The BackendPro tree menu in the admin panel now saves its open/closes status rather than it being lost between different pages, See Bugs <a href="http://trac2.assembla.com/backendpro/ticket/15">#15</a> and <a href="http://trac2.assembla.com/backendpro/ticket/45">#145</a></li> 76 78 <li>Redirection upon login is now fixed, See <a href="http://trac2.assembla.com/backendpro/ticket/100">Bug #100</a></li> trunk/user_guide/upgrades/upgrade_050.html
r187 r221 65 65 <p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first. This may include customer user authentication and custom website preference forms.</p> 66 66 67 <h3>Step 3: Upgrade the database</h3>67 <h3>Step 2: Upgrade the database</h3> 68 68 <p>Due to some changes between this version and the last you will needs to run some queries on your 69 69 database. Run the following queries seperatly on the database containing your BackendPro data</p> … … 72 72 </code> 73 73 74 <h2>Step 2: Update your user guide</h2> 74 <h3>Step 3: File System Changes</h3> 75 <p>In this upgrade several files have been moved around so the old files can be removed. Details of changes are 76 listed below:</p> 77 <ul> 78 <li><strong>Dashboard Files</strong> - The dashboard files have now been moved to their own module. This is to tidy up 79 their file structure. This means <dfn>system/application/libraries/Dashboard.php</dfn>, <dfn>system/application/languages/english/dashboard_dashboard.php</dfn> 80 and <dfn>system/application/views/admin/dashboard/statistics.php</dfn> can be removed. If you have made any changes to these files you will want to relocate them to their 81 new respective files in <dfn>modules/dashboard/</dfn>. 82 </ul> 83 84 <h2>Step 4: Update your user guide</h2> 75 85 <p>Please replace your local copy of the user guide with the new version, including the image files.</p> 76 86 </div>