本文整理汇总了PHP中textpattern函数的典型用法代码示例。如果您正苦于以下问题:PHP textpattern函数的具体用法?PHP textpattern怎么用?PHP textpattern使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了textpattern函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: define
define("txpinterface", "admin");
$thisversion = '4.1.0';
$txp_using_svn = true;
// set false for releases
ob_start(NULL, 2048);
if (!@(include './config.php')) {
ob_end_clean();
include txpath . '/setup/index.php';
exit;
} else {
ob_end_clean();
}
header("Content-type: text/html; charset=utf-8");
if (isset($_POST['form_preview'])) {
include txpath . '/publish.php';
textpattern();
exit;
}
error_reporting(E_ALL);
@ini_set("display_errors", "1");
include_once txpath . '/lib/constants.php';
include_once txpath . '/lib/mdb.php';
include_once txpath . '/lib/txplib_db.php';
include_once txpath . '/lib/txplib_prefs.php';
include_once txpath . '/lib/txplib_forms.php';
include_once txpath . '/lib/txplib_html.php';
include_once txpath . '/lib/txplib_misc.php';
include_once txpath . '/lib/txplib_element.php';
include_once txpath . '/lib/txplib_class.php';
include_once txpath . '/lib/admin_config.php';
include_once txpath . '/lib/txplib_controller.php';
示例2: _textpattern
function _textpattern()
{
global $plugins_ver, $pretext, $prefs, $plugin_callback;
$this->debug('Plugin: ' . $this->plugin_name . ' - ' . $plugins_ver[$this->plugin_name]);
$this->debug('Function: ' . __FUNCTION__ . '()');
// URI
$req = $pretext['req'];
$req = preg_replace('%\\?[^\\/]+$%', '', $req);
$this->debug('Request URI: ' . $req);
$uri = explode('/', trim($req, '/'));
// The number of components comes in useful when determining the best partial match.
$uri_component_count = count($uri);
// Permanent links
$permlinks = $this->get_all_permlinks(1);
// Force Textpattern and tags to use messy URLs - these are easier to
// find in regex
$this->set_permlink_mode();
if (count($permlinks)) {
// We also want to match the front page of the site (for page numbers / feeds etc..).
// Add a permlinks rule which will do that.
$permlinks['default'] = array('components' => array(), 'settings' => array('pl_name' => 'gbp_permanent_links_default', 'pl_precedence' => '', 'pl_preview' => '/', 'con_section' => '', 'con_category' => '', 'des_section' => '', 'des_category' => '', 'des_permlink' => '', 'des_feed' => '', 'des_location' => '', 'des_page' => ''));
// Extend the pretext_replacement scope outside the foreach permlink loop
$pretext_replacement = NULL;
foreach ($permlinks as $id => $pl) {
// Extract the permlink settings
$pl_settings = $pl['settings'];
extract($pl_settings);
$this->debug('Permlink name: ' . $pl_name);
$this->debug('Permlink id: ' . $id);
$this->debug('Preview: ' . $pl_preview);
$pl_components = $pl['components'];
// URI components
$uri_components = $uri;
$this->debug('PL component count: ' . count($pl_components));
$this->debug('URL component count: ' . count($uri_components));
$date = false;
$title_page_feed = false;
foreach ($pl_components as $pl_c) {
// Are we expecting a date component? If so the number of pl and uri components won't match
if ($pl_c['type'] == 'date') {
$date = true;
} else {
if (in_array($pl_c['type'], array('title', 'page', 'feed'))) {
$title_page_feed = true;
}
}
}
if (!$title_page_feed) {
// If there isn't a title, page or feed component then append a special type for cleaver partial matching
$pl_components[] = array('type' => 'title_page_feed', 'prefix' => '', 'suffix' => '', 'regex' => '', 'text' => '');
}
// Exit early if there are more URL components than PL components,
// taking into account whether there is a data component
if (!$uri_components[0] || count($uri_components) > count($pl_components) + ($date ? 2 : 0)) {
$this->debug('More URL components than PL components');
continue;
}
// Reset pretext_replacement as we are about to start another comparison
$pretext_replacement = array('permlink_id' => $id);
// Reset the article context string
$context = array();
unset($context_str);
if (!empty($des_section)) {
$context[] = "`Section` = '{$des_section}'";
}
if (!empty($des_category)) {
$context[] = "(`Category1` = '{$des_category}' OR `Category2` = '{$des_category}')";
}
$context_str = count($context) > 0 ? 'and ' . join(' and ', $context) : '';
// Assume there is no match
$partial_match = false;
$cleaver_partial_match = false;
// Loop through the permlink components
foreach ($pl_components as $pl_c_index => $pl_c) {
// Assume there is no match
$match = false;
// Check to see if there are still URI components to be checked.
if (count($uri_components)) {
// Get the next component.
$uri_c = array_shift($uri_components);
} else {
if (!$title_page_feed && count($pl_components) - 1 == $uri_component_count) {
// If we appended a title_page_feed component earlier and permlink and URI components
// counts are equal, we must of finished checking this permlink, and it matches so break.
$match = true;
break;
} else {
// If there are no more URI components then we have a partial match.
// Store the partial match data unless there has been a preceding permlink with the
// same number of components, as permlink have already been sorted by precedence.
if (!array_key_exists($uri_component_count, $this->partial_matches)) {
$this->partial_matches[$uri_component_count] = $pretext_replacement;
}
// Unset pretext_replacement as changes could of been made in a preceding component
unset($pretext_replacement);
// Break early form the foreach permlink components loop.
$partial_match = true;
break;
}
}
//.........这里部分代码省略.........