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


PHP xPDO::escSplit方法代码示例

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


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

示例1: initialize

 public function initialize()
 {
     $this->setDefaultProperties(array('classKey' => 'modSnippet', 'pk' => false));
     $tagParts = xPDO::escSplit('?', $this->getProperty('tag'), '`', 2);
     $tagNameParts = xPDO::escSplit('@', $tagParts[0]);
     $propertySet = isset($tagNameParts[1]) ? trim($tagNameParts[1]) : null;
     if (isset($propertySet) && strpos($propertySet, ':') != false) {
         $propSetParts = xPDO::escSplit(':', $propertySet);
         $propertySet = trim($propSetParts[0]);
     }
     if (isset($propertySet) && ($ps = $this->modx->getObject('modPropertySet', array('name' => $propertySet)))) {
         $this->setProperty('propertySet', $ps->id);
     }
     if (isset($tagParts[1])) {
         $tagPropString = ltrim(trim($tagParts[1]), '&');
         $this->tagProperties = $this->modx->getParser()->parseProperties($tagPropString);
     }
     //$this->modx->log(1,print_r($this->tagProperties,1));
     //$this->modx->log(modX::LOG_LEVEL_ERROR, $this->getProperty('tag'));
     $this->element = $this->modx->getObject($this->getProperty('classKey'), $this->getProperty('pk'));
     if (empty($this->element)) {
         return $this->modx->lexicon('element_err_nf');
     }
     return true;
 }
开发者ID:sergant210,项目名称:tagElementPlugin,代码行数:25,代码来源:getinsertproperties.class.php

