classes
13 years ago
lang
13 years ago
lib
13 years ago
samples
13 years ago
styles
13 years ago
vendor
13 years ago
.htaccess
13 years ago
init.php
13 years ago
license.txt
13 years ago
loader.php
13 years ago
init.php
128 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Framework Initialization. |
| 4 | * This file is called at framework load time. |
| 5 | * |
| 6 | * @version $Rev: 199485 $ |
| 7 | * @author Jordi Canals |
| 8 | * @copyright Copyright (C) 2008, 2009, 2010 Jordi Canals |
| 9 | * @license GNU General Public License version 2 |
| 10 | * @link http://alkivia.org |
| 11 | * @package Alkivia |
| 12 | * @subpackage Framework |
| 13 | * |
| 14 | |
| 15 | Copyright 2008, 2009, 2010 Jordi Canals <devel@jcanals.cat> |
| 16 | |
| 17 | This program is free software; you can redistribute it and/or |
| 18 | modify it under the terms of the GNU General Public License |
| 19 | version 2 as published by the Free Software Foundation. |
| 20 | |
| 21 | This program is distributed in the hope that it will be useful, |
| 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | GNU General Public License for more details. |
| 25 | |
| 26 | You should have received a copy of the GNU General Public License |
| 27 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 28 | */ |
| 29 | |
| 30 | /** |
| 31 | * Creates and returns the framework URL. |
| 32 | * |
| 33 | * @return string Framework URL |
| 34 | */ |
| 35 | function ak_styles_url () |
| 36 | { |
| 37 | $dir = str_replace('\\', '/', WP_CONTENT_DIR); |
| 38 | $fmw = str_replace('\\', '/', AK_FRAMEWORK); |
| 39 | |
| 40 | return str_replace($dir, content_url(), $fmw) . '/styles'; |
| 41 | } |
| 42 | |
| 43 | // ================================================= SET GLOBAL CONSTANTS ===== |
| 44 | |
| 45 | if ( ! defined('AK_STYLES_URL') ) { |
| 46 | /** Define the framework URL */ |
| 47 | define ( 'AK_STYLES_URL', ak_styles_url() ); |
| 48 | } |
| 49 | |
| 50 | if ( ! defined('AK_INI_FILE') ) { |
| 51 | /** Define the alkivia.ini filename and absoilute location */ |
| 52 | define ( 'AK_INI_FILE', WP_CONTENT_DIR . '/alkivia.ini'); |
| 53 | } |
| 54 | |
| 55 | if ( ! defined('AK_CLASSES') ) { |
| 56 | /** Define the classes folder */ |
| 57 | define ( 'AK_CLASSES', AK_FRAMEWORK . '/classes'); |
| 58 | } |
| 59 | |
| 60 | if ( ! defined('AK_LIB') ) { |
| 61 | /** Library folder for functions files */ |
| 62 | define ( 'AK_LIB', AK_FRAMEWORK . '/lib'); |
| 63 | } |
| 64 | |
| 65 | if ( ! defined('AK_VENDOR') ) { |
| 66 | /** Vendor classes and libs */ |
| 67 | define ('AK_VENDOR', AK_FRAMEWORK . '/vendor'); |
| 68 | } |
| 69 | |
| 70 | $akf_uploads = wp_upload_dir(); |
| 71 | if ( ! defined('AK_UPLOAD_DIR') ) { |
| 72 | /** Absolute path to upload folder */ |
| 73 | define ( 'AK_UPLOAD_DIR', $akf_uploads['basedir'] . '/alkivia'); |
| 74 | } |
| 75 | if ( ! defined('AK_UPLOAD_URL') ) { |
| 76 | /** URL to upload folder. This could be replaced by a download manager. */ |
| 77 | define ( 'AK_UPLOAD_URL', $akf_uploads['baseurl'] . '/alkivia'); |
| 78 | } |
| 79 | |
| 80 | // ============================================== SET GLOBAL ACTION HOOKS ===== |
| 81 | |
| 82 | /** |
| 83 | * Adds meta name for Alkivia Framework to head. |
| 84 | * |
| 85 | * @hook action 'wp_head' |
| 86 | * @access private |
| 87 | * @return void |
| 88 | */ |
| 89 | function _ak_framework_meta_tags() { |
| 90 | echo '<meta name="framework" content="Alkivia Framework ' . get_option('ak_framework_version') . '" />' . PHP_EOL; |
| 91 | } |
| 92 | add_action('wp_head', '_ak_framework_meta_tags'); |
| 93 | |
| 94 | /** |
| 95 | * Loads the framework translations. |
| 96 | * Sets the translation text domain to 'akvf'. |
| 97 | * |
| 98 | * @return bool true on success, false on failure |
| 99 | */ |
| 100 | function _ak_framework_translation() |
| 101 | { |
| 102 | $locale = get_locale(); |
| 103 | $mofile = AK_FRAMEWORK . "/lang/$locale.mo"; |
| 104 | |
| 105 | return load_textdomain('akfw', $mofile); |
| 106 | } |
| 107 | add_action('init', '_ak_framework_translation'); |
| 108 | |
| 109 | // ================================================ INCLUDE ALL LIBRARIES ===== |
| 110 | |
| 111 | // Create the upload folder if does not exist. |
| 112 | if ( ! is_dir(AK_UPLOAD_DIR) ) { |
| 113 | wp_mkdir_p(AK_UPLOAD_DIR); |
| 114 | } |
| 115 | |
| 116 | // Prepare the settings and objects libraries. |
| 117 | require_once ( AK_CLASSES . '/settings.php'); |
| 118 | |
| 119 | require_once ( AK_LIB . '/filesystem.php' ); |
| 120 | require_once ( AK_LIB . '/formating.php' ); |
| 121 | require_once ( AK_LIB . '/modules.php' ); |
| 122 | require_once ( AK_LIB . '/objects.php' ); |
| 123 | require_once ( AK_LIB . '/system.php' ); |
| 124 | require_once ( AK_LIB . '/themes.php' ); |
| 125 | require_once ( AK_LIB . '/users.php' ); |
| 126 | |
| 127 | do_action('ak_framework_loaded'); |
| 128 |