/** * 工厂, 创建操作各种数据库的对象. * * @param string|null $db_type 数据库类型, 如果传递 null 或者不传递则默认为 local RThink_Config 的 * db_type * @param array $options 数据库配置参数 * @return object 操作相应数据库的对象 * @throws em_db_exception */ public static function factory($options, $db_type) { $adapter_name = ucfirst($db_type) . 'Adapter'; $class_name = 'RThink_Db_' . $adapter_name; class_exists($class_name, false) || (require 'RThink/Db/' . $adapter_name . '.php'); return new $class_name($options); }
/** * Factory method that creates a cache object based on configuration * @param $name Name of definitions handled by cache * @param $config Instance of HTMLPurifier_Config */ public function create($type, $config) { $method = $config->get('Cache', 'DefinitionImpl'); if ($method === null) { return new HTMLPurifier_DefinitionCache_Null($type); } if (!empty($this->caches[$method][$type])) { return $this->caches[$method][$type]; } if (isset($this->implementations[$method]) && class_exists($class = $this->implementations[$method], false)) { $cache = new $class($type); } else { if ($method != 'Serializer') { trigger_error("Unrecognized DefinitionCache {$method}, using Serializer instead", E_USER_WARNING); } $cache = new HTMLPurifier_DefinitionCache_Serializer($type); } foreach ($this->decorators as $decorator) { $new_cache = $decorator->decorate($cache); // prevent infinite recursion in PHP 4 unset($cache); $cache = $new_cache; } $this->caches[$method][$type] = $cache; return $this->caches[$method][$type]; }
/** * Initialize the Cache Engine * * Called automatically by the cache frontend * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array()); * * @param array $settings array of setting for the engine * @return boolean True if the engine has been successfully initialized, false if not */ public function init($settings = array()) { if (!class_exists('Memcache')) { return false; } if (!isset($settings['prefix'])) { $settings['prefix'] = Inflector::slug(APP_DIR) . '_'; } $settings += array('engine' => 'Memcache', 'servers' => array('127.0.0.1'), 'compress' => false, 'persistent' => true); parent::init($settings); if ($this->settings['compress']) { $this->settings['compress'] = MEMCACHE_COMPRESSED; } if (is_string($this->settings['servers'])) { $this->settings['servers'] = array($this->settings['servers']); } if (!isset($this->_Memcache)) { $return = false; $this->_Memcache = new Memcache(); foreach ($this->settings['servers'] as $server) { list($host, $port) = $this->_parseServerString($server); if ($this->_Memcache->addServer($host, $port, $this->settings['persistent'])) { $return = true; } } return $return; } return true; }
public function __call($s_method_name, $arr_arguments) { if (!method_exists($this, $s_method_name)) { // если еще не имлементировали $s_match = ""; $s_method_prefix = ''; $s_method_base = ''; $arr_matches = array(); $bSucc = preg_match("/[A-Z_]/", $s_method_name, $arr_matches); if ($bSucc) { $s_match = $arr_matches[0]; $i_match = strpos($s_method_name, $s_match); $s_method_prefix = substr($s_method_name, 0, $i_match) . "/"; $s_method_base = substr($s_method_name, 0, $i_match + ($s_match === "_" ? 1 : 0)); } $s_class_enter = "__" . $s_method_name; // метод, общий для всех режимов if (!class_exists($s_class_enter)) { $s_entermethod_lib = "methods/" . $s_method_prefix . "__" . $s_method_name . ".lib.php"; $this->__loadLib($s_entermethod_lib); $this->__implement($s_class_enter); } $s_class_mode = "__" . $s_method_name . "_"; // метод, выбираемый в зависимости от режима if (!class_exists($s_class_mode)) { $s_modemethod_lib = "methods/" . $s_method_prefix . "__" . $s_method_name . "_" . cmsController::getInstance()->getCurrentMode() . ".lib.php"; $this->__loadLib($s_modemethod_lib); $this->__implement($s_class_mode); } } return parent::__call($s_method_name, $arr_arguments); }
/** * Add a complex type by recursivly using all the class properties fetched via Reflection. * * @param string $type Name of the class to be specified * @return string XSD Type for the given PHP type */ public function addComplexType($type) { if (!class_exists($type)) { throw new \Zend\Soap\WSDL\Exception(sprintf('Cannot add a complex type %s that is not an object or where ' . 'class could not be found in \'DefaultComplexType\' strategy.', $type)); } $dom = $this->getContext()->toDomDocument(); $class = new \ReflectionClass($type); $complexType = $dom->createElement('xsd:complexType'); $complexType->setAttribute('name', $type); $all = $dom->createElement('xsd:all'); foreach ($class->getProperties() as $property) { if ($property->isPublic() && preg_match_all('/@var\\s+([^\\s]+)/m', $property->getDocComment(), $matches)) { /** * @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType' * node for describing other classes used as attribute types for current class */ $element = $dom->createElement('xsd:element'); $element->setAttribute('name', $property->getName()); $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0]))); $all->appendChild($element); } } $complexType->appendChild($all); $this->getContext()->getSchema()->appendChild($complexType); $this->getContext()->addType($type); return "tns:{$type}"; }
/** * Setup the config based on either the Configure::read() values * or the PaypalIpnConfig in config/paypal_ipn_config.php * * Will attempt to read configuration in the following order: * Configure::read('PaypalIpn') * App::import() of config/paypal_ipn_config.php * App::import() of plugin's config/paypal_ipn_config.php */ function __construct() { $this->config = Configure::read('PaypalIpn'); if (empty($this->config)) { $importConfig = array('type' => 'File', 'name' => 'PaypalIpn.PaypalIpnConfig', 'file' => CONFIGS . 'paypal_ipn_config.php'); if (!class_exists('PaypalIpnConfig')) { App::import($importConfig); } if (!class_exists('PaypalIpnConfig')) { // Import from paypal plugin configuration $importConfig['file'] = 'config' . DS . 'paypal_ipn_config.php'; App::import($importConfig); } if (!class_exists('PaypalIpnConfig')) { trigger_error(__d('paypal_ipn', 'PaypalIpnConfig: The configuration could not be loaded.', true), E_USER_ERROR); } if (!PHP5) { $config =& new PaypalIpnConfig(); } else { $config = new PaypalIpnConfig(); } $vars = get_object_vars($config); foreach ($vars as $property => $configuration) { if (strpos($property, 'encryption_') === 0) { $name = substr($property, 11); $this->encryption[$name] = $configuration; } else { $this->config[$property] = $configuration; } } } parent::__construct(); }
public function __construct() { if (!class_exists('DOMDocument')) { throw new WindException('DOMDocument is not exist.'); } $this->dom = new DOMDocument('1.0', 'utf-8'); }
protected function setUp() { parent::setUp(); if (!class_exists('Imagick')) { $this->markTestSkipped('Imagick is not installed'); } }
/** * Create a new XML document. * If $url is set, the DOCTYPE definition is treated as a PUBLIC * definition; $dtd should contain the ID, and $url should contain the * URL. Otherwise, $dtd should be the DTD name. */ function &createDocument($type, $dtd, $url = null) { $version = '1.0'; if (class_exists('DOMImplementation')) { // Use the new (PHP 5.x) DOM $impl =& new DOMImplementation(); // only generate a DOCTYPE if type is non-empty if ($type != '') { $domdtd = $impl->createDocumentType($type, isset($url) ? $dtd : '', isset($url) ? $url : $dtd); $doc = $impl->createDocument($version, '', $domdtd); } else { $doc = $impl->createDocument($version, ''); } // ensure we are outputting UTF-8 $doc->encoding = 'UTF-8'; } else { // Use the XMLNode class $doc =& new XMLNode(); $doc->setAttribute('version', $version); $doc->setAttribute('type', $type); $doc->setAttribute('dtd', $dtd); $doc->setAttribute('url', $url); } return $doc; }
private static function create($str, $type) { if (!class_exists($type)) { throw new PPP_Token_UnrecognizedTokenException($type); } return new $type($str); }
function controller_render($name, $action) { if (!$name) { $name = 'default'; } $name = strtolower($name); $ret = preg_match('/(^[a-z][a-z]*?[a-z]$)/', $name); if ($ret <= 0) { return '控制器名称非法' . $ret . $name; } $path = _ROOT . 'controller/' . $name . '.php'; if (!file_exists($path)) { return '控制器不存在'; } include_once $path; $classname = $name . 'Controller'; if (!class_exists($classname)) { return '控制器声明不完全'; } $o = new $classname(); if (!method_exists($o, 'render')) { return '控制器未继承BaseController::Render'; } define('BASE_CONTROLLER', $name); return call_user_method('render', $o, $action); }
/** * @param ResourceMapping $resource * @param ReflectionProperty $property * @param ArrayCollection $annotations * @return ResourceMapping * * @throws InvalidMappingException when a association is defined without a field definition. * @throws InvalidMappingException when a association is defined on a primary field. * @throws InvalidMappingException when a association target is an invalid class. */ public function processFieldAnnotationsForResourceMapping(ResourceMapping $resource, ReflectionProperty $property, ArrayCollection $annotations) { $field = $this->processFieldAnnotations($property, $annotations); if ($field->getAssociation()) { if ($field->getField()) { if ($field->getField()->primary) { throw new InvalidMappingException(sprintf(InvalidMappingException::MESSAGE_MISSING_FIELD_PRIMARY, $property->getDeclaringClass()->getName())); } if (!class_exists($field->getAssociation()->target)) { throw new InvalidMappingException(sprintf(InvalidMappingException::MESSAGE_INVALID_ASSOCIATION_TARGET, $property->getDeclaringClass()->getName(), $property->getName())); } $resource->getAssociations()->add($field); return $resource; } else { throw new InvalidMappingException(sprintf(InvalidMappingException::MESSAGE_MISSING_ASSOCIATION_FIELD, $property->getDeclaringClass()->getName(), $property->getName())); } } if ($field->getField()) { $resource->getFields()->add($field); if ($field->getField()->primary) { $resource->setPrimary($field); } } return $resource; }
/** * create a new adapter switch IDp name or ID * * @param string $id The id or name of the IDp * @param array $params (optional) required parameters by the adapter */ function factory($id, $params = NULL) { Hybrid_Logger::info("Enter Hybrid_Provider_Adapter::factory( {$id} )"); # init the adapter config and params $this->id = $id; $this->params = $params; $this->id = $this->getProviderCiId($this->id); $this->config = $this->getConfigById($this->id); # check the IDp id if (!$this->id) { throw new Exception("No provider ID specified.", 2); } # check the IDp config if (!$this->config) { throw new Exception("Unknown Provider ID, check your configuration file.", 3); } # check the IDp adapter is enabled if (!$this->config["enabled"]) { throw new Exception("The provider '{$this->id}' is not enabled.", 3); } # include the adapter wrapper if (isset($this->config["wrapper"]) && is_array($this->config["wrapper"])) { require_once $this->config["wrapper"]["path"]; if (!class_exists($this->config["wrapper"]["class"])) { throw new Exception("Unable to load the adapter class.", 3); } $this->wrapper = $this->config["wrapper"]["class"]; } else { require_once Hybrid_Auth::$config["path_providers"] . $this->id . ".php"; $this->wrapper = "Hybrid_Providers_" . $this->id; } # create the adapter instance, and pass the current params and config $this->adapter = new $this->wrapper($this->id, $this->config, $this->params); return $this; }
protected function setUp() { if (!class_exists('Symfony\\Component\\Form\\Form')) { $this->markTestSkipped('The "Form" component is not available'); } if (!class_exists('Doctrine\\DBAL\\Platforms\\MySqlPlatform')) { $this->markTestSkipped('Doctrine DBAL is not available.'); } if (!class_exists('Doctrine\\Common\\Version')) { $this->markTestSkipped('Doctrine Common is not available.'); } if (!class_exists('Doctrine\\ORM\\EntityManager')) { $this->markTestSkipped('Doctrine ORM is not available.'); } $this->em = DoctrineOrmTestCase::createTestEntityManager(); parent::setUp(); $schemaTool = new SchemaTool($this->em); $classes = array($this->em->getClassMetadata(self::ENTITY_CLASS)); try { $schemaTool->dropSchema($classes); } catch (\Exception $e) { } try { $schemaTool->createSchema($classes); } catch (\Exception $e) { } $ids = range(1, 300); foreach ($ids as $id) { $name = 65 + chr($id % 57); $this->em->persist(new SingleIdentEntity($id, $name)); } $this->em->flush(); }
/** * Replace property_exists() * * @category PHP * @package PHP_Compat * @license LGPL - http://www.gnu.org/licenses/lgpl.html * @copyright 2004-2007 Aidan Lister <*****@*****.**>, Arpad Ray <*****@*****.**> * @link http://php.net/property_exists * @author Christian Stadler <*****@*****.**> * @version $Revision: 269597 $ * @since PHP 5.1.0 * @require PHP 4.0.0 (user_error) */ function php_compat_property_exists($class, $property) { if (!is_string($property)) { user_error('property_exists() expects parameter 2 to be a string, ' . gettype($property) . ' given', E_USER_WARNING); return false; } if (is_object($class) || is_string($class)) { if (is_string($class)) { if (!class_exists($class)) { return false; } $vars = get_class_vars($class); } else { $vars = get_object_vars($class); } // Bail out early if get_class_vars or get_object_vars didnt work // or returned an empty array if (!is_array($vars) || count($vars) <= 0) { return false; } $property = strtolower($property); foreach (array_keys($vars) as $varname) { if (strtolower($varname) == $property) { return true; } } return false; } user_error('property_exists() expects parameter 1 to be a string or ' . 'an object, ' . gettype($class) . ' given', E_USER_WARNING); return false; }
function plgAcymailingContentplugin(&$subject, $config) { parent::__construct($subject, $config); if (!isset($this->params)) { $plugin = JPluginHelper::getPlugin('acymailing', 'contentplugin'); $this->params = new acyParameter($plugin->params); } $this->paramsContent = JComponentHelper::getParams('com_content'); JPluginHelper::importPlugin('content'); $this->dispatcherContent = JDispatcher::getInstance(); $excludedHandlers = array('plgContentEmailCloak', 'pluginImageShow'); $excludedNames = array('system' => array('SEOGenerator', 'SEOSimple'), 'content' => array('webeecomment', 'highslide', 'smartresizer', 'phocagallery')); $excludedType = array_keys($excludedNames); if (!ACYMAILING_J16) { foreach ($this->dispatcherContent->_observers as $id => $observer) { if (is_array($observer) and in_array($observer['handler'], $excludedHandlers)) { $this->dispatcherContent->_observers[$id]['event'] = ''; } elseif (is_object($observer)) { if (in_array($observer->_type, $excludedType) and in_array($observer->_name, $excludedNames[$observer->_type])) { $this->dispatcherContent->_observers[$id] = null; } } } } if (!class_exists('JSite')) { include_once ACYMAILING_ROOT . 'includes' . DS . 'application.php'; } }
/** * Run after the test. * * @return void */ public function tearDown() { if (class_exists('Mockery')) { Mockery::close(); } Container::getInstance()->flush(); }
public function getModelForBean(OODBBean $bean) { $model = $bean->getMeta("type"); $prefix = $this->defaultNamespace; $typeMap = $this->typeMap; if (isset($typeMap[$model])) { $modelName = $typeMap[$model]; } else { if (strpos($model, '_') !== FALSE) { $modelParts = explode('_', $model); $modelName = ''; foreach ($modelParts as $part) { $modelName .= ucfirst($part); } $modelName = $prefix . $modelName; if (!class_exists($modelName)) { //second try $modelName = $prefix . ucfirst($model); if (!class_exists($modelName)) { return NULL; } } } else { $modelName = $prefix . ucfirst($model); if (!class_exists($modelName)) { return NULL; } } } $obj = self::factory($modelName); $obj->loadBean($bean); return $obj; }
/** * Class contructor * * @since 0.2 **/ public function __construct() { // activation ## register_activation_hook(__FILE__, array($this, 'register_activation_hook')); // deactivation ## register_deactivation_hook(__FILE__, array($this, 'register_deactivation_hook')); // uninstall ## // TODO ## // load in mobile detect class ## if (!class_exists('Mobile_Detect')) { include Q_BROWSERS_PATH . '/library/mobile_detect.php'; } // instatiate class ## $this->detect = new Mobile_Detect(); $this->detect->setDetectionType('extended'); // extended search ## // grab user agent ## $this->useragent = $_SERVER['HTTP_USER_AGENT'] ? $_SERVER['HTTP_USER_AGENT'] : false; if (is_admin()) { // text-domain ## add_action('plugins_loaded', array($this, 'load_plugin_textdomain'), 1); // plugin URL ## $this->plugin_URL = WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)); $this->plugin_dir_path = plugin_dir_url(__FILE__); } else { // conditional stylesheets for browser tweaks ## add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_conditional'), 10000000); // load them late ## // browser body_class ## add_filter('body_class', array($this, 'body_classes'), 1); // comments ## add_action('wp_footer', array($this, 'comments'), 1000); } }
/** * Initialize singleton instance. * * @param string $class OPTIONAL Subclass of Zend_Wildfire_Channel_HttpHeaders * @return Zend_Wildfire_Channel_HttpHeaders Returns the singleton Zend_Wildfire_Channel_HttpHeaders instance * @throws Zend_Wildfire_Exception */ public static function init($class = null) { if (self::$_instance !== null) { require_once LIB_DIR . '/Zend/Wildfire/Exception.php'; throw new Zend_Wildfire_Exception('Singleton instance of Zend_Wildfire_Channel_HttpHeaders already exists!'); } if ($class !== null) { if (!is_string($class)) { require_once LIB_DIR . '/Zend/Wildfire/Exception.php'; throw new Zend_Wildfire_Exception('Third argument is not a class string'); } if (!class_exists($class)) { require_once LIB_DIR . '/Zend/Loader.php'; Zend_Loader::loadClass($class); } self::$_instance = new $class(); if (!self::$_instance instanceof Zend_Wildfire_Channel_HttpHeaders) { self::$_instance = null; require_once LIB_DIR . '/Zend/Wildfire/Exception.php'; throw new Zend_Wildfire_Exception('Invalid class to third argument. Must be subclass of Zend_Wildfire_Channel_HttpHeaders.'); } } else { self::$_instance = new self(); } return self::$_instance; }
function registerEvents() { \Idno\Core\site()->addEventHook('saved', function (\Idno\Core\Event $event) { $eventdata = $event->data(); if ($object = $eventdata['object']) { if (site()->session()->isLoggedOn()) { if (!empty(site()->session()->currentUser()->robot_state)) { $user = site()->session()->currentUser(); switch ($user->robot_state) { case '1': if (class_exists('IdnoPlugins\\Status') && $object instanceof \IdnoPlugins\Status) { $user->robot_state = '2a'; } else { $user->robot_state = '2b'; } self::$changed_state = 1; break; case '2a': if (class_exists('IdnoPlugins\\Photo') && $object instanceof \IdnoPlugins\Photo) { $user->robot_state = '3a'; } self::$changed_state = 1; break; case '2b': $user->robot_state = '3b'; self::$changed_state = 1; break; } $user->save(); site()->session()->refreshSessionUser($user); } } } }); }
/** * * 压缩文件 * @param String $package 压缩文件路径 * @param String $packageName 压缩包名称,如:test,压缩为zip压缩包 * @param String $localname 压缩包根目录文件名 */ function zipFile($package, $packageName, $localname) { if (class_exists('ZipArchive')) { return $this->_zipFileZiparchive($package, $packageName . '.zip', $localname); } return $this->_zipFilePclzip($package, $packageName . '.zip', $localname); }
function __construct() { $this->l = \OC::$server->getL10N('lib'); $version = OC_Util::getVersion(); $this->defaultEntity = 'ownCloud'; /* e.g. company name, used for footers and copyright notices */ $this->defaultName = 'ownCloud'; /* short name, used when referring to the software */ $this->defaultTitle = 'ownCloud'; /* can be a longer name, for titles */ $this->defaultBaseUrl = 'https://owncloud.org'; $this->defaultSyncClientUrl = 'https://owncloud.org/sync-clients/'; $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8'; $this->defaultiTunesAppId = '543672169'; $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.owncloud.android'; $this->defaultDocBaseUrl = 'https://doc.owncloud.org'; $this->defaultDocVersion = $version[0] . '.' . $version[1]; // used to generate doc links $this->defaultSlogan = $this->l->t('web services under your control'); $this->defaultLogoClaim = ''; $this->defaultMailHeaderColor = '#1d2d44'; /* header color of mail notifications */ $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php'; if (file_exists($themePath)) { // prevent defaults.php from printing output ob_start(); require_once $themePath; ob_end_clean(); if (class_exists('OC_Theme')) { $this->theme = new OC_Theme(); } } }
/** * Process * * @param mixed $value * @param array $options * * @return string|null */ public function process($value, array $options = array()) { if ($value === null) { return; } if (!class_exists('\\libphonenumber\\PhoneNumberUtil')) { throw new \RuntimeException('Library for phone checking not found'); } if (is_object($value) || is_resource($value) || is_array($value)) { $this->throwException($options, 'error'); } try { $phone = $this->getPhone($value, $options, $is_toll_free); } catch (\libphonenumber\NumberParseException $e) { $this->throwException($options, 'error'); } $util = \libphonenumber\PhoneNumberUtil::getInstance(); if (!$util->isValidNumber($phone)) { $this->throwException($options, 'error'); } if ($is_toll_free) { return $phone->getNationalNumber(); } return (string) $util->format($phone, $this->getDefaultPhoneFormat($options)); }
function after() { if (class_exists('DebugToolbar')) { echo DebugToolbar::render(); } return parent::after(); }
/** * Generates and checks presenter class name. * @param string presenter name * @return string class name * @throws InvalidPresenterException */ public function getPresenterClass(&$name) { if (isset($this->cache[$name])) { return $this->cache[$name]; } if (!is_string($name) || !Nette\Utils\Strings::match($name, '#^[a-zA-Z\\x7f-\\xff][a-zA-Z0-9\\x7f-\\xff:]*\\z#')) { throw new InvalidPresenterException("Presenter name must be alphanumeric string, '{$name}' is invalid."); } $class = $this->formatPresenterClass($name); if (!class_exists($class)) { throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' was not found."); } $reflection = new \ReflectionClass($class); $class = $reflection->getName(); if (!$reflection->implementsInterface('Nette\\Application\\IPresenter')) { throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is not Nette\\Application\\IPresenter implementor."); } elseif ($reflection->isAbstract()) { throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is abstract."); } $this->cache[$name] = $class; if ($name !== ($realName = $this->unformatPresenterClass($class))) { trigger_error("Case mismatch on presenter name '{$name}', correct name is '{$realName}'.", E_USER_WARNING); $name = $realName; } return $class; }
/** * Construct transport * * @param \Elastica\Connection $connection Connection object * @throws \Elastica\Exception\RuntimeException */ public function __construct(Connection $connection = null) { parent::__construct($connection); if (!class_exists('Elasticsearch\\RestClient')) { throw new RuntimeException('Elasticsearch\\RestClient class not found. Check that suggested package munkie/elasticsearch-thrift-php is required in composer.json'); } }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { //$inner = $data->parseVariables($this->rawOutput(), false); $tmp = new Pagemill_Stream(true); foreach ($this->children() as $child) { $child->process($data, $tmp); } $inner = html_entity_decode($tmp->peek(), ENT_COMPAT, 'UTF-8'); $data->set('value', $inner); $use = $data->parseVariables($this->getAttribute('use')); if ($use) { // Use the requested editor if available if (class_exists($use)) { if (is_subclass_of($use, __CLASS__)) { $sub = new $use($this->name(), $this->attributes(), $this, $this->docType()); $sub->output($data, $stream); return; } else { trigger_error("Requested editor class '{$cls}' does not appear to be an editor subclass."); } } else { trigger_error("Requested editor class '{$cls}' does not exist."); } } if (TYPEF_DEFAULT_EDITOR != '') { // Use the requested editor if available $use = TYPEF_DEFAULT_EDITOR; if (class_exists($use)) { if (is_subclass_of($use, __CLASS__)) { $sub = new $use($this->name(), $this->attributes(), $this, $this->docType()); $sub->output($data, $stream); return; } else { trigger_error("Configured editor class '{$use}' does not appear to be an editor subclass."); } } else { trigger_error("Configured editor class '{$use}' does not exist."); } } // Use CKEditor if available if (class_exists('Typeframe_Tag_Editor_CkEditor')) { $sub = new Typeframe_Tag_Editor_CkEditor($this->name(), $this->attributes(), $this, $this->docType()); $sub->process($data, $stream); return; } // No editor available. Use a plain textarea. $attribs = ''; foreach ($this->attributes() as $k => $v) { if ($k != 'use') { $attribs .= " {$k}=\"" . $data->parseVariables($v) . "\""; } } if (!$this->getAttribute('cols')) { $attribs .= ' cols="80"'; } if (!$this->getAttribute('rows')) { $attribs .= ' rows="25"'; } $stream->puts("<textarea{$attribs}>" . $inner . "</textarea>"); }
/** * Retrieve list of parents * * @param string $type * @return array */ public function getParents($type) { if (!class_exists($type)) { return $this->_default; } return $this->_classReader->getParents($type) ?: $this->_default; }
/** * Factory method to return a preconfigured Zend_Service_StrikeIron_* * instance. * * @param null|string $options Service options * @return object Zend_Service_StrikeIron_* instance * @throws Zend_Service_StrikeIron_Exception */ public function getService($options = array()) { $class = isset($options['class']) ? $options['class'] : 'Base'; unset($options['class']); if (strpos($class, '_') === false) { $class = "Zend_Service_StrikeIron_{$class}"; } try { if (!class_exists($class)) { // require_once 'Zend/Loader.php'; @Zend_Loader::loadClass($class); } if (!class_exists($class, false)) { throw new Exception('Class file not found'); } } catch (Exception $e) { $msg = "Service '{$class}' could not be loaded: " . $e->getMessage(); /** * @see Zend_Service_StrikeIron_Exception */ // require_once 'Zend/Service/StrikeIron/Exception.php'; throw new Zend_Service_StrikeIron_Exception($msg, $e->getCode(), $e); } // instantiate and return the service $service = new $class(array_merge($this->_options, $options)); return $service; }