示例2: processTag

 public function processTag($tag, $processUncacheable = true)
 {
     // We need only # placeholders
     if ($tag[1][0] !== '#' && strpos($tag[1], '!#') === false) {
         return parent::processTag($tag, $processUncacheable);
     }
     $this->_processingTag = true;
     $element = null;
     $elementOutput = null;
     $outerTag = $tag[0];
     $innerTag = $tag[1];
     /* collect any nested element tags in the innerTag and process them */
     $this->processElementTags($outerTag, $innerTag, $processUncacheable);
     $this->_processingTag = true;
     $outerTag = '[[' . $innerTag . ']]';
     $tagParts = xPDO::escSplit('?', $innerTag, '`', 2);
     $tagName = trim($tagParts[0]);
     $tagPropString = null;
     if (isset($tagParts[1])) {
         $tagPropString = trim($tagParts[1]);
     }
     $token = substr($tagName, 0, 1);
     $tokenOffset = 0;
     $cacheable = true;
     if ($token === '!') {
         if (!$processUncacheable) {
             $this->_processingTag = false;
             return $outerTag;
         }
         $cacheable = false;
         $tokenOffset++;
         $token = substr($tagName, $tokenOffset, 1);
     }
     if ($cacheable && $token !== '+') {
         $elementOutput = $this->loadFromCache($outerTag);
     }
     if ($elementOutput === null) {
         switch ($token) {
             case '#':
                 include_once $this->modx->getOption('core_path') . 'components/fastfield/model/fastfield/fastfield.php';
                 $tagName = substr($tagName, 1 + $tokenOffset);
                 $element = new modResourceFieldTag($this->modx);
                 $element->set('name', $tagName);
                 $element->setTag($outerTag);
                 $element->setCacheable($cacheable);
                 $elementOutput = $element->process($tagPropString);
                 break;
         }
     }
     if (($elementOutput === null || $elementOutput === false) && $outerTag !== $tag[0]) {
         $elementOutput = $outerTag;
     }
     if ($this->modx->getDebug() === true) {
         $this->modx->log(xPDO::LOG_LEVEL_DEBUG, "Processing {$outerTag} as {$innerTag} using tagname {$tagName}:\n" . print_r($elementOutput, 1) . "\n\n");
     }
     $this->_processingTag = false;
     return $elementOutput;
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:58,代码来源:fastfieldparser.class.php

示例3: initialize

 /**
  * {@inheritDoc}
  * @return boolean
  */
 public function initialize()
 {
     $this->objectType = $this->getProperty('elementType');
     $this->classKey = 'mod' . ucfirst($this->objectType);
     $this->permission = 'view_' . $this->objectType;
     $tag = $this->getProperty('tag');
     $tagParts = xPDO::escSplit('?', $tag, '`', 2);
     $tagName = trim($tagParts[0]);
     $parser = $this->modx->getParser();
     $elementName = $this->elementName = $parser->realname($tagName);
     if (empty($elementName)) {
         return $this->modx->lexicon($this->objectType . '_err_ns');
     }
     $query = $this->modx->newQuery($this->classKey, array('name' => $elementName));
     $query->select('id');
     $id = $this->modx->getValue($query->prepare());
     if (!$id) {
         return $this->modx->lexicon($this->objectType . '_err_nf');
     }
     $this->setProperty('id', $id);
     return parent::initialize();
 }
开发者ID:sergant210,项目名称:tagElementPlugin,代码行数:26,代码来源:getproperties.class.php

示例4: writeSchema

 /**
  * Write an xPDO XML Schema from your database.
  *
  * @param string $schemaFile The name (including path) of the schemaFile you
  * want to write.
  * @param string $package Name of the package to generate the classes in.
  * @param string $baseClass The class which all classes in the package will
  * extend; by default this is set to {@link xPDOObject} and any
  * auto_increment fields with the column name 'id' will extend {@link
  * xPDOSimpleObject} automatically.
  * @param string $tablePrefix The table prefix for the current connection,
  * which will be removed from all of the generated class and table names.
  * Specify a prefix when creating a new {@link xPDO} instance to recreate
  * the tables with the same prefix, but still use the generic class names.
  * @param boolean $restrictPrefix Only reverse-engineer tables that have the
  * specified tablePrefix; if tablePrefix is empty, this is ignored.
  * @return boolean True on success, false on failure.
  */
 public function writeSchema($schemaFile, $package = '', $baseClass = '', $tablePrefix = '', $restrictPrefix = false)
 {
     if (empty($package)) {
         $package = $this->manager->xpdo->package;
     }
     if (empty($baseClass)) {
         $baseClass = 'xPDOObject';
     }
     if (empty($tablePrefix)) {
         $tablePrefix = $this->manager->xpdo->config[xPDO::OPT_TABLE_PREFIX];
     }
     $schemaVersion = xPDO::SCHEMA_VERSION;
     $xmlContent = array();
     $xmlContent[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
     $xmlContent[] = "<model package=\"{$package}\" baseClass=\"{$baseClass}\" platform=\"mysql\" defaultEngine=\"MyISAM\" version=\"{$schemaVersion}\">";
     //read list of tables
     $dbname = $this->manager->xpdo->escape($this->manager->xpdo->config['dbname']);
     $tableLike = $tablePrefix && $restrictPrefix ? " LIKE '{$tablePrefix}%'" : '';
     $tablesStmt = $this->manager->xpdo->prepare("SHOW TABLES FROM {$dbname}{$tableLike}");
     $tablesStmt->execute();
     $tables = $tablesStmt->fetchAll(PDO::FETCH_NUM);
     if ($this->manager->xpdo->getDebug() === true) {
         $this->manager->xpdo->log(xPDO::LOG_LEVEL_DEBUG, print_r($tables, true));
     }
     foreach ($tables as $table) {
         $xmlObject = array();
         $xmlFields = array();
         $xmlIndices = array();
         if (!($tableName = $this->getTableName($table[0], $tablePrefix, $restrictPrefix))) {
             continue;
         }
         $class = $this->getClassName($tableName);
         $extends = $baseClass;
         $fieldsStmt = $this->manager->xpdo->query('SHOW COLUMNS FROM ' . $this->manager->xpdo->escape($table[0]));
         if ($fieldsStmt) {
             $fields = $fieldsStmt->fetchAll(PDO::FETCH_ASSOC);
             if ($this->manager->xpdo->getDebug() === true) {
                 $this->manager->xpdo->log(xPDO::LOG_LEVEL_DEBUG, print_r($fields, true));
             }
             if (!empty($fields)) {
                 foreach ($fields as $field) {
                     $Field = '';
                     $Type = '';
                     $Null = '';
                     $Key = '';
                     $Default = '';
                     $Extra = '';
                     extract($field, EXTR_OVERWRITE);
                     $Type = xPDO::escSplit(' ', $Type, "'", 2);
                     $precisionPos = strpos($Type[0], '(');
                     $dbType = $precisionPos ? substr($Type[0], 0, $precisionPos) : $Type[0];
                     $dbType = strtolower($dbType);
                     $Precision = $precisionPos ? substr($Type[0], $precisionPos + 1, strrpos($Type[0], ')') - ($precisionPos + 1)) : '';
                     if (!empty($Precision)) {
                         $Precision = ' precision="' . trim($Precision) . '"';
                     }
                     $attributes = '';
                     if (isset($Type[1]) && !empty($Type[1])) {
                         $attributes = ' attributes="' . trim($Type[1]) . '"';
                     }
                     $PhpType = $this->manager->xpdo->driver->getPhpType($dbType);
                     $Null = ' null="' . ($Null === 'NO' ? 'false' : 'true') . '"';
                     $Key = $this->getIndex($Key);
                     $Default = $this->getDefault($Default);
                     if (!empty($Extra)) {
                         if ($Extra === 'auto_increment') {
                             if ($baseClass === 'xPDOObject' && $Field === 'id') {
                                 $extends = 'xPDOSimpleObject';
                                 continue;
                             } else {
                                 $Extra = ' generated="native"';
                             }
                         } else {
                             $Extra = ' extra="' . strtolower($Extra) . '"';
                         }
                         $Extra = ' ' . $Extra;
                     }
                     $xmlFields[] = "\t\t<field key=\"{$Field}\" dbtype=\"{$dbType}\"{$Precision}{$attributes} phptype=\"{$PhpType}\"{$Null}{$Default}{$Key}{$Extra} />";
                 }
             } else {
                 $this->manager->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'No columns were found in table ' . $table[0]);
             }
//.........这里部分代码省略.........
开发者ID:semencov-com,项目名称:affiliate,代码行数:101,代码来源:xpdogenerator.class.php

示例5: getPropertySet

 /**
  * Gets a named property set related to this element instance.
  *
  * If a setName parameter is not provided, this function will attempt to
  * extract a setName from the element name using the @ symbol to delimit the
  * name of the property set.
  *
  * Here is an example of an element tag using the @ modifier to specify a
  * property set name:
  *  [[ElementName@PropertySetName:FilterCommand=`FilterModifier`?
  *      &PropertyKey1=`PropertyValue1`
  *      &PropertyKey2=`PropertyValue2`
  *  ]]
  *
  * @access public
  * @param string|null $setName An explicit property set name to search for.
  * @return array|null An array of properties or null if no set is found.
  */
 public function getPropertySet($setName = null)
 {
     $propertySet = null;
     $name = $this->get('name');
     if (strpos($name, '@') !== false) {
         $psName = '';
         $split = xPDO::escSplit('@', $name);
         if ($split && isset($split[1])) {
             $name = $split[0];
             $psName = $split[1];
             $filters = xPDO::escSplit(':', $setName);
             if ($filters && isset($filters[1]) && !empty($filters[1])) {
                 $psName = $filters[0];
                 $name .= ':' . $filters[1];
             }
             $this->set('name', $name);
         }
         if (!empty($psName)) {
             $psObj = $this->xpdo->getObjectGraph('modPropertySet', '{"Elements":{}}', array('Elements.element' => $this->id, 'Elements.element_class' => $this->_class, 'modPropertySet.name' => $psName));
             if ($psObj) {
                 $propertySet = $this->xpdo->parser->parseProperties($psObj->get('properties'));
             }
         }
     }
     if (!empty($setName)) {
         $propertySetObj = $this->xpdo->getObjectGraph('modPropertySet', '{"Elements":{}}', array('Elements.element' => $this->id, 'Elements.element_class' => $this->_class, 'modPropertySet.name' => $setName));
         if ($propertySetObj) {
             if (is_array($propertySet)) {
                 $propertySet = array_merge($propertySet, $this->xpdo->parser->parseProperties($propertySetObj->get('properties')));
             } else {
                 $propertySet = $this->xpdo->parser->parseProperties($propertySetObj->get('properties'));
             }
         }
     }
     return $propertySet;
 }
开发者ID:OptimusCrime,项目名称:revolution,代码行数:54,代码来源:modelement.class.php

示例6: realname

 /**
  * Gets the real name of an element containing filter modifiers.
  *
  * @param string $unfiltered The unfiltered name of a {@link modElement}.
  * @return string The name minus any filter modifiers.
  */
 public function realname($unfiltered)
 {
     $filtered = $unfiltered;
     $split = xPDO::escSplit(':', $filtered);
     if ($split && isset($split[0])) {
         $filtered = $split[0];
         $propsetSplit = xPDO::escSplit('@', $filtered);
         if ($propsetSplit && isset($propsetSplit[0])) {
             $filtered = $propsetSplit[0];
         }
     }
     return $filtered;
 }
开发者ID:hanlray,项目名称:revolution,代码行数:19,代码来源:modparser.class.php

示例7: getTablesToJson

 public function getTablesToJson($baseClass = '', $tablePrefix = '', $restrictPrefix = false)
 {
     if (empty($baseClass)) {
         $baseClass = 'xPDOObject';
     }
     if (empty($tablePrefix)) {
         $tablePrefix = $this->manager->xpdo->config[xPDO::OPT_TABLE_PREFIX];
     }
     $jsonTables = array();
     //read list of tables
     $dbname = $this->databaseName;
     //$this->manager->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Database name: ' . $dbname);
     $tableLike = $tablePrefix && $restrictPrefix ? " LIKE '{$tablePrefix}%'" : '';
     $tablesStmt = $this->manager->xpdo->prepare("SHOW TABLES FROM {$dbname}{$tableLike}");
     $tablesStmt->execute();
     $tables = $tablesStmt->fetchAll(PDO::FETCH_NUM);
     if ($this->manager->xpdo->getDebug() === true) {
         $this->manager->xpdo->log(xPDO::LOG_LEVEL_DEBUG, print_r($tables, true));
     }
     foreach ($tables as $table) {
         $jsonFields = array();
         // the only thing added to this function the rest is copied:
         if (!in_array($table[0], $this->allowed_tables)) {
             //echo '<br>No Table: '.$table[0];
             //$this->manager->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'CMPGenerator->my_oPDO0->writeTableSchema -> No Table: '.$table[0]);
             continue;
         }
         //echo '<br>Table: '. $table[0];
         //$this->manager->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'CMPGenerator->my_oPDO0->writeTableSchema -> Table: '.$table[0].' - Pre: '.$tablePrefix.' - Restrict: '.$restrictPrefix );
         // End custom
         if (!($tableName = $this->getTableName($table[0], $tablePrefix, $restrictPrefix))) {
             continue;
         }
         $class = $this->getClassName($tableName);
         $extends = $baseClass;
         $sql = 'SHOW COLUMNS FROM ' . $this->manager->xpdo->escape($dbname) . '.' . $this->manager->xpdo->escape($table[0]);
         //$this->manager->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Line: '.__LINE__.' Sql: '.$sql);
         $fieldsStmt = $this->manager->xpdo->query($sql);
         if ($fieldsStmt) {
             $fields = $fieldsStmt->fetchAll(PDO::FETCH_ASSOC);
             if ($this->manager->xpdo->getDebug() === true) {
                 $this->manager->xpdo->log(xPDO::LOG_LEVEL_DEBUG, print_r($fields, true));
             }
             if (!empty($fields)) {
                 foreach ($fields as $field) {
                     $Field = '';
                     $Type = '';
                     $Null = '';
                     $Key = '';
                     $Default = '';
                     $Extra = '';
                     extract($field, EXTR_OVERWRITE);
                     $Type = xPDO::escSplit(' ', $Type, "'", 2);
                     $precisionPos = strpos($Type[0], '(');
                     $dbType = $precisionPos ? substr($Type[0], 0, $precisionPos) : $Type[0];
                     $dbType = strtolower($dbType);
                     $Precision = $precisionPos ? substr($Type[0], $precisionPos + 1, strrpos($Type[0], ')') - ($precisionPos + 1)) : '';
                     if (!empty($Precision)) {
                         $Precision = trim($Precision);
                     }
                     $attributes = '';
                     if (isset($Type[1]) && !empty($Type[1])) {
                         $attributes = trim($Type[1]);
                     }
                     $Null = ' null="' . ($Null === 'NO' ? 'false' : 'true') . '"';
                     $Key = $this->getIndex($Key);
                     $Default = $this->getDefault($Default);
                     $primaryKey = false;
                     if (!empty($Extra)) {
                         if ($Extra === 'auto_increment') {
                             $primaryKey = true;
                             if ($baseClass === 'xPDOObject' && $Field === 'id') {
                                 $extends = 'xPDOSimpleObject';
                                 //  continue;
                             } else {
                                 $Extra = ' generated="native"';
                             }
                         } else {
                             $Extra = ' extra="' . strtolower($Extra) . '"';
                         }
                         $Extra = ' ' . $Extra;
                     }
                     $type = !$Precision ? $dbType : $dbType . '(' . $Precision . ')';
                     $jsonFields[] = array('field' => $Field, 'type' => $type, 'key' => $primaryKey);
                 }
             } else {
                 $this->manager->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'No columns were found in table ' . $table[0]);
             }
         } else {
             $this->manager->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Error retrieving columns for table ' . $table[0]);
         }
         $jsonTables[$tableName] = $jsonFields;
     }
     if ($this->manager->xpdo->getDebug() === true) {
         $this->manager->xpdo->log(xPDO::LOG_LEVEL_DEBUG, print_r($jsonTables, 1));
     }
     return $jsonTables;
 }
开发者ID:Piterden,项目名称:modx_testfloor,代码行数:98,代码来源:my_xpdogenerator.class.php

示例8: testEscSplit

 /**
  * Test xPDO::escSplit
  */
 public function testEscSplit()
 {
     if (!empty(xPDOTestHarness::$debug)) {
         print "\n" . __METHOD__ . " = ";
     }
     $str = '1,2,3';
     $result = xPDO::escSplit(',', $str, $this->xpdo->_escapeCharOpen);
     $this->assertTrue(is_array($result), 'xPDO::escSplit did not return an array.');
     $this->assertEquals(3, count($result), 'xPDO::escSplit did not return the correct number of indices.');
 }
开发者ID:node-migrator-bot,项目名称:xpdo,代码行数:13,代码来源:xPDO.php

示例9: writeSchema

 /**
  * Write an XPDO XML Schema from your database.
  *
  * @param string $schemaFile The name (including path) of the schemaFile you
  * want to write.
  * @param string $package Name of the package to generate the classes in.
  * @param string $baseClass The class which all classes in the package will
  * extend; by default this is set to {@link xPDOObject} and any
  * auto_increment fields with the column name 'id' will extend {@link
  * xPDOSimpleObject} automatically.
  * @param string $tablePrefix The table prefix for the current connection,
  * which will be removed from all of the generated class and table names.
  * Specify a prefix when creating a new {@link xPDO} instance to recreate
  * the tables with the same prefix, but still use the generic class names.
  * @param boolean $restrictPrefix Only reverse-engineer tables that have the
  * specified tablePrefix; if tablePrefix is empty, this is ignored.
  * @return boolean True on success, false on failure.
  */
 public function writeSchema($schemaFile, $package = '', $baseClass = '', $tablePrefix = '', $restrictPrefix = false)
 {
     if (empty($package)) {
         $package = $this->manager->xpdo->package;
     }
     if (empty($baseClass)) {
         $baseClass = 'xPDOObject';
     }
     if (empty($tablePrefix)) {
         $tablePrefix = $this->manager->xpdo->config[xPDO::OPT_TABLE_PREFIX];
     }
     $xmlContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
     $xmlContent .= "<model package=\"{$package}\" baseClass=\"{$baseClass}\" platform=\"mysql\" defaultEngine=\"MyISAM\">\n";
     //read list of tables
     $dbname = $this->manager->xpdo->config['dbname'];
     $tableLike = $tablePrefix && $restrictPrefix ? " LIKE '{$tablePrefix}%'" : '';
     $tablesStmt = $this->manager->xpdo->prepare("SHOW TABLES FROM {$dbname}{$tableLike}");
     $tablesStmt->execute();
     $tables = $tablesStmt->fetchAll(PDO::FETCH_NUM);
     if ($this->manager->xpdo->getDebug() === true) {
         $this->manager->xpdo->log(xPDO::LOG_LEVEL_DEBUG, print_r($tables, true));
     }
     foreach ($tables as $table) {
         $xmlObject = '';
         $xmlFields = '';
         if (!($tableName = $this->getTableName($table[0], $tablePrefix, $restrictPrefix))) {
             continue;
         }
         $class = $this->getClassName($tableName);
         $extends = $baseClass;
         $fieldsStmt = $this->manager->xpdo->prepare("SHOW COLUMNS FROM `{$table[0]}`");
         $fieldsStmt->execute();
         $fields = $fieldsStmt->fetchAll(PDO::FETCH_ASSOC);
         if ($this->manager->xpdo->getDebug() === true) {
             $this->manager->xpdo->log(xPDO::LOG_LEVEL_DEBUG, print_r($fields, true));
         }
         foreach ($fields as $field) {
             $Field = '';
             $Type = '';
             $Null = '';
             $Key = '';
             $Default = '';
             $Extra = '';
             extract($field, EXTR_OVERWRITE);
             $Type = xPDO::escSplit(' ', $Type, "'", 2);
             $precisionPos = strpos($Type[0], '(');
             $dbType = $precisionPos ? substr($Type[0], 0, $precisionPos) : $Type[0];
             $dbType = strtolower($dbType);
             $Precision = $precisionPos ? substr($Type[0], $precisionPos + 1, strrpos($Type[0], ')') - ($precisionPos + 1)) : '';
             if (!empty($Precision)) {
                 $Precision = ' precision="' . trim($Precision) . '"';
             }
             $attributes = '';
             if (isset($Type[1]) && !empty($Type[1])) {
                 $attributes = ' attributes="' . trim($Type[1]) . '"';
             }
             $PhpType = $this->getPhpType($dbType);
             $Null = ' null="' . ($Null === 'NO' ? 'false' : 'true') . '"';
             $Key = $this->getIndex($Key);
             $Default = $this->getDefault($Default);
             if (!empty($Extra)) {
                 if ($Extra === 'auto_increment') {
                     if ($baseClass === 'xPDOObject' && $Field === 'id') {
                         $extends = 'xPDOSimpleObject';
                         continue;
                     } else {
                         $Extra = ' generated="native"';
                     }
                 } else {
                     $Extra = ' extra="' . strtolower($Extra) . '"';
                 }
                 $Extra = ' ' . $Extra;
             }
             $xmlFields .= "\t\t<field key=\"{$Field}\" dbtype=\"{$dbType}\"{$Precision}{$attributes} phptype=\"{$PhpType}\"{$Null}{$Default}{$Key}{$Extra} />\n";
             //                echo $xmlContent . "\n";
         }
         $xmlObject .= "\t<object class=\"{$class}\" table=\"{$tableName}\" extends=\"{$extends}\">\n";
         $xmlObject .= $xmlFields;
         $xmlObject .= "\t</object>\n";
         $xmlContent .= $xmlObject;
     }
     $xmlContent .= "</model>\n";
//.........这里部分代码省略.........
开发者ID:Kleist,项目名称:xPDO,代码行数:101,代码来源:xpdogenerator.class.php

示例10: findTags

 /**
  * @param string $content
  * @param array $tags
  */
 public function findTags($content, &$tags)
 {
     $parser = $this->modx->getParser();
     $collectedTags = array();
     $parser->collectElementTags($content, $collectedTags);
     foreach ($collectedTags as $tag) {
         $tagName = $tag[1];
         if (substr($tagName, 0, 1) == '!') {
             $tagName = substr($tagName, 1);
         }
         $token = substr($tagName, 0, 1);
         $tagParts = xPDO::escSplit('?', $tagName, '`', 2);
         $tagName = trim($tagParts[0]);
         $tagPropString = null;
         $tagName = trim($this->modx->stripTags($tagName));
         if (in_array($token, array('$', '+', '~', '#', '%', '-', '*'))) {
             $tagName = substr($tagName, 1);
         }
         switch ($token) {
             case '$':
                 $class = 'modChunk';
                 break;
             case '+':
             case '~':
             case '#':
             case '%':
             case '-':
             case '*':
                 continue 2;
                 break;
             default:
                 $class = 'modSnippet';
                 break;
         }
         if (isset($tagParts[1])) {
             $tagPropString = trim($tagParts[1]);
             $this->findTags($tagPropString, $tags);
             $element = $parser->getElement($class, $tagName);
             if ($element) {
                 $properties = $element->getProperties($tagPropString);
             } else {
                 $properties = array();
             }
         } else {
             $properties = array();
         }
         $this->debug('Found ' . $class . ' ' . $tagName . ' with properties ' . print_r($properties, 1));
         $tagName = $parser->realname($tagName);
         if (empty($tagName)) {
             continue;
         }
         $tags[$tagName] = array('name' => $tagName, 'class' => $class);
         foreach ($properties as $property) {
             $prop = trim($property);
             if (!empty($prop) && !is_numeric($prop) && is_string($prop)) {
                 $tags[$prop] = array('name' => $prop, 'class' => 'modChunk', 'isProperty' => true);
             }
         }
     }
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:64,代码来源:moddevtools.class.php

示例11: processTag

 public function processTag($tag, $processUncacheable = true)
 {
     $this->_processingTag = true;
     $element = null;
     $elementOutput = null;
     $outerTag = $tag[0];
     $innerTag = $tag[1];
     /* Avoid all processing for comment tags, e.g. [[- comments here]] */
     if (substr($innerTag, 0, 1) === '-') {
         return "";
     }
     /* collect any nested element tags in the innerTag and process them */
     $this->processElementTags($outerTag, $innerTag, $processUncacheable);
     $this->_processingTag = true;
     $outerTag = '[[' . $innerTag . ']]';
     $tagParts = xPDO::escSplit('?', $innerTag, '`', 2);
     $tagName = trim($tagParts[0]);
     $tagPropString = null;
     if (isset($tagParts[1])) {
         $tagPropString = trim($tagParts[1]);
     }
     $token = substr($tagName, 0, 1);
     $tokenOffset = 0;
     $cacheable = true;
     if ($token === '!') {
         if (!$processUncacheable) {
             $this->_processingTag = false;
             return $outerTag;
         }
         $cacheable = false;
         $tokenOffset++;
         $token = substr($tagName, $tokenOffset, 1);
     }
     if ($cacheable && $token !== '+') {
         $elementOutput = $this->loadFromCache($outerTag);
     }
     if ($elementOutput === null) {
         switch ($token) {
             case '+':
                 $tagName = substr($tagName, 1 + $tokenOffset);
                 $element = new modPlaceholderTag($this->modx);
                 $element->set('name', $tagName);
                 $element->setTag($outerTag);
                 $elementOutput = $element->process($tagPropString);
                 break;
             case '%':
                 $tagName = substr($tagName, 1 + $tokenOffset);
                 $element = new modLexiconTag($this->modx);
                 $element->set('name', $tagName);
                 $element->setTag($outerTag);
                 $element->setCacheable($cacheable);
                 $elementOutput = $element->process($tagPropString);
                 break;
             case '~':
                 // replace modLinkTag with ShopmodxLinkTag
                 $tagName = substr($tagName, 1 + $tokenOffset);
                 $element = new ShopmodxLinkTag($this->modx);
                 $element->set('name', $tagName);
                 $element->setTag($outerTag);
                 $element->setCacheable($cacheable);
                 $elementOutput = $element->process($tagPropString);
                 break;
             case '$':
                 $tagName = substr($tagName, 1 + $tokenOffset);
                 if ($element = $this->getElement('modChunk', $tagName)) {
                     $element->set('name', $tagName);
                     $element->setTag($outerTag);
                     $element->setCacheable($cacheable);
                     $elementOutput = $element->process($tagPropString);
                 }
                 break;
             case '*':
                 $tagName = substr($tagName, 1 + $tokenOffset);
                 $nextToken = substr($tagName, 0, 1);
                 if ($nextToken === '#') {
                     $tagName = substr($tagName, 1);
                 }
                 if (is_array($this->modx->resource->_fieldMeta) && in_array($this->realname($tagName), array_keys($this->modx->resource->_fieldMeta))) {
                     $element = new modFieldTag($this->modx);
                     $element->set('name', $tagName);
                     $element->setTag($outerTag);
                     $element->setCacheable($cacheable);
                     $elementOutput = $element->process($tagPropString);
                 } elseif ($element = $this->getElement('modTemplateVar', $tagName)) {
                     $element->set('name', $tagName);
                     $element->setTag($outerTag);
                     $element->setCacheable($cacheable);
                     $elementOutput = $element->process($tagPropString);
                 }
                 break;
             default:
                 $tagName = substr($tagName, $tokenOffset);
                 if ($element = $this->getElement('modSnippet', $tagName)) {
                     $element->set('name', $tagName);
                     $element->setTag($outerTag);
                     $element->setCacheable($cacheable);
                     $elementOutput = $element->process($tagPropString);
                 }
         }
     }
//.........这里部分代码省略.........
开发者ID:Tramp1357,项目名称:atlasorg,代码行数:101,代码来源:shopmodxparser.class.php


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