Advertisement
pierovdfn

Flatpress Documentation

Sep 4th, 2011
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.28 KB | None | 0 0
  1. FLATPRESS DOCUMENTATION v0.1 BETA
  2.  
  3. This document uses the revision 399 of Flatpress' SVN Repository.
  4. License of the document: public domain.
  5.  
  6. === 1. General constants ===
  7. Flatpress has some general and useful constants.
  8. These are:
  9.  
  10. * DUMB_MODE_ENABLED (declared in defaults.php line 19)
  11.  
  12. * FILE_PERMISSIONS (declared in defaults.php line 22)
  13. This is the default permission for files in the octal format.
  14.  
  15. * DIR_PERMISSIONS (declared in defaults.php line 23)
  16. This is the default permission for directories in the octal format.
  17.  
  18. * SESSION_PATH (declared in defaults.php line 31)
  19. If you have troubles with sessions files, you can define here where you want
  20. to save sessions.
  21. If the constant is empty (and this is its default value) the default
  22. webserver's configuration will be used.
  23.  
  24. * ABS_PATH (declared in defaults.php line 34)
  25. This is the absolute path to your Flatpress installation.
  26.  
  27. * FP_DEFAULTS (declared in defaults.php line 39)
  28. This is the directory of the default configuration files.
  29.  
  30. * FP_CONTENT (declared in defaults.php line 43)
  31. This is the writeable directory. All files that need to be changed by
  32. Flatpress should go here.
  33.  
  34. * CONFIG_DIR (declared in defaults.php line 46)
  35. This is the directory where are saved the configuration files.
  36.  
  37. * CONFIG_FILE
  38. This is the name of the main configuration file.
  39.  
  40. * HASHSALT_FILE
  41. This is the name of the file where is contained the hash salt for passwords.
  42.  
  43. * CONFIG_DEFAULT
  44. This is the name of the file that has the default configuration.
  45.  
  46. * USERS_DIR
  47. This is the directory where are placed the files about users.
  48.  
  49. * CONTENT_DIR
  50. The directory where entries, comments and static pages are saved.
  51.  
  52. * FP_INCLUDES
  53. The directory that contains all includes files.
  54.  
  55. * INCLUDES_DIR
  56. The directory of core scripts.
  57.  
  58. * SMARTY_DIR
  59. The directory of smarty template engine.
  60.  
  61. TODO: Continue the list
  62.  
  63. === 2. File system functions ===
  64.  
  65. ==== 2.1 Low level io functions ====
  66. /**
  67. * io_write_file
  68. *
  69. * This function writes some contents in a file and then sets the
  70. * FILE_PERMISSIONS chmods to it.
  71. * It also creates the directory of the file if it does not exist.
  72. *
  73. * @param string $filename: The file to write
  74. * @param mixed $data: The content to write
  75. * @return boolean: Did it succeed on writing?
  76. * @filesource fp-includes/core/core.fileio.php
  77. */
  78.  
  79. /**
  80. * io_load_file
  81. *
  82. * This function reads a file.
  83. *
  84. * @param string $filename: The file to read
  85. * @return mixed: The content or the boolean "false" on error.
  86. * @filesource fp-includes/core/core.fileio.php
  87. */
  88.  
  89. ==== 2.2 fs_filelister class ====
  90. /**
  91. * fs_filelister (class)
  92. *
  93. * This class makes the list of the files of a directory and optionally also
  94. * the files of its subdirectories.
  95. *
  96. * It can be easely extended by other classes.
  97. *
  98. * @filesource fp-includes/core/core.filesystem.php
  99. */
  100.  
  101. /**
  102. * Variable _list
  103. *
  104. * This variable is an array with the files.
  105. *
  106. * @var array
  107. */
  108.  
  109. /**
  110. * Variable _directory
  111. *
  112. * The directory to list.
  113. *
  114. * @var string
  115. */
  116.  
  117. /**
  118. * Variable count
  119. *
  120. * This variable is set by the count method and it's the number of elements in
  121. * $this->_list.
  122. *
  123. * @var integer
  124. */
  125.  
  126. /**
  127. * fs_filelister (constructor function)
  128. *
  129. * This is the constructor of the class.
  130. * It sets $this->_directory (if the $directory is not null) and starts the
  131. * listing.
  132. *
  133. * @param string $directory: The directory to list. It's optional.
  134. */
  135.  
  136. /**
  137. * _checkFile
  138. *
  139. * This function is called when a file or a subdirectory is found.
  140. * It has to add it to the list and it has to return what the _listFiles
  141. * function has to do:
  142. * 0 means go on
  143. * 1 means recurse the directory
  144. * 2 means exit the function
  145. *
  146. * By default this function just checks if the second param is not a directory
  147. * and return 0 (do not recurse sub directories).
  148. *
  149. * @param string $directory: The directory of the $file
  150. * @param string $file: The file name
  151. * @return integer: See the description
  152. */
  153.  
  154. /**
  155. * _exitingDir
  156. *
  157. * This function is called when _listFiles has done the recurse.
  158. * By default it does not do anything.
  159. *
  160. * @param string $directory: The directory of the $file
  161. * @param string $file: The file name
  162. * @return void
  163. */
  164.  
  165. /**
  166. * _listFiles
  167. *
  168. * This function makes the list of the files of a directory.
  169. *
  170. * @param string $directory: The directory to list
  171. * @return boolean: Does it succeed on listing?
  172. */
  173.  
  174. /**
  175. * getList
  176. *
  177. * This function returns $this->_list
  178. *
  179. * @return array: $this->_list
  180. */
  181.  
  182. /**
  183. * count
  184. *
  185. * Returns the number of elements in $this->_list.
  186. *
  187. * @return integer: See the description
  188. */
  189.  
  190. ==== 2.3 Classes that extends fs_filelister ====
  191. /**
  192. * fs_pathlister class
  193. *
  194. * This class extends the fs_filelister class but it recurses the directories.
  195. * The only overwritten method it's _checkFile
  196. *
  197. * @extends fs_filelister
  198. * @filesource fp-includes/core/core.filesystem.php
  199. */
  200.  
  201. ===== 2.3.1 fs_chmodder =====
  202. /**
  203. * class fs_chmodder
  204. *
  205. * Perform a recursive reset of file permission in the given $path
  206. * and its subdirectories to FILE_PERMISSIONS and DIR_PERMISSIONS.
  207. *
  208. * @extends fs_filelister
  209. * @filesource fp-includes/core/core.filesystem.php
  210. */
  211.  
  212. /**
  213. * variable _chmod_dir
  214. *
  215. * This is the octal chmod for directories.
  216. *
  217. * @var integer
  218. */
  219.  
  220. /**
  221. * variable _chmod_file
  222. *
  223. * This is the octal chmod for files.
  224. *
  225. * @var integer
  226. */
  227.  
  228. /**
  229. * method fs_chmodder (constructor)
  230. *
  231. * It sets the instance variables and starts the listing.
  232. *
  233. * @param string $directory: The directory where it has to operate
  234. * @param integer $ch_file: The chmod for files (default FILE_PERMISSIONS)
  235. * @param integer $ch_dir: The chmod for directories (default DIR_PERMISSIONS)
  236. */
  237.  
  238. /**
  239. * method _checkFile
  240. *
  241. * It sets the chmod and if it fails it adds to the list the file that it
  242. * couldn't set.
  243. *
  244. * @param string $directory: The directory of the $file
  245. * @param string $file: The file name
  246. * @return integer: 0 for files and 1 (recurse) for directories
  247. */
  248.  
  249. ===== 2.3.2 cache_filelister =====
  250. There is a class that caches fs_filelister but it uses a B+Tree Algorithm that I
  251. can't document because is beyond my capabilities.
  252. I'm sorry because it could be very interesting for people that studies Flat
  253. Files in PHP.
  254.  
  255. ==== 2.4 Other procedural functions ====
  256. /**
  257. * fs_list_dirs
  258. *
  259. * I think that this function makes the list of a directory but it calls an
  260. * undefined function (lang_id) so I don't know what it does very well.
  261. *
  262. * @return array: The list of files
  263. * @filesource fp-includes/core/core.filesystem.php
  264. */
  265.  
  266. /**
  267. * fs_mkdir
  268. *
  269. * Recursively creates dirs.
  270. * Returns true on success, else false
  271. *
  272. * @param string $path: Directory or directories to create
  273. * @param integer $mode: octal permissions; default DIR_PERMISSIONS constant
  274. * @return boolean: Does it succeed on creation?
  275. * @link http://www.php.net/function.mkdir.php
  276. * @filesource fp-includes/core/core.filesystem.php
  277. */
  278.  
  279. /**
  280. * fs_delete
  281. *
  282. * Deletes a file and recursively deletes dirs, if they're empty.
  283. *
  284. * It "deletes" also non-existent files but return 2 if the file does not exist.
  285. * Otherwise, it it exists, it return a boolean value (true on success, false on
  286. * failure.
  287. *
  288. * @return mixed: see the descriprtion.
  289. * @filesource fp-includes/core/core.filesystem.php
  290. */
  291.  
  292. /**
  293. * fs_chmod_recursive
  294. *
  295. * This function create an instance of fs_chmodder.
  296. *
  297. * @param string $fpath: $directory to fs_chmodder
  298. * @return array: List of files that it couldn't set the chmod
  299. * @filesource fp-includes/core/core.filesystem.php
  300. * @see fs_chmodder
  301. */
  302.  
  303. /**
  304. * fs_delete_recursive
  305. *
  306. * This function first deletes recursively the files and the subdirectories of a
  307. * directory then deletes the directory.
  308. *
  309. * @param string $path: The directory to delete
  310. * @return boolean: True always
  311. * @filesource fp-includes/core/core.filesystem.php
  312. */
  313.  
  314. /**
  315. * fs_copy
  316. *
  317. * This function makes the copy of a file.
  318. *
  319. * @param string $source: The file to copy
  320. * @param string $dest: The name of the copy
  321. * @return boolean: Does it succeed?
  322. * @filesource fp-includes/core/core.filesystem.php
  323. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement