当前位置: 首页>>代码示例>>PHP>>正文


PHP Site::get_dir方法代码示例

本文整理汇总了PHP中Site::get_dir方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::get_dir方法的具体用法?PHP Site::get_dir怎么用?PHP Site::get_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Site的用法示例。


在下文中一共展示了Site::get_dir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse_data

 private static function parse_data($block, $data)
 {
     // Unserialize and manipulate the data
     $flickrfeed = unserialize($data);
     $flickrfeed = array_slice($flickrfeed['items'], 0, $block->image_count);
     // Photo size
     foreach ($flickrfeed as &$image) {
         $image['image_sizes'] = array('thumbnail' => str_replace('_m.jpg', '_t.jpg', $image['m_url']), 'small' => $image['m_url'], 'medium' => $image['l_url'], 'medium_z' => str_replace('_m.jpg', '_z.jpg', $image['m_url']), 'large' => str_replace('_m.jpg', '_b.jpg', $image['m_url']), 'original' => $image['photo_url'], 'square' => $image['t_url'], 'default' => $image['t_url']);
         if (isset($image['image_sizes'][$block->image_size])) {
             $image['local_file'] = Site::get_dir('user', '/files/flickrfeed/' . $block->image_size . '/' . basename($image['image_sizes'][$block->image_size]));
             $image['local_url'] = Site::get_url('user', '/files/flickrfeed/' . $block->image_size . '/' . basename($image['image_sizes'][$block->image_size]));
             $image['image_url'] = $image['image_sizes'][$block->image_size];
         } else {
             $image['local_file'] = Site::get_dir('user', '/files/flickrfeed/default/' . basename($image['image_sizes']['default']));
             $image['local_url'] = Site::get_url('user', '/files/flickrfeed/default/' . basename($image['image_sizes']['default']));
             $image['image_url'] = $image['image_sizes']['default'];
         }
         if ($block->cache_locally) {
             if (!file_exists($image['local_file'])) {
                 if (!file_exists(dirname($image['local_file']))) {
                     $umask = umask(0);
                     mkdir(dirname($image['local_file']), 0777, true);
                     umask($umask);
                 }
                 if (is_writable(dirname($image['local_file']))) {
                     file_put_contents($image['local_file'], file_get_contents($image['image_url']));
                 }
             }
             if (file_exists($image['local_file'])) {
                 $image['image_url'] = $image['local_url'];
             }
         }
     }
     return $flickrfeed;
 }
开发者ID:habari-extras,项目名称:flickrfeed,代码行数:35,代码来源:flickrfeed.plugin.php

