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


PHP Phpfox::getObject方法代码示例

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


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

示例1: getComponent

 /**
  * Loads a module component. Components are the building blocks of the site and
  * include controllers which build up the pages we see and blocks that build up the controllers.
  *
  * @param string $sClass Name of the component to load.
  * @param array $aParams (Optional) Custom params you can pass to the component.
  * @param string $sType (Optional) Identify if this component is a block or a controller.
  * @param boolean $bTemplateParams Assign $aParams to the template
  * @return mixed Return the component object if it exists, otherwise FALSE.
  */
 public function getComponent($sClass, $aParams = array(), $sType = 'block', $bTemplateParams = false)
 {
     ($sPlugin = Phpfox_Plugin::get('module_getcomponent_start')) ? eval($sPlugin) : false;
     if ($sType == 'ajax' && strpos($sClass, '.') === false) {
         $sClass = $sClass . '.ajax';
     }
     if (is_array($sClass)) {
         return Phpfox::getBlock('core.holder', array('block_location' => $this->_aCacheBlockId[md5($sClass[0])]['location'], 'block_custom_id' => $this->_aCacheBlockId[md5($sClass[0])]['block_id'], 'content' => $sClass[0]));
     }
     $aParts = explode('.', $sClass);
     $sModule = $aParts[0];
     $sComponent = $sType . PHPFOX_DS . substr_replace(str_replace('.', PHPFOX_DS, $sClass), '', 0, strlen($sModule . PHPFOX_DS));
     if ($sType == 'controller') {
         $this->_sModule = $sModule;
         $this->_sController = substr_replace(str_replace('.', PHPFOX_DS, $sClass), '', 0, strlen($sModule . PHPFOX_DS));
     }
     static $sBlockName = '';
     if ($sModule == 'custom') {
         if (preg_match('/block\\' . PHPFOX_DS . 'cf_(.*)/i', $sComponent, $aCustomMatch)) {
             $aParams = array('type_id' => 'user_main', 'template' => 'content', 'custom_field_id' => $aCustomMatch[1]);
             $sBlockName = 'custom_cf_' . $aCustomMatch[1];
             $sComponent = 'block' . PHPFOX_DS . 'display';
             $sClass = 'custom.display';
         }
     }
     /*if (Theme_Service_Theme::instance()->isInDnDMode() || defined('PHPFOX_IN_DESIGN_MODE'))
     		{
     			Phpfox_Template::instance()->assign(array('sDeleteBlock' => str_replace('.','_',$sClass),
     				'bBlockCanMove' => true));				
     		}*/
     $sMethod = $sModule . '_component_' . str_replace(PHPFOX_DS, '_', $sComponent) . '_process';
     /*
     if (preg_match('/(.*?)\((.*?)\)/', $sComponent, $aMatches) && !empty($aMatches[2]))
     {
     	eval('$aParams = array_merge($aParams, array(' . $aMatches[2] . '));');
     
     	$sComponent = $aMatches[1];		
     	$sClass = $aMatches[1];			
     }		
     */
     $sHash = md5($sClass . $sType);
     if (!isset($this->_aModules[$sModule])) {
         return false;
     }
     if (isset($this->_aComponent[$sHash])) {
         $this->_aComponent[$sHash]->__construct(array('sModule' => $sModule, 'sComponent' => $sComponent, 'aParams' => $aParams));
     } else {
         $sClassFile = PHPFOX_DIR_MODULE . $sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . $sComponent . '.class.php';
         if (!file_exists($sClassFile) && isset($aParts[1])) {
             $sClassFile = PHPFOX_DIR_MODULE . $sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . $sComponent . PHPFOX_DS . $aParts[1] . '.class.php';
         }
         ($sPlugin = Phpfox_Plugin::get('library_module_getcomponent_1')) ? eval($sPlugin) : false;
         if (isset($mPluginReturn)) {
             return $mPluginReturn;
         }
         // Lets check if there is such a component
         if (!file_exists($sClassFile)) {
             ($sPlugin = Phpfox_Plugin::get('library_module_getcomponent_2')) ? eval($sPlugin) : false;
             if (isset($mPluginReturn)) {
                 return $mPluginReturn;
             }
             // Opps, for some reason we have loaded an invalid component. Lets send back info to the dev.
             Phpfox_Error::trigger('Failed to load component: ' . $sClass . ' (' . $sClassFile . ')', E_USER_ERROR);
         }
         // Require the component
         require $sClassFile;
         // Get the object
         $this->_aComponent[$sHash] = Phpfox::getObject($sModule . '_component_' . str_replace(PHPFOX_DS, '_', $sComponent), array('sModule' => $sModule, 'sComponent' => $sComponent, 'aParams' => $aParams));
     }
     $mReturn = 'blank';
     if ($sType != 'ajax') {
         ($sPlugin = Phpfox_Plugin::get('component_pre_process')) ? eval($sPlugin) : false;
         $mReturn = $this->_aComponent[$sHash]->process();
         if (is_object($mReturn) && $mReturn instanceof Closure) {
             ob_clean();
             echo $mReturn->__invoke();
             exit;
         }
         if ($sType == 'controller' && (is_array($mReturn) || is_object($mReturn))) {
             if ($mReturn instanceof Core\jQuery) {
                 $mReturn = ['run' => (string) $mReturn];
             }
             ob_clean();
             header('Content-type: application/json');
             echo json_encode($mReturn);
             exit;
         }
         ($sPlugin = Phpfox_Plugin::get('component_post_process')) ? eval($sPlugin) : false;
     }
     $this->_aReturn[$sClass] = $mReturn;
//.........这里部分代码省略.........
开发者ID:Goudarzi-hahram,项目名称:phpfox,代码行数:101,代码来源:module.class.php

示例2: array

 /**
  * Get a phpFox library. This includes the class file and creates the object for you.
  * 
  * Example usage:
  * <code>
  * Phpfox_Url::instance()->makeUrl('test');
  * </code>
  * In the example we called the URL library found in the folder: include/library/phpfox/url/url.class.php
  * then created an object for it so we could directly call the method "makeUrl".
  *
  * @param string $sClass Library class name.
  * @param array $aParams ARRAY of params you can pass to the library.
  * @return object Object of the library class is returned.
  */
 public static function &getLib($sClass, $aParams = array())
 {
     class_exists('Phpfox_Plugin') && ($sPlugin = Phpfox_Plugin::get('library_phpfox_getlib_0')) ? eval($sPlugin) : false;
     if (substr($sClass, 0, 7) != 'phpfox.' || ($sClass == 'phpfox.api' || $sClass == 'phpfox.process')) {
         $sClass = 'phpfox.' . $sClass;
     }
     $sHash = md5($sClass . serialize($aParams));
     if (isset(self::$_aObject[$sHash])) {
         return self::$_aObject[$sHash];
     }
     Phpfox::getLibClass($sClass);
     $sClass = str_replace('phpfox.phpfox.', 'phpfox.', $sClass);
     self::$_aObject[$sHash] = Phpfox::getObject($sClass, $aParams);
     return self::$_aObject[$sHash];
 }
开发者ID:html5ravi,项目名称:phpfox,代码行数:29,代码来源:phpfox.class.php

示例3: array

	/**
	 * Get a phpFox library. This includes the class file and creates the object for you.
	 * 
	 * Example usage:
	 * <code>
	 * Phpfox::getLib('url')->makeUrl('test');
	 * </code>
	 * In the example we called the URL library found in the folder: include/library/phpfox/url/url.class.php
	 * then created an object for it so we could directly call the method "makeUrl".
	 *
	 * @param string $sClass Library class name.
	 * @param array $aParams ARRAY of params you can pass to the library.
	 * @return object Object of the library class is returned.
	 */
	public static function &getLib($sClass, $aParams = array())
	{		
		if ((substr($sClass, 0, 7) != 'phpfox.') || ($sClass == 'phpfox.api' || $sClass == 'phpfox.process'))
		{
			$sClass = 'phpfox.' . $sClass;
		}
		
		$sHash = md5($sClass . serialize($aParams));
		
		if (isset(self::$_aObject[$sHash]))
		{	
			return self::$_aObject[$sHash];
		}		
		
		Phpfox::getLibClass($sClass);		

		$sClass = str_replace('phpfox.phpfox.', 'phpfox.', $sClass);		

		self::$_aObject[$sHash] = Phpfox::getObject($sClass, $aParams);
		
		return self::$_aObject[$sHash];
	}
开发者ID:hoanghd,项目名称:tools,代码行数:36,代码来源:phpfox.class.php


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