2006-12-02 04:36:16 +00:00
< ? php
/*
2009-11-24 14:48:34 +00:00
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright ( C ) 2008 - 2009 e107 Inc ( e107 . org )
| http :// e107 . org
|
|
| Released under the terms and conditions of the
| GNU General Public License ( http :// gnu . org ) .
|
| $Source : / cvs_backup / e107_0 . 8 / e107_plugins / featurebox / admin_config . php , v $
2009-11-26 17:15:46 +00:00
| $Revision : 1.10 $
| $Date : 2009 - 11 - 26 17 : 15 : 46 $
| $Author : secretr $
2009-11-24 14:48:34 +00:00
+----------------------------------------------------------------------------+
*/
2006-12-02 04:36:16 +00:00
require_once ( " ../../class2.php " );
2008-12-11 21:13:48 +00:00
if ( ! getperms ( " P " ) || ! plugInstalled ( 'featurebox' ))
{
2006-12-02 04:36:16 +00:00
header ( " location: " . e_BASE . " index.php " );
exit ;
}
2009-11-24 14:48:34 +00:00
include_lan ( e_PLUGIN . " featurebox/languages/ " . e_LANGUAGE . " _admin_featurebox.php " );
2006-12-02 04:36:16 +00:00
2009-11-24 14:48:34 +00:00
class fb_admin extends e_admin_dispatcher
2008-12-10 22:41:39 +00:00
{
2009-11-24 14:48:34 +00:00
protected $modes = array (
'main' => array (
'controller' => 'fb_main_ui' ,
'path' => null ,
'ui' => 'fb_admin_form_ui' ,
'uipath' => null
),
2009-11-26 17:15:46 +00:00
'category' => array (
'controller' => 'fb_category_ui' ,
2009-11-24 14:48:34 +00:00
'path' => null ,
'ui' => 'fb_cat_form_ui' ,
'uipath' => null
)
);
protected $adminMenu = array (
'main/list' => array ( 'caption' => 'Featurebox List' , 'perm' => 'P' ),
'main/create' => array ( 'caption' => 'Create Featurebox Entry' , 'perm' => 'P' ),
2009-11-26 17:15:46 +00:00
'category/list' => array ( 'caption' => 'Categories' , 'perm' => 'P' ),
'category/create' => array ( 'caption' => " Create Category " , 'perm' => 'P' ),
2009-11-24 14:48:34 +00:00
// 'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => '0'),
// 'main/custom' => array('caption'=> 'Custom Page', 'perm' => '0')
);
protected $adminMenuAliases = array (
2009-11-26 17:15:46 +00:00
'main/edit' => 'main/list' ,
'category/edit' => 'category/list'
2009-11-24 14:48:34 +00:00
);
protected $menuTitle = 'featurebox' ;
2006-12-02 04:36:16 +00:00
}
2009-11-24 14:48:34 +00:00
2009-11-26 17:15:46 +00:00
class fb_category_ui extends e_admin_ui
2009-11-24 14:48:34 +00:00
{
2009-11-26 17:15:46 +00:00
protected $pluginTitle = 'Feature Box' ;
protected $pluginName = 'featurebox' ;
protected $table = " featurebox_category " ;
protected $pid = " fb_category_id " ;
protected $perPage = 0 ; //no limit
protected $fields = array (
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '5%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
'fb_category_id' => array ( 'title' => LAN_ID , 'type' => 'number' , 'data' => 'int' , 'width' => '5%' , 'forced' => TRUE ),
'fb_category_title' => array ( 'title' => LAN_TITLE , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'validate' => 'str' , 'rule' => '1-200' , 'error' => 'String between 1-200 characters expected' , 'help' => 'up to 200 characters' , 'thclass' => 'left' ),
'fb_category_layout' => array ( 'title' => 'Layout' , 'type' => 'dropdown' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => 'left' , 'batch' => true , 'filter' => true ),
'fb_category_random' => array ( 'title' => 'Random' , 'type' => 'boolean' , 'data' => 'int' , 'width' => '5%' , 'thclass' => 'center' , 'class' => 'center' , 'batch' => true , 'filter' => true ),
'fb_category_class' => array ( 'title' => LAN_VISIBILITY , 'type' => 'userclass' , 'data' => 'int' , 'width' => 'auto' ),
'fb_category_limit' => array ( 'title' => 'Limit' , 'type' => 'number' , 'data' => 'int' , 'width' => '5%' , 'thclass' => 'left' , 'help' => 'number of items to be shown' ),
'options' => array ( 'title' => LAN_OPTIONS , 'type' => null , 'width' => '10%' , 'forced' => TRUE , 'thclass' => 'center last' , 'class' => 'center' )
);
function init ()
{
// build layout dropdown params
$templates = array ();
$templates [ 'default' ] = 'Default' ;
$tmp = e107 :: getFile () -> get_files ( e_PLUGIN . 'featurebox/templates/layout' );
foreach ( $tmp as $files )
{
$key = str_replace ( '_template.php' , '' , $files [ 'fname' ]);
$templates [ $key ] = implode ( ' ' , array_map ( 'ucfirst' , explode ( '_' , $key ))); //TODO add LANS?
}
// TODO we need something like getFrontTheme()/getAdminTheme() - this will fail on user theme!
$tmp = e107 :: getFile () -> get_files ( e_THEME . e107 :: getPref ( 'sitetheme' ) . '/featurebox/templates/layout' );
foreach ( $tmp as $files )
{
$key = str_replace ( '_template.php' , '' , $files [ 'fname' ]);
$templates [ $key ] = implode ( ' ' , array_map ( 'ucfirst' , explode ( '_' , $key ))); //TODO add LANS?
}
$this -> fields [ 'fb_category_layout' ][ 'readParms' ] = $templates ;
$this -> fields [ 'fb_category_layout' ][ 'writeParms' ] = $templates ;
}
/**
* User defined pre - delete logic
*/
public function beforeDelete ( $data , $id )
{
if ( e107 :: getDb () -> db_Count ( 'featurebox' , '(*)' , 'fb_category=' . intval ( $id )))
{
$this -> getTreeModel () -> addMessageWarning ( " Can't delete <strong> { $data [ 'fb_category_title' ] } </strong> - category is in use! " );
return false ;
}
return true ;
}
2006-12-02 04:36:16 +00:00
}
2009-11-24 14:48:34 +00:00
/* class fb_cat_form_ui extends e_admin_form_ui
2006-12-02 04:36:16 +00:00
{
2009-11-24 14:48:34 +00:00
} */
class fb_main_ui extends e_admin_ui
{
2009-11-26 17:15:46 +00:00
//TODO Move to Class above.
protected $pluginTitle = 'Feature Box' ;
protected $pluginName = 'featurebox' ;
protected $table = " featurebox " ;
protected $pid = " fb_id " ;
protected $perPage = 10 ;
protected $batchDelete = true ;
protected $fields = array (
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '5%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
'fb_id' => array ( 'title' => LAN_ID , 'type' => 'int' , 'width' => '5%' , 'forced' => TRUE ),
'fb_title' => array ( 'title' => LAN_TITLE , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left first' ),
'fb_text' => array ( 'title' => " Message Text " , 'type' => 'bbarea' , 'width' => '30%' , 'readParms' => 'expand=...&truncate=50&bb=1' ), // Display name
'fb_image' => array ( 'title' => " Image " , 'type' => 'image' , 'width' => 'auto' , 'thclass' => 'left first' ),
'fb_imageurl' => array ( 'title' => " Image Link " , 'type' => 'url' , 'width' => 'auto' , 'thclass' => 'left first' ),
'fb_mode' => array ( 'title' => FBLAN_12 , 'type' => 'dropdown' , 'data' => 'int' , 'width' => '5%' , 'filter' => TRUE , 'batch' => TRUE ),
'fb_class' => array ( 'title' => LAN_VISIBILITY , 'type' => 'userclass' , 'data' => 'int' , 'width' => 'auto' ), // User id
'fb_rendertype' => array ( 'title' => FBLAN_22 , 'type' => 'dropdown' , 'data' => 'int' , 'width' => 'auto' , 'noedit' => TRUE ),
'fb_template' => array ( 'title' => FBLAN_25 , 'type' => 'dropdown' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => 'center' , 'class' => 'center' , 'writeParms' => '' , 'filter' => true , 'batch' => true ), // Photo
'fb_category' => array ( 'title' => LAN_CATEGORY , 'type' => 'dropdown' , 'data' => 'int' , 'width' => '5%' , 'filter' => TRUE , 'batch' => TRUE ),
'fb_order' => array ( 'title' => LAN_ORDER , 'type' => 'number' , 'data' => 'int' , 'width' => '5%' , 'thclass' => 'center' ),
'options' => array ( 'title' => LAN_OPTIONS , 'type' => null , 'forced' => TRUE , 'width' => '10%' , 'thclass' => 'center last' , 'class' => 'center' )
);
// protected $fieldpref = array('checkboxes', 'comment_id', 'comment_item_id', 'comment_author_id', 'comment_author_name', 'comment_subject', 'comment_comment', 'comment_type', 'options');
protected $prefs = array (
'fb_active' => array ( 'title' => 'Allow submitting of fbs by:' , 'type' => 'userclass' ),
'submit_question' => array ( 'title' => 'Allow submitting of Questions by:' , 'type' => 'userclass' ),
'classic_look' => array ( 'title' => 'Use Classic Layout' , 'type' => 'boolean' )
);
2009-11-24 14:48:34 +00:00
function init ()
2008-12-10 22:41:39 +00:00
{
2009-11-24 14:48:34 +00:00
$templates = array ();
$categories = array ();
$tmp = e107 :: getTemplate ( 'featurebox' , 'featurebox' );
foreach ( $tmp as $key => $val )
2008-12-10 22:41:39 +00:00
{
2009-11-24 14:48:34 +00:00
$templates [ $key ] = $key ; //TODO add LANS?
2008-12-10 22:41:39 +00:00
}
2009-11-24 14:48:34 +00:00
2009-11-26 17:15:46 +00:00
if ( e107 :: getDb () -> db_Select ( 'featurebox_category' ))
2008-12-10 22:41:39 +00:00
{
2009-11-26 17:15:46 +00:00
$categories [ 0 ] = LAN_SELECT ;
2009-11-24 14:48:34 +00:00
while ( $row = e107 :: getDb () -> db_Fetch ())
{
2009-11-26 17:15:46 +00:00
$id = $row [ 'fb_category_id' ];
$categories [ $id ] = $row [ 'fb_category_title' ];
2009-11-24 14:48:34 +00:00
}
2008-12-10 22:41:39 +00:00
}
2009-11-24 14:48:34 +00:00
$this -> fields [ 'fb_category' ][ 'writeParms' ] = $categories ;
$this -> fields [ 'fb_template' ][ 'writeParms' ] = $templates ;
$this -> fields [ 'fb_rendertype' ][ 'writeParms' ] = array ( FBLAN_23 , FBLAN_24 );
$this -> fields [ 'fb_mode' ][ 'writeParms' ] = array ( FBLAN_13 , FBLAN_14 );
$this -> fields [ 'fb_category' ][ 'readParms' ] = $categories ;
$this -> fields [ 'fb_template' ][ 'readParms' ] = $templates ;
$this -> fields [ 'fb_rendertype' ][ 'readParms' ] = array ( FBLAN_23 , FBLAN_24 );
$this -> fields [ 'fb_mode' ][ 'readParms' ] = array ( FBLAN_13 , FBLAN_14 );
2006-12-02 04:36:16 +00:00
}
2009-11-24 14:48:34 +00:00
2006-12-02 04:36:16 +00:00
}
2009-11-24 14:48:34 +00:00
class fb_admin_form_ui extends e_admin_form_ui
2006-12-02 04:36:16 +00:00
{
2009-11-24 14:48:34 +00:00
2006-12-02 04:36:16 +00:00
}
2009-11-24 14:48:34 +00:00
new fb_admin ();
2006-12-02 04:36:16 +00:00
2009-11-24 14:48:34 +00:00
require_once ( e_ADMIN . " auth.php " );
e107 :: getAdminUI () -> runPage ();
2006-12-02 04:36:16 +00:00
require_once ( e_ADMIN . " footer.php " );
2009-11-24 14:48:34 +00:00
exit ;
2006-12-02 04:36:16 +00:00
?>