示例2: add_template_vars

 /**
  * Add some variables to the template output
  */
 public function add_template_vars()
 {
     // Use theme options to set values that can be used directly in the templates
     // Don't check for constant values in the template code itself
     $this->assign('show_title_image', self::SHOW_TITLE_IMAGE);
     $this->assign('home_label', self::HOME_LABEL);
     $this->assign('show_powered', self::SHOW_POWERED);
     $this->assign('display_login', self::DISPLAY_LOGIN);
     $this->assign('tags_in_multiple', self::TAGS_IN_MULTIPLE);
     $this->assign('post_class', 'post' . (!self::SHOW_ENTRY_PAPERCLIP ? ' alt' : ''));
     $this->assign('page_class', 'post' . (!self::SHOW_PAGE_PAPERCLIP ? ' alt' : ''));
     $this->assign('show_post_nav', self::SHOW_POST_NAV);
     $locale = Options::get('locale');
     if (file_exists(Site::get_dir('theme', true) . $locale . '.css')) {
         $this->assign('localized_css', $locale . '.css');
     } else {
         $this->assign('localized_css', false);
     }
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     $this->assign('post_id', isset($this->post) && $this->post->content_type == Post::type('page') ? $this->post->id : 0);
     // Add FormUI template placing the input before the label
     $this->add_template('charcoal_text', dirname(__FILE__) . '/formcontrol_text.php');
     parent::add_template_vars();
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:29,代码来源:theme.php

示例3: action_init

 public function action_init()
 {
     // gotta be an easier way of doing this
     $theme_dir = Plugins::filter('admin_theme_dir', Site::get_dir('admin_theme', TRUE));
     $theme = Themes::create('admin', 'RawPHPEngine', $theme_dir);
     if (!$theme->template_exists('admincontrol_select')) {
         $this->add_template('admincontrol_select', dirname(__FILE__) . '/admincontrol_select.php');
     }
 }
开发者ID:habari-extras,项目名称:projectr,代码行数:9,代码来源:projectr.plugin.php

示例4: action_admin_header

 public function action_admin_header($theme)
 {
     // This is such a hack it's not even funny
     // But I am laughing inside. Laughing in a bad way.
     Stack::remove('admin_stylesheet', 'admin');
     $css = file_get_contents(Site::get_dir('admin_theme') . '/css/admin.css');
     $css = preg_replace('@#page input\\[type=button\\], #page input\\[type=submit\\], #page button {([^}]+)}@', '', $css, 1);
     $css = preg_replace('@#page input\\[type=button\\]:hover, #page input\\[type=submit\\]:hover, #page button:hover {([^}]+)}@', '', $css, 1);
     Stack::add('admin_stylesheet', array(preg_replace('@../images/@', Site::get_url('admin_theme') . '/images/', $css), 'screen'), 'admin', 'jquery');
 }
开发者ID:habari-extras,项目名称:unbuttonadmin,代码行数:10,代码来源:unbuttonadmin.plugin.php

示例5: rewrite_match_gallery

 /**
  * Check the requested gallery exists
  * @param RewriteRule $rule The matched rewrite rule
  * @param string The URL stub requested
  * @param array $params Some stuff
  * @todo Find a nicer way to assign thumbnails
  **/
 public static function rewrite_match_gallery($rule, $stub, $params)
 {
     // TODO It would be better to use the silo, but there's no way to check if a path is valid
     // $silo->get_dir() always returns at least an empty array, even for invalid paths
     $base = Site::get_dir('user') . '/files/simplegallery/';
     // Strip the base URL from the front of the stub, and add it to the base to get the full path.
     $sg = new SimpleGallery();
     $path = $base . substr($stub, strlen($sg->base));
     return file_exists($path);
 }
开发者ID:habari-extras,项目名称:simplegallery,代码行数:17,代码来源:simplegallery.plugin.php

示例6: habari_autoload

/**
 * Attempt to load the class before PHP fails with an error.
 * This method is called automatically in case you are trying to use a class which hasn't been defined yet.
 *
 * We look for the undefined class in the following folders:
 * - /system/classes/*.php
 * - /system/handlers/*.php
 * - /user/classes/*.php
 * - /user/handlers/*.php
 * - /user/sites/x.y.z/classes/*.php
 * - /user/sites/x.y.z/handlers/*.php
 *
 * @param string $class_name Class called by the user
 */
function habari_autoload( $class_name )
{
	static $files = null;

	$success = false;
	$class_file = strtolower( $class_name ) . '.php';

	if ( empty( $files ) ) {
		$files = array();
		$dirs = array(
			HABARI_PATH . '/system/classes',
			HABARI_PATH . '/system/handlers',
			HABARI_PATH . '/user/classes',
			HABARI_PATH . '/user/handlers',
		);

		// For each directory, save the available files in the $files array.
		foreach ( $dirs as $dir ) {
			$glob = glob( $dir . '/*.php' );
			if ( $glob === false || empty( $glob ) ) continue;
			$fnames = array_map( create_function( '$a', 'return strtolower(basename($a));' ), $glob );
			$files = array_merge( $files, array_combine( $fnames, $glob ) );
		}

		// Load the Site class, a requirement to get files from a multisite directory.
		if ( isset( $files['site.php'] ) ) {
			require( $files['site.php'] );
		}

		// Verify if this Habari instance is a multisite.
		if ( ( $site_user_dir = Site::get_dir( 'user' ) ) != HABARI_PATH . '/user' ) {
			// We are dealing with a site defined in /user/sites/x.y.z
			// Add the available files in that directory in the $files array.
			$glob_classes = glob( $site_user_dir . '/classes/*.php' );
			$glob_handlers = glob( $site_user_dir . '/handlers/*.php' );
			$glob = array_merge( $glob_classes, $glob_handlers );
			if ( $glob !== false && !empty( $glob ) ) {
				$fnames = array_map( create_function( '$a', 'return strtolower(basename($a));' ), $glob );
				$files = array_merge( $files, array_combine( $fnames, $glob ) );
			}
		}
	}

	// Search in the available files for the undefined class file.
	if ( isset( $files[$class_file] ) ) {
		require( $files[$class_file] );
		// If the class has a static method named __static(), execute it now, on initial load.
		if ( class_exists( $class_name, false ) && method_exists( $class_name, '__static' ) ) {
			call_user_func( array( $class_name, '__static' ) );
		}
		$success = true;
	}
}
开发者ID:rynodivino,项目名称:system,代码行数:67,代码来源:autoload.php

示例7: ajax_tags

 /**
  * Handles AJAX from /admin/tags
  * Used to delete and rename tags
  */
 public function ajax_tags($handler_vars)
 {
     Utils::check_request_method(array('POST'));
     $wsse = Utils::WSSE($handler_vars['nonce'], $handler_vars['timestamp']);
     if ($handler_vars['digest'] != $wsse['digest']) {
         Session::error(_t('WSSE authentication failed.'));
         echo Session::messages_get(true, array('Format', 'json_messages'));
         return;
     }
     $tag_names = array();
     $theme_dir = Plugins::filter('admin_theme_dir', Site::get_dir('admin_theme', true));
     $this->theme = Themes::create('admin', 'RawPHPEngine', $theme_dir);
     $action = $this->handler_vars['action'];
     switch ($action) {
         case 'delete':
             foreach ($_POST as $id => $delete) {
                 // skip POST elements which are not tag ids
                 if (preg_match('/^tag_\\d+/', $id) && $delete) {
                     $id = substr($id, 4);
                     $tag = Tags::get_by_id($id);
                     $tag_names[] = $tag->term_display;
                     Tags::vocabulary()->delete_term($tag);
                 }
             }
             $msg_status = _n(_t('Tag %s has been deleted.', array(implode('', $tag_names))), _t('%d tags have been deleted.', array(count($tag_names))), count($tag_names));
             Session::notice($msg_status);
             break;
         case 'rename':
             if (!isset($this->handler_vars['master'])) {
                 Session::error(_t('Error: New name not specified.'));
                 echo Session::messages_get(true, array('Format', 'json_messages'));
                 return;
             }
             $master = $this->handler_vars['master'];
             $tag_names = array();
             foreach ($_POST as $id => $rename) {
                 // skip POST elements which are not tag ids
                 if (preg_match('/^tag_\\d+/', $id) && $rename) {
                     $id = substr($id, 4);
                     $tag = Tags::get_by_id($id);
                     $tag_names[] = $tag->term_display;
                 }
             }
             Tags::vocabulary()->merge($master, $tag_names);
             $msg_status = sprintf(_n('Tag %1$s has been renamed to %2$s.', 'Tags %1$s have been renamed to %2$s.', count($tag_names)), implode($tag_names, ', '), $master);
             Session::notice($msg_status);
             break;
     }
     $this->theme->tags = Tags::vocabulary()->get_tree();
     $this->theme->max = Tags::vocabulary()->max_count();
     echo json_encode(array('msg' => Session::messages_get(true, 'array'), 'tags' => $this->theme->fetch('tag_collection')));
 }
开发者ID:ringmaster,项目名称:system,代码行数:56,代码来源:admintagshandler.php

示例8: _autoload

 public static function _autoload($class_name)
 {
     if (strtolower($class_name) == 'geshi') {
         $geshi_paths = array(dirname(__FILE__) . '/geshi', HABARI_PATH . '/3rdparty/geshi', Site::get_dir('vendor') . '/geshi');
         foreach ($geshi_paths as $gp) {
             if (file_exists($gp . '/geshi.php')) {
                 self::$geshi_path = $gp;
                 require $gp . '/geshi.php';
                 return;
             }
         }
     }
 }
开发者ID:habari-extras,项目名称:highlighter,代码行数:13,代码来源:highlighter.plugin.php

示例9: theme_header_image

 public function theme_header_image()
 {
     $imglist = '';
     mt_srand((double) microtime() * 1000);
     $imgs = dir(Site::get_dir('theme') . "/headers/");
     while ($file = $imgs->read()) {
         if (preg_match("/(gif|jpe?g|png)\$/i", $file)) {
             $imglist .= "{$file} ";
         }
     }
     closedir($imgs->handle);
     $imglist = explode(" ", $imglist);
     $no = sizeof($imglist) - 2;
     $random = mt_rand(0, $no);
     return $imglist[$random];
 }
开发者ID:habari-extras,项目名称:aligned,代码行数:16,代码来源:theme.php

示例10: action_plugin_activation

 public function action_plugin_activation($file)
 {
     if (realpath($file) == __FILE__) {
         CronTab::add_cron(array('name' => 'pbem_check_accounts', 'callback' => array(__CLASS__, 'check_accounts'), 'increment' => 600, 'description' => 'Check for new PBEM mail every 600 seconds.'));
         ACL::create_token('PBEM', 'Directly administer posts from the PBEM plugin', 'pbem');
         $dir = Site::get_dir('user') . '/files/PBEM';
         if (!is_dir($dir)) {
             if (!mkdir($dir, 0755)) {
                 EventLog::log('PBEM temporary storage directory ' . $dir . ' could not be created. Attachment processing will not work.', 'info', 'plugin', 'pbem');
                 Session::error('PBEM temporary storage directory ' . $dir . ' could not be created. Attachment processing will not work.');
             } else {
                 EventLog::log('PBEM temporary storage directory ' . $dir . ' created.', 'info', 'plugin', 'pbem');
             }
         }
     }
 }
开发者ID:habari-extras,项目名称:pbem,代码行数:16,代码来源:pbem.plugin.php

示例11: get_all

 /**
  * Returns the theme dir and path information
  * @return array An array of Theme data
  **/
 public static function get_all()
 {
     if (!isset(self::$all_themes)) {
         $dirs = array(HABARI_PATH . '/system/themes/*', HABARI_PATH . '/3rdparty/themes/*', HABARI_PATH . '/user/themes/*');
         if (Site::is('multi')) {
             $dirs[] = Site::get_dir('config') . '/themes/*';
         }
         $themes = array();
         foreach ($dirs as $dir) {
             $themes = array_merge($themes, Utils::glob($dir, GLOB_ONLYDIR | GLOB_MARK));
         }
         $themes = array_filter($themes, create_function('$a', 'return file_exists( $a . "/theme.xml" );'));
         $themefiles = array_map('basename', $themes);
         self::$all_themes = array_combine($themefiles, $themes);
     }
     return self::$all_themes;
 }
开发者ID:ringmaster,项目名称:system,代码行数:21,代码来源:themes.php

示例12: make_default_dirs

 public function make_default_dirs($force = true)
 {
     $defaults = array('pb__dirs_photos' => Site::get_dir('user') . '/files/photoblog/photos', 'pb__dirs_thumbnails' => Site::get_dir('user') . '/files/photoblog/thumbnails');
     if ($force) {
         $dirs = $defaults;
     } else {
         /* This is ugly too */
         $dirs = Options::get(array('pb__dirs_photos', 'pb__dirs_thumbnails'));
         if (isset($dirs[0]) && !empty($dirs[0])) {
             $dirs['pb__dirs_photos'] = $dirs[0];
         }
         if (isset($dirs[1]) && !empty($dirs[1])) {
             $dirs['pb__dirs_thumbnails'] = $dirs[1];
         }
         $dirs = array_merge($defaults, $dirs);
     }
     return $this->make_dirs($dirs);
 }
开发者ID:habari-extras,项目名称:photoblog,代码行数:18,代码来源:photoblog.plugin.php

示例13: habari_autoload

 /**
  * SPL Autoload function, includes a file to meet requirement of loading a class by name
  * @param string $class_name The name of a class, including (if present) a namespace
  * @return bool True if this function successfully autoloads the class in question
  */
 public static function habari_autoload($class_name)
 {
     $success = false;
     $full_class_name = $class_name;
     if (!preg_match('#^\\\\?Habari\\\\#', $class_name)) {
         return false;
     }
     $class_name = preg_replace('#^\\\\?Habari\\\\#', '', $class_name);
     $class_file = strtolower($class_name) . '.php';
     if (empty(self::$files)) {
         $dirs = array(HABARI_PATH . '/system/classes', HABARI_PATH . '/system/controls', HABARI_PATH . '/system/handlers', HABARI_PATH . '/user/classes', HABARI_PATH . '/user/controls', HABARI_PATH . '/user/handlers');
         // Queue these directories to find the Site class
         self::queue_dirs($dirs);
         // Load the Site class, a requirement to get files from a multisite directory.
         if (isset(self::$files['site.php'])) {
             require self::$files['site.php'];
             unset(self::$files['site.php']);
         }
         // Verify if this Habari instance is a multisite.
         if (($site_user_dir = Site::get_dir('user')) != HABARI_PATH . '/user') {
             // We are dealing with a site defined in /user/sites/x.y.z
             // Add those directories to the end of the $dirs array so they can override previous entries
             $dirs[] = $site_user_dir . '/classes';
             $dirs[] = $site_user_dir . '/controls';
             $dirs[] = $site_user_dir . '/handlers';
         }
         self::queue_dirs($dirs);
     }
     // Search in the available files for the undefined class file.
     if (isset(self::$files[$class_file])) {
         require self::$files[$class_file];
         unset(self::$files[$class_file]);
         // Remove the file from the list to expose duplicate class names // @todo remove this line
         // If the class has a static method named __static(), execute it now, on initial load.
         if (class_exists($full_class_name, false) && method_exists($full_class_name, '__static')) {
             call_user_func(array($full_class_name, '__static'));
         }
         $success = true;
     }
     return $success;
 }
开发者ID:habari,项目名称:system,代码行数:46,代码来源:autoload.php

示例14: add_template_vars

 /**
  * Add some variables to the template output
  */
 public function add_template_vars()
 {
     // Use theme options to set values that can be used directly in the templates
     $opts = Options::get_group(__CLASS__);
     $this->assign('show_title_image', $opts['show_title_image']);
     $this->assign('home_label', $opts['home_label']);
     $this->assign('show_powered', $opts['show_powered']);
     $this->assign('display_login', $opts['display_login']);
     $this->assign('tags_in_multiple', $opts['tags_in_multiple']);
     $this->assign('post_class', 'post' . (!$opts['show_entry_paperclip'] ? ' alt' : ''));
     $this->assign('page_class', 'post' . (!$opts['show_page_paperclip'] ? ' alt' : ''));
     $this->assign('show_post_nav', $opts['show_post_nav']);
     $this->assign('loggedin', User::identify()->loggedin);
     $locale = Options::get('locale');
     if (file_exists(Site::get_dir('theme', true) . $locale . '.css')) {
         $this->assign('localized_css', $locale . '.css');
     } else {
         $this->assign('localized_css', false);
     }
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => 'published', 'nolimit' => 1)));
     }
     $this->assign('post_id', isset($this->post) && $this->post->content_type == Post::type('page') ? $this->post->id : 0);
     if ($this->request->display_entries_by_tag) {
         if (count($this->include_tag) && count($this->exclude_tag) == 0) {
             $this->tags_msg = _t('Displaying posts tagged: %s', array(Format::tag_and_list($this->include_tag)));
         } else {
             if (count($this->exclude_tag) && count($this->include_tag) == 0) {
                 $this->tags_msg = _t('Displaying posts not tagged: %s', array(Format::tag_and_list($this->exclude_tag)));
             } else {
                 $this->tags_msg = _t('Displaying posts tagged: %s and not %s', array(Format::tag_and_list($this->include_tag), Format::tag_and_list($this->exclude_tag)));
             }
         }
     }
     // Add FormUI template placing the input before the label
     $this->add_template('charcoal_text', dirname(__FILE__) . '/formcontrol_text.php');
 }
