phpcmsの基本知識
9851 ワード
| �C api | �C caches | �C configs | �C caches_* | �C phpcms phpcms | �C languages | �C libs 、 | �C model | �C modules | �C templates | �C phpsso_server phpsso | �C statics | �C css css | �C images | �C js js | �C uploadfile | �C admin.php | �C index.php | �C crossdomain.xml FLASH | �C robots.txt | �C favicon.ico icon
URL
PHPCMS MVC , , , , 。
m / phpcms/modules
c phpcms/modules/ /*.php
a phpcms/modules/ /*.php
[ ]:
http://yourdomain.com/index.php?m=content&c=index&a=show&id=1
m = content / phpcms/modules/content
c = index phpcms/modules/content/index.php
a = show phpcms/modules/content/index.php show()
id = 1 get
:
http://www.yourdomain.com/index.php
phpcms content index init , , 。
URL : URL , url 。
http://www.yourdomain.com/index.php?m=content&c=index&a=init
1. phpcms/libs/classes , *.class.php
2. phpcms/libs/functions , *.func.php, global.func.php ,global.func.php
pc_base::load_sys_class(' ',' ',' ');
:
$http = pc_base::load_sys_class('http'); // http
pc_base::load_sys_class('format', '', 0); // form ,
pc_base::load_sys_func(' ');
:
pc_base::load_sys_func('mail'); mail
phpcms v9 , phpcms/modules 。 url m
:
http://www.yourname.com/index.php?m=content
phpcms/modules/content 。
, phpcms/modules
phpcms v9 , phpcms/modules/ / 。 +.php, mytest , mytest.php 。
, 。
mytest.php test , URL:
http://www.yourname.com/index.php?m=test&c=mytest
,
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
class mytest {
function __construct() {
}
public function init() {
echo 'hellp phpcms v9,my name is defalut action';
}
}
?>
, , 。
PHPCMS 。 PHPCMS :
.class.php ( phpcms , ), http.class.php。
.func.php ( ), mail.func.php。
, phpcmsapp phpcmsapp.class.php。
“ _model.class.php” , 。
caches/configs/ 。
: load_config
$upload_url = pc_base::load_config(' ',' ',' 。 ',' ');
:
$upload_url = pc_base::load_config('system','upload_url');
1. , , "MY_*.php" 。
phpcms/mood/index.php 。 index.php "MY_index.php"
MY_index.php
<?php
class MY_index extends index{
function __construct() {
parent::__construct();
}
//……your code
}
?>
url index , MY_index.php , 。
:caches/configs/database.php
, 。 , default, default ( :extended_1)
<?php
return array (
'default' => array (
'hostname' => 'localhost',
'database' => 'phpcms',
'username' => 'admin',
'password' => 'admin',
'tablepre' => 'v9_',
'charset' => 'gbk',
'type' => 'mysql',
'debug' => true,
'pconnect' => 0,
'autoconnect' => 0
),
/* */
'extended_1' => array ( 'hostname' => '10.10.125.2',
'database' => 'phpcms',
'username' => 'admin',
'password' => 'admin',
'tablepre' => 'v9_',
'charset' => 'gbk',
'type' => 'mysql',
'debug' => true,
'pconnect' => 0,
'autoconnect' => 0
),);?> , , 。
:caches/configs/route.php
, 。 , default。
:<?phpreturn array( 'default'=>array('m'=>'admin', 'c'=>'index', 'a'=>'init'),
'test.youname.com'=>array('m'=>'test', 'c'=>'index', 'a'=>'init'),);?>data , POST GET 。POST GET PHP $_POST $_GET 。
, $_POST['catid'] data POST 。
data 。 , 。
:<?phpreturn array( 'default'=>array( 'm'=>'phpcms',
'c'=>'index',
'a'=>'init',
'data'=>array( 'POST'=>array( 'catid'=>1
),
'GET'=>array( 'contentid'=>1
)
)
)
)?> POST catid=2 $_POST 2, 1。
:caches/configs/system.php
phpcms :1. ;( )2. 3. ;4. ;( )5. ;6. 。
phpcms v9 , phpcms/modules
, phpcms/modules 。
test , phpcms/modules , test。
test :classes
functions
templates , 。
, phpcms\templates\default "default" , default
default test
“test” , 。
phpcms v9 , phpcms/modules/ / 。
+.php, mytest , mytest.php 。
, 。 。
:1.mytest.php , ( )<?php/*defined('IN_PHPCMS') or exit('No permission resources.');
class mytest {
function __construct() {
}
public function init() {
$myvar = 'hello world!';
echo $myvar;
}
public function mylist() {
$myvar = 'hello world!this is a example!';
echo $myvar;
}
}*/?> url
http://www.yourname.com/index.php?m=test&c=mytesthttp://www.yourname.com/index.php?m=test&c=mytest&a=mylist “a” , init 2.mytest_admin.php , ( )
admin admin , 。
, , , admin 。<?phpdefined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);class mytest_admin extends admin { public function __construct() {
} public function init() { $myvar = 'oh,i am phpcmser'; echo $myvar;
}
}?>
phpcms , , 。1.
phpcms\templates\default\ , phpcms\templates\default\test
:include template('test', 'mytest', 'default');
test mytest ,default , defalut
mytest.php init mytest , public function init() { $var = 'hello world!'; include template('test', 'mytest', 'default');
}
url 。2.
phpcms\modules\ \templates , phpcms\modules\test\templates
:include $this->admin_tpl('mytest_admin_list');
mytest_admin_list phpcms\modules\test\templates mytest_admin_list.tpl.php, : .tpl.php
mytest_admin.php init mytest_admin_list , public function init() { $myvar = 'oh,i am phpcmser'; include $this->admin_tpl('mytest_admin_list');
}
:phpcms/model/ 。
+'_model.class.php' "test", , 'test_model.class.php' :<?phpdefined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_sys_class('model', '', 0);class test_model extends model { public function __construct() { $this->db_config = pc_base::load_config('database'); $this->db_setting = 'default'; $this->table_name = 'test';
parent::__construct();
}
}?> :1. ;2.$this->db_setting = 'default' , default, 。3.$this->table_name = 'test'
。
$this->db = pc_base::load_model('test_model');
。
<?php/*defined('IN_PHPCMS') or exit('No permission resources.');
class mytest {
private $db;
function __construct() {
$this->db = pc_base::load_model('test_model');
}
public function init() {
$result = $this->db->select();
var_dump($result);
}
}*/?> $this->db phpcms/libs/classes/model.class.php