本文整理汇总了PHP中instantiate函数的典型用法代码示例。如果您正苦于以下问题:PHP instantiate函数的具体用法?PHP instantiate怎么用?PHP instantiate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了instantiate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getCitationOutputFilterInstance
/**
* Retrieve the citation output filter that will be
* used to transform citations.
* @return TemplateBasedFilter
*/
function getCitationOutputFilterInstance()
{
$citationOutputFilterName = $this->getData('citationOutputFilterName');
assert(!is_null($citationOutputFilterName));
list($inputTypeDescription, $outputTypeDescription) = $this->getCitationOutputFilterTypeDescriptions();
$filterGroup = PersistableFilter::tempGroup($inputTypeDescription, $outputTypeDescription);
return instantiate($citationOutputFilterName, 'TemplateBasedFilter', null, null, $filterGroup);
}
开发者ID:PublishingWithoutWalls,项目名称:pkp-lib,代码行数:13,代码来源:TemplateBasedReferencesListFilter.inc.php
示例2: get_callable
/**
* get_callable() is used to retrieve a PHP callable from a specification.
*
* P framework allows callables to be anything that passes is_callable()
* or anything in the form "Class->method"
*
* @param callable|string $specification
* @param array|\ArrayAccess $parameters
* @return \callable
*/
function get_callable($specification, $parameters = array())
{
if (is_callable($specification)) {
return $specification;
} elseif (is_instantiable($specification)) {
return instantiate($specification, $parameters);
}
throw new \InvalidArgumentException('Provided specification cannot become callable');
}
开发者ID:pframework,项目名称:p,代码行数:19,代码来源:functions.php
示例3: instantiate
/**
* Get the supported meta-data schema (lazy load)
* @return MetadataSchema
*/
function &getMetadataSchema()
{
// Lazy-load the meta-data schema if this has
// not been done before.
if (is_null($this->_metadataSchema)) {
$this->_metadataSchema =& instantiate($this->getMetadataSchemaName(), 'MetadataSchema');
assert(is_object($this->_metadataSchema));
}
return $this->_metadataSchema;
}
开发者ID:ingmarschuster,项目名称:MindResearchRepository,代码行数:14,代码来源:MetadataDataObjectAdapter.inc.php
示例4: fatalError
/**
* Retrieve a reference to the specified DAO.
* @param $name string the class name of the requested DAO
* @param $dbconn ADONewConnection optional
* @return DAO
*/
function &getDAO($name, $dbconn = null)
{
$daos =& DAORegistry::getDAOs();
if (!isset($daos[$name])) {
// Import the required DAO class.
$application =& PKPApplication::getApplication();
$className = $application->getQualifiedDAOName($name);
if (!$className) {
fatalError('Unrecognized DAO ' . $name . '!');
}
// Only instantiate each class of DAO a single time
$daos[$name] =& instantiate($className, array('DAO', 'XMLDAO'));
if ($dbconn != null) {
$daos[$name]->setDataSource($dbconn);
}
}
return $daos[$name];
}
开发者ID:yuricampos,项目名称:ojs,代码行数:24,代码来源:DAORegistry.inc.php
示例5: fatalError
/**
* Retrieve a reference to the specified DAO.
* @param $name string the class name of the requested DAO
* @param $dbconn ADONewConnection optional
* @return DAO
*/
function &getDAO($name, $dbconn = null)
{
$daos =& DAORegistry::getDAOs();
if (!isset($daos[$name])) {
// Import the required DAO class.
$application =& PKPApplication::getApplication();
$className = $application->getQualifiedDAOName($name);
if (!$className) {
fatalError('Unrecognized DAO ' . $name . '!');
}
// Only instantiate each class of DAO a single time
$daos[$name] =& instantiate($className, array('DAO', 'XMLDAO'));
if ($dbconn != null) {
// FIXME Needed by installer but shouldn't access member variable directly
$daos[$name]->_dataSource = $dbconn;
}
}
return $daos[$name];
}
开发者ID:ingmarschuster,项目名称:MindResearchRepository,代码行数:25,代码来源:DAORegistry.inc.php
示例6: explode
/**
* Takes a plain text type descriptor, identifies the namespace
* and instantiates the corresponding type description object.
*
* @param $typeDescription string A plain text type description.
*
* Type descriptions consist of two parts:
* * a type namespace
* * a type name (optionally including parameters like cardinality, etc.)
*
* Example:
* primitive::string[5]
* -> namespace: primitive - type name: string[5]
*
* Each namespace will be mapped to one subclass of the TypeDescription
* class which will then be responsible to parse the given type name.
*
* @return TypeDescription or null if the type description is invalid.
*/
function &instantiateTypeDescription($typeDescription)
{
$nullVar = null;
// Identify the namespace
$typeDescriptionParts = explode('::', $typeDescription);
if (count($typeDescriptionParts) != 2) {
return $nullVar;
}
// Map the namespace to a type description class
$typeDescriptionClass = $this->_namespaceMap($typeDescriptionParts[0]);
if (is_null($typeDescriptionClass)) {
return $nullVar;
}
// Instantiate and return the type description object
$typeDescriptionObject =& instantiate($typeDescriptionClass, 'TypeDescription', null, null, $typeDescriptionParts[1]);
if (!is_object($typeDescriptionObject)) {
return $nullVar;
}
return $typeDescriptionObject;
}
开发者ID:doana,项目名称:pkp-lib,代码行数:39,代码来源:TypeDescriptionFactory.inc.php
示例7: XML_HTMLSax
/**
* Constructs XML_HTMLSax selecting concrete StateParser subclass
* depending on PHP version being used as well as setting the default
* NullHandler for all callbacks<br />
* @access public
*/
function XML_HTMLSax()
{
if (version_compare(phpversion(), '4.3', 'ge')) {
$this->state_parser = instantiate('XML_HTMLSax_StateParser_Gtet430', $this);
} else {
$this->state_parser = instantiate('XML_HTMLSax_StateParser_Lt430', $this);
}
$nullhandler = instantiate('XML_HTMLSax_NullHandler');
$this->set_object($nullhandler);
$this->set_element_handler('DoNothing', 'DoNothing');
$this->set_data_handler('DoNothing');
$this->set_pi_handler('DoNothing');
$this->set_jasp_handler('DoNothing');
$this->set_escape_handler('DoNothing');
}
开发者ID:freebasic,项目名称:fbwikka,代码行数:21,代码来源:HTMLSax.php
示例8: installFilterTemplates
/**
* Installs filter template entries into the filters table.
* FIXME: Move this to plug-in installation when moving filters to plug-ins, see #5157.
*/
function installFilterTemplates()
{
// Filters are supported on PHP5+ only.
if (!checkPhpVersion('5.0.0')) {
return true;
}
$filterDao =& DAORegistry::getDAO('FilterDAO');
$filtersToBeInstalled = array('lib.pkp.classes.citation.lookup.crossref.CrossrefNlmCitationSchemaFilter', 'lib.pkp.classes.citation.lookup.pubmed.PubmedNlmCitationSchemaFilter', 'lib.pkp.classes.citation.lookup.worldcat.WorldcatNlmCitationSchemaFilter', 'lib.pkp.classes.citation.parser.freecite.FreeciteRawCitationNlmCitationSchemaFilter', 'lib.pkp.classes.citation.parser.paracite.ParaciteRawCitationNlmCitationSchemaFilter', 'lib.pkp.classes.citation.parser.parscit.ParscitRawCitationNlmCitationSchemaFilter', 'lib.pkp.classes.citation.parser.regex.RegexRawCitationNlmCitationSchemaFilter', 'lib.pkp.classes.citation.output.abnt.NlmCitationSchemaAbntFilter', 'lib.pkp.classes.citation.output.apa.NlmCitationSchemaApaFilter', 'lib.pkp.classes.citation.output.mla.NlmCitationSchemaMlaFilter', 'lib.pkp.classes.citation.output.vancouver.NlmCitationSchemaVancouverFilter', 'lib.pkp.classes.importexport.nlm.PKPSubmissionNlmXmlFilter');
import('lib.pkp.classes.citation.output.PlainTextReferencesListFilter');
foreach ($filtersToBeInstalled as $filterToBeInstalled) {
// Instantiate filter.
$filter =& instantiate($filterToBeInstalled, 'Filter');
// Install citation output filters as non-configurable site-wide filter instances.
if (is_a($filter, 'NlmCitationSchemaCitationOutputFormatFilter') || is_a($filter, 'PKPSubmissionNlmXmlFilter')) {
$filter->setIsTemplate(false);
// Check whether the filter instance has been
// installed before.
$existingFilters =& $filterDao->getObjectsByClass($filterToBeInstalled, 0, false);
// Install other filter as configurable templates.
} else {
$filter->setIsTemplate(true);
// Check whether the filter template has been
// installed before.
$existingFilters =& $filterDao->getObjectsByClass($filterToBeInstalled, 0, true);
}
// Guarantee idempotence.
if ($existingFilters->getCount()) {
continue;
}
// Install the filter or template.
$filterDao->insertObject($filter, 0);
// If this is a citation output filter then also install a corresponding references list filter.
if (is_a($filter, 'NlmCitationSchemaCitationOutputFormatFilter')) {
// Only Vancouver Style listings require numerical ordering.
if (is_a($filter, 'NlmCitationSchemaVancouverFilter')) {
$ordering = REFERENCES_LIST_ORDERING_NUMERICAL;
} else {
$ordering = REFERENCES_LIST_ORDERING_ALPHABETICAL;
}
// Instantiate the filter.
$referencesListFilter = new PlainTextReferencesListFilter($filter->getDisplayName(), $filter->getClassName(), $ordering);
$referencesListFilter->setIsTemplate(false);
// Install the filter.
$filterDao->insertObject($referencesListFilter, 0);
unset($referencesListFilter);
}
unset($filter);
}
// Composite filters are more complex to install because they
// need to be constructed first:
// 1) Check and install the ISBNdb filter template.
$alreadyInstalled = false;
$existingTemplatesFactory =& $filterDao->getObjectsByClass('lib.pkp.classes.filter.GenericSequencerFilter', 0, true);
$existingTemplates =& $existingTemplatesFactory->toArray();
foreach ($existingTemplates as $existingTemplate) {
$subFilters =& $existingTemplate->getFilters();
if (count($subFilters) != 2) {
continue;
}
if (!(isset($subFilters[1]) && is_a($subFilters[1], 'IsbndbNlmCitationSchemaIsbnFilter'))) {
continue;
}
if (!(isset($subFilters[2]) && is_a($subFilters[2], 'IsbndbIsbnNlmCitationSchemaFilter'))) {
continue;
}
$alreadyInstalled = true;
break;
}
if (!$alreadyInstalled) {
// Instantiate the filter as a configurable template.
$isbndbTransformation = array('metadata::lib.pkp.classes.metadata.nlm.NlmCitationSchema(CITATION)', 'metadata::lib.pkp.classes.metadata.nlm.NlmCitationSchema(CITATION)');
import('lib.pkp.classes.filter.GenericSequencerFilter');
$isbndbFilter = new GenericSequencerFilter('ISBNdb', $isbndbTransformation);
$isbndbFilter->setIsTemplate(true);
// Instantiate and add the NLM-to-ISBN filter.
import('lib.pkp.classes.citation.lookup.isbndb.IsbndbNlmCitationSchemaIsbnFilter');
$nlmToIsbnFilter = new IsbndbNlmCitationSchemaIsbnFilter();
$isbndbFilter->addFilter($nlmToIsbnFilter);
// Instantiate and add the ISBN-to-NLM filter.
import('lib.pkp.classes.citation.lookup.isbndb.IsbndbIsbnNlmCitationSchemaFilter');
$isbnToNlmFilter = new IsbndbIsbnNlmCitationSchemaFilter();
$isbndbFilter->addFilter($isbnToNlmFilter);
// Add the settings mapping.
$isbndbFilter->setSettingsMapping(array('apiKey' => array('seq' . $nlmToIsbnFilter->getSeq() . '_apiKey', 'seq' . $isbnToNlmFilter->getSeq() . '_apiKey'), 'isOptional' => array('seq' . $nlmToIsbnFilter->getSeq() . '_isOptional', 'seq' . $isbnToNlmFilter->getSeq() . '_isOptional')));
// Persist the composite filter.
$filterDao->insertObject($isbndbFilter, 0);
}
// 3) Check and install the NLM XML 2.3 output filter.
$alreadyInstalled = false;
$existingTemplatesFactory =& $filterDao->getObjectsByClass('lib.pkp.classes.filter.GenericSequencerFilter', 0, false);
$existingTemplates =& $existingTemplatesFactory->toArray();
foreach ($existingTemplates as $existingTemplate) {
$subFilters =& $existingTemplate->getFilters();
if (count($subFilters) != 2) {
continue;
}
//.........这里部分代码省略.........
开发者ID:ingmarschuster,项目名称:MindResearchRepository,代码行数:101,代码来源:Installer.inc.php
示例9: str_replace
/**
* Get the (validated) RPC service endpoint from the request.
* If no such RPC service endpoint can be constructed then the method
* returns null.
* @param $request PKPRequest the request to be routed
* @return callable an array with the handler instance
* and the handler operation to be called by call_user_func().
*/
function &getRpcServiceEndpoint(&$request)
{
if ($this->_rpcServiceEndpoint === false) {
// We have not yet resolved this request. Mark the
// state variable so that we don't try again next
// time.
$this->_rpcServiceEndpoint = $nullVar = null;
//
// Component Handler
//
// Retrieve requested component handler
$component = $this->getRequestedComponent($request);
if (empty($component)) {
return $nullVar;
}
// Construct the component handler file name and test its existence.
$component = 'controllers.' . $component;
$componentFileName = str_replace('.', '/', $component) . '.inc.php';
switch (true) {
case file_exists($componentFileName):
break;
case file_exists('lib/pkp/' . $componentFileName):
$component = 'lib.pkp.' . $component;
break;
default:
// Request to non-existent handler
return $nullVar;
}
// We expect the handler to be part of one
// of the following packages:
$allowedPackages = array('controllers', 'lib.pkp.controllers');
// Retrieve requested component operation
$op = $this->getRequestedOp($request);
assert(!empty($op));
// A handler at least needs to implement the
// following methods:
$requiredMethods = array($op, 'authorize', 'validate', 'initialize');
$componentInstance =& instantiate($component, 'PKPHandler', $allowedPackages, $requiredMethods);
if (!is_object($componentInstance)) {
return $nullVar;
}
//
// Callable service endpoint
//
// Construct the callable array
$this->_rpcServiceEndpoint = array($componentInstance, $op);
}
return $this->_rpcServiceEndpoint;
}
开发者ID:farhanabbas1983,项目名称:ojs-1,代码行数:57,代码来源:PKPComponentRouter.inc.php
示例10: _getDaoDelegate
/**
* Return the requested SubmissionFileDAODelegate.
* @param $fileImplementation string the class name of
* a file implementation that the requested delegate
* should serve.
* @return SubmissionFileDAODelegate
*/
private function _getDaoDelegate($fileImplementation)
{
// Normalize the file implementation name.
$fileImplementation = strtolower_codesafe($fileImplementation);
// Did we already instantiate the requested delegate?
if (!isset($this->_delegates[$fileImplementation])) {
// Instantiate the requested delegate.
$delegateClasses = $this->getDelegateClassNames();
assert(isset($delegateClasses[$fileImplementation]));
$delegateClass = $delegateClasses[$fileImplementation];
$this->_delegates[$fileImplementation] = instantiate($delegateClass, 'SubmissionFileDAODelegate', null, null, $this);
}
// Return the delegate.
return $this->_delegates[$fileImplementation];
}
开发者ID:energylevels,项目名称:pkp-lib,代码行数:22,代码来源:PKPSubmissionFileDAO.inc.php
示例11: fatalError
/**
* Instantiate a plugin.
*
* This method can be called statically.
*
* @param $category string
* @param $categoryDir string
* @param $file string
* @param $classToCheck string set null to maintain pre-2.3.x backwards compatibility
* @return Plugin
*/
function &_instantiatePlugin($category, $categoryDir, $file, $classToCheck = null)
{
if (!is_null($classToCheck) && !preg_match('/[a-zA-Z0-9]+/', $file)) {
fatalError('Invalid product name "' . $file . '"!');
}
$pluginPath = "{$categoryDir}/{$file}";
$plugin = null;
// Try the plug-in wrapper first for backwards
// compatibility.
$pluginWrapper = "{$pluginPath}/index.php";
if (file_exists($pluginWrapper)) {
$plugin = (include $pluginWrapper);
if ($classToCheck) {
assert(is_a($plugin, $classToCheck));
}
} else {
// Try the well-known plug-in class name next.
$pluginClassName = ucfirst($file) . ucfirst($category) . 'Plugin';
$pluginClassFile = $pluginClassName . '.inc.php';
if (file_exists("{$pluginPath}/{$pluginClassFile}")) {
// Try to instantiate the plug-in class.
$pluginPackage = 'plugins.' . $category . '.' . $file;
$plugin =& instantiate($pluginPackage . '.' . $pluginClassName, $pluginClassName, $pluginPackage, 'register');
}
}
// Make sure that the plug-in inherits from the right class.
if (is_object($plugin)) {
assert(is_a($plugin, 'Plugin'));
} else {
assert(is_null($plugin));
}
return $plugin;
}
开发者ID:farhanabbas1983,项目名称:ojs-1,代码行数:44,代码来源:PluginRegistry.inc.php
示例12: assert
/**
* Instantiates the given class from the given
* package
* @param $packageName string
* @param $className string
* @return object
*/
function &instantiateClass($packageName, $className)
{
assert(!empty($packageName) && !empty($className));
$object =& instantiate($packageName . '.' . $className, $className);
return $object;
}
开发者ID:JovanyJeff,项目名称:hrp,代码行数:13,代码来源:ClassTypeDescription.inc.php
示例13: instantiate
/**
* @see TemplateBasedReferencesListFilter::getCitationOutputFilterInstance()
*/
function &getCitationOutputFilterInstance()
{
$citationOutputFilterName = $this->getData('citationOutputFilterName');
$nlmCitationOutputFilter =& instantiate($citationOutputFilterName, 'NlmCitationSchemaCitationOutputFormatFilter');
return $nlmCitationOutputFilter;
}
开发者ID:JovanyJeff,项目名称:hrp,代码行数:9,代码来源:PlainTextReferencesListFilter.inc.php
示例14: foreach
$image->descriptionHtmlSyndicated = FEED_DESCRIPTION_HTML;
$rss->image = $image;
$n = (int) $n;
// get feed items
// To optimize memory usage, we should load the minimum items. But, we must load
// more than what we need, because we may have no rights on some items.
// Twice the number we need is just an arbitrary value!!! (2*$n)
if ($comments = $this->LoadRecentComments(2 * $n)) {
$c = 0;
foreach ($comments as $comment) {
if (!$this->HasAccess('comment_read', $comment['page_tag'])) {
continue;
}
$c++;
#$item = new FeedItem();
$item = instantiate('FeedItem');
$item->title = $comment['page_tag'];
$item->link = str_replace('&', '&', $this->Href('', $comment['page_tag'], 'show_comments=1') . '#comment_' . $comment['id']);
// @@@ ^ uses &amp; in all formats - this is FC escaping the & that Href() outputs
// WARNING: the double escape comes from the use of htmlspecialchars()
// see also recentchanges.xml.php
$item->date = date('r', strtotime($comment['time']));
$item->description = 'By ' . $comment['user'] . ': ' . $comment['comment'] . "\n";
// @@@ ^ JW: should link to actual comment, or (maybe) the page that has the comment
/*
http://dublincore.org/documents/1999/07/02/dces/
Element: Source
Name: Source
Identifier: Source
Definition: A Reference to a resource from which the present resource
开发者ID:freebasic,项目名称:fbwikka,代码行数:31,代码来源:comments.xml.php
示例15: instantiate
/**
* Construct a new configured filter instance (transformation).
* @param $filterClassName string a fully qualified class name
* @param $inputType string
* @param $outputType string
* @return Filter
*/
function &_newDataObject($filterClassName, $inputType, $outputType)
{
// Instantiate the filter
$filter =& instantiate($filterClassName, 'Filter');
if (!is_object($filter)) {
fatalError('Error while instantiating class "' . $filterClassName . '" as filter!');
}
// Set input/output data types (transformation type).
// NB: This will raise a fatal error if the transformation is not
// supported by this filter.
$filter->setTransformationType($inputType, $outputType);
return $filter;
}
开发者ID:JovanyJeff,项目名称:hrp,代码行数:20,代码来源:FilterDAO.inc.php
示例16: list
if (preg_match("#^(.*)\$#", $wakka, $matches)) {
list(, $page) = $matches;
}
}
//Fix lowercase mod_rewrite bug: URL rewriting makes pagename lowercase. #135
if (strtolower($page) == $page && isset($_SERVER['REQUEST_URI'])) {
$pattern = preg_quote($page, '/');
if (preg_match("/({$pattern})/i", urldecode($_SERVER['REQUEST_URI']), $match_url)) {
$page = $match_url[1];
}
}
//$page = preg_replace('/_/', ' ', $page);
/**
* Create Wakka object
*/
$wakka = instantiate('Wakka', $wakkaConfig);
/**
* Check for database access.
*/
if (!$wakka->dblink) {
echo '<em class="error">' . T_("Error: Unable to connect to the database.") . '</em>';
exit;
}
/**
* Save session ID
*/
$user = $wakka->GetUser();
// Only store sessions for real users!
if (NULL != $user) {
$res = $wakka->LoadSingle("SELECT * FROM " . $wakka->config['table_prefix'] . "sessions WHERE sessionid='" . session_id() . "' AND userid='" . $user['name'] . "'");
if (isset($res)) {
开发者ID:freebasic,项目名称:fbwikka,代码行数:31,代码来源:wikka.php
示例17: assert
/**
* Construct a new configured filter instance (transformation).
* @param $filterClassName string a fully qualified class name
* @param $filterGroupId integer
* @return PersistableFilter
*/
function &_newDataObject($filterClassName, $filterGroupId)
{
// Instantiate the filter group.
$filterGroupDao =& DAORegistry::getDAO('FilterGroupDAO');
/* @var $filterGroupDao FilterGroupDAO */
$filterGroup =& $filterGroupDao->getObjectById($filterGroupId);
assert(is_a($filterGroup, 'FilterGroup'));
// Instantiate the filter
$filter =& instantiate($filterClassName, 'PersistableFilter', null, 'execute', $filterGroup);
/* @var $filter PersistableFilter */
if (!is_object($filter)) {
fatalError('Error while instantiating class "' . $filterClassName . '" as filter!');
}
return $filter;
}
开发者ID:ramonsodoma,项目名称:pkp-lib,代码行数:21,代码来源:FilterDAO.inc.php
示例18: sprintf
if ($this->debugMode) {
$errortext = sprintf($this->error, $line, $err);
echo '<!-- ' . $errortext . ' -->' . "\n";
}
}
}
}
}
if (preg_match("/^(http|https):\\/\\/([^\\s\"<>]+)\$/i", $rss_path)) {
if ($caching) {
// Create unique cache file name based on URL
$rss_cache_file = md5($rss_path) . ".xml";
}
//Load the RSS Feed: workaround to hide error messages within HTML comments:
#$rss =& new Wikka_Onyx();
$rss = instantiate('Wikka_Onyx');
$rss->setCachePath($rss_cache_path);
$rss->parse($rss_path, $rss_cache_file, $rss_cache_time);
$meta = $rss->getData(ONYX_META);
//List the feed's items
$cached_output = "<h3>" . $meta['title'] . "</h3>";
$cached_output .= "<ul>\n";
while ($max_items > 0 && ($item = $rss->getNextItem())) {
$cached_output .= "<li><a href=\"" . $item['link'] . "\">" . $item['title'] . "</a><br />\n";
if (isset($item['description'])) {
$cached_output .= $item['description'];
}
$cached_output .= "</li>\n";
$max_items = $max_items - 1;
}
$cached_output .= "</ul>\n";
开发者ID:freebasic,项目名称:fbwikka,代码行数:31,代码来源:rss.php
示例19: GeSHi_Highlight
/**
* Highlight a code block with GeSHi.
*
* The path to GeSHi and the GeSHi language files must be defined in the configuration.
*
* This implementation fits in with general Wikka behavior; e.g., we use classes and an external
* stylesheet to render hilighting.
*
* Apart from this fixed general behavior, WikiAdmin can configure a few behaviors via the
* configuration file:
* geshi_header - wrap code in div (default) or pre
* geshi_line_numbers - disable line numbering, or enable normal or fancy line numbering
* geshi_tab_width - override tab width (default is 8 but 4 is more commonly used in code)
*
* Limitation: while line numbering is supported, extra GeSHi styling for line numbers is not.
* When line numbering is enabled, the end user can "turn it on" by specifying a starting line
* number together with the language code in a code block, e.g., (php;260); this number is then
* passed as the $start parameter for this method.
*
* @since wikka 1.1.6.0
*
* @access public
* @uses Config::$geshi_path
* @uses Config::$geshi_languages_path
* @uses Config::$geshi_header
* @uses Config::$geshi_line_numbers
* @uses Config::$geshi_tab_width
* @uses GeShi
*
* @param string $sourcecode required: source code to be highlighted
* @param string $language required: language spec to select highlighter
* @param integer $start optional: start line number; if supplied and >= 1 line numbering
* will be turned on if it is enabled in the configuration.
* @return string code block with syntax highlighting classes applied
* @todo support for GeSHi line number styles
* @todo enable error handling
*/
function GeSHi_Highlight($sourcecode, $language, $start = 0)
{
// create GeSHi object
include_once $this->GetConfigValue('geshi_path') . DIRECTORY_SEPARATOR . 'geshi.php';
$geshi = instantiate('GeSHi', $sourcecode, $language, $this->GetConfigValue('geshi_languages_path'));
# create object by reference
$geshi->enable_classes();
# use classes for hilighting (must be first after creating object)
$geshi->set_overall_class('code');
# enables using a single stylesheet for multiple code fragments
// configure user-defined behavior
$geshi->set_header_type(GESHI_HEADER_DIV);
# set default
if (NULL !== $this->GetConfigValue('geshi_header')) {
if ('pre' == $this->GetConfigValue('geshi_header')) {
$geshi->set_header_type(GESHI_HEADER_PRE);
}
}
$geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS);
# set default
if ($start > 0) {
if (NULL !== $this->GetConfigValue('geshi_line_numbers')) {
if ('1' == $this->GetConfigValue('geshi_line_numbers')) {
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
} elseif ('2' == $this->GetConfigValue('geshi_line_numbers')) {
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
}
if ($start > 1) {
$geshi->start_line_numbers_at($start);
}
}
}
if (NULL !== $this->GetConfigValue('geshi_tab_width')) {
$geshi->set_tab_width($this->GetConfigValue('geshi_tab_width'));
}
// parse and return highlighted code
// comments added to make GeSHi-highlighted block visible in code JW/20070220
return '<!--start GeSHi-->' . "\n" . $geshi->parse_code() . "\n" . '<!--end GeSHi-->' . "\n";
}
开发者ID:freebasic,项目名称:fbwikka,代码行数:76,代码来源:Wakka.class.php
示例20: PersistentObject
/**
*
* @deprecated
*/
function PersistentObject($tablename, $unique_set, $cache_by = NULL, $use_cache = true, $is_transient = false, $allowCreate = true)
{
deprecated_functions::PersistentObject();
return instantiate($tablename, $unique_set, $cache_by, $use_cache, $is_transient, $allowCreate);
}
开发者ID:rb26,项目名称:zenphoto,代码行数:9,代码来源:classes.php
注:本文中的instantiate函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论