This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

remove mode() and get_section() from #codeigniter system library

  • Loading branch information...
emad-elsaid committed Mar 6, 2011
1 parent 6ae34f8 commit cb45dab3f204a08cef122f23cbfc37b64df20fc5
@@ -20,7 +20,7 @@ public function __construct(){
public function edit(){
- $this->system->mode( 'edit' );
+ $this->system->mode = 'edit';
$this->load->library( 'gui' );
$text = anchor( site_url('editmode/view') , 'Go to View Mode' );
$this->print_text('<center>'.$text.'</center>');
@@ -29,7 +29,7 @@ public function edit(){
public function view(){
- $this->system->mode( 'view' );
+ $this->system->mode = 'view';
$this->load->library( 'gui' );
$text = anchor( site_url('editmode/edit') , 'Go to Edit Mode' );
$this->print_text('<center>'.$text.'</center>');
@@ -25,8 +25,8 @@ function perm_array(){
'admin' => intval($CI->ion_auth->is_admin()).'=1',
'logged' => intval($CI->ion_auth->logged_in()).'=1',
'guest' => intval(!$CI->ion_auth->logged_in()).'=1',
- 'view' => intval($CI->system->mode()=='view').'=1',
- 'edit' => intval($CI->system->mode()=='edit').'=1'
+ 'view' => intval($CI->system->mode=='view').'=1',
+ 'edit' => intval($CI->system->mode=='edit').'=1'
),
'vars' => array(
'level' => $CI->session->userdata('level'),
@@ -24,7 +24,9 @@ public function __construct(){
$this->CI->load->helper(array('perm', 'html','url','theme'));
// getting the current section
- $this->section = $this->get_section();
+ $this->section = new Section($this->CI->uri->rsegment(3));
+ if(!$this->section->exists())
+ $this->section->get_by_id(1);
if( $this->CI->ion_auth->logged_in()){
//getting the current user data
@@ -36,30 +38,6 @@ public function __construct(){
// getting the site mode
$this->mode = $this->CI->session->userdata('mode');
}
-
- /**
- * function of checking site mode
- *
- * */
- public function mode($mode=''){
-
- if( !empty($mode) ){
- $this->CI->session->set_userdata( 'mode', $mode );
- $this->mode = $mode ;
- }
- return $this->mode;
-
- }
-
- public function get_section(){
-
- $sec = new Section($this->CI->uri->rsegment(3));
-
- if(!$sec->exists())
- $sec->get_by_id(1);
-
- return $sec;
- }
}
?>
@@ -70,7 +70,7 @@ public function move_down(){
**/
public function container( $text='' ){
- if( $this->ci->system->mode()=='edit' AND $this->info!='PAGE_BODY_LOCKED' ){
+ if( $this->ci->system->mode=='edit' AND $this->info!='PAGE_BODY_LOCKED' ){
$text = $this->ci->load->view('edit_mode/container'
,array(
'text'=>$text
@@ -185,7 +185,7 @@ public function render(){
$layout_content[$child->cell] .= $child->render();
foreach( $layout_content as $k=>$v )
- if($this->ci->system->mode()=='edit' AND $v=='' AND $this->ci->ion_auth->is_admin())
+ if($this->ci->system->mode=='edit' AND $v=='' AND $this->ci->ion_auth->is_admin())
$layout_content[ $k ] = $this->add_button( $k );
}
/**
@@ -44,7 +44,7 @@ class:
<?php
$ci =& get_instance();
-if( $ci->system->mode()=='edit' )
+if( $ci->system->mode=='edit' )
{
$c = new Content();
$c->get_by_id( $id );
@@ -9,7 +9,7 @@
<?php
theme_add( explode( "\n", $info->resourceFiles) );
-if( $ci->system->mode()=='edit' )
+if( $ci->system->mode=='edit' )
{
$c = new Content();
$c->get_by_id( $id );
@@ -17,7 +17,7 @@
$u = ( empty($info->externel) )? site_url($info->section) : $info->externel;
-if( ($ci->system->mode()=='edit') and $ci->ion_auth->is_admin() )
+if( ($ci->system->mode=='edit') and $ci->ion_auth->is_admin() )
{
$ci->load->library('gui');
echo $ci->gui->info( 'Redirect content here to this '. anchor( $u, 'Page' ) );
@@ -6,7 +6,7 @@
theme_add( 'assets/fancybox/jquery.fancybox.css' );
$local = base_url().'/assets/admin/';
$logout = site_url( 'auth/logout' );
-$XHR_URL = site_url('editmode/'.($ci->system->mode()=='edit'? 'view':'edit'));
+$XHR_URL = site_url('editmode/'.($ci->system->mode=='edit'? 'view':'edit'));
theme_add( <<<EOT

0 comments on commit cb45dab

Please sign in to comment.