开发者ID:ringmaster,项目名称:system,代码行数:40,代码来源:theme.php

示例15: ajax_dashboard

 /**
  * Handles AJAX requests from the dashboard
  */
 public function ajax_dashboard($handler_vars)
 {
     Utils::check_request_method(array('POST'));
     $theme_dir = Plugins::filter('admin_theme_dir', Site::get_dir('admin_theme', true));
     $this->theme = Themes::create('admin', 'RawPHPEngine', $theme_dir);
     switch ($handler_vars['action']) {
         case 'updateModules':
             $modules = array();
             foreach ($_POST as $key => $module) {
                 // skip POST elements which are not module names
                 if (preg_match('/^module\\d+$/', $key)) {
                     list($module_id, $module_name) = explode(':', $module, 2);
                     // remove non-sortable modules from the list
                     if ($module_id != 'nosort') {
                         $modules[$module_id] = $module_name;
                     }
                 }
             }
             Modules::set_active($modules);
             $ar = new AjaxResponse(200, _t('Modules updated.'));
             break;
         case 'addModule':
             $id = Modules::add($handler_vars['module_name']);
             $this->fetch_dashboard_modules();
             $ar = new AjaxResponse(200, _t('Added module %s.', array($handler_vars['module_name'])));
             $ar->html('modules', $this->theme->fetch('dashboard_modules'));
             break;
         case 'removeModule':
             Modules::remove($handler_vars['moduleid']);
             $this->fetch_dashboard_modules();
             $ar = new AjaxResponse(200, _t('Removed module.'));
             $ar->html('modules', $this->theme->fetch('dashboard_modules'));
             break;
     }
     $ar->out();
 }
开发者ID:ringmaster,项目名称:system,代码行数:39,代码来源:admindashboardhandler.php


注:本文中的Site::get_dir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。