Example #1
0
 /**
  * Returns an array containing a flat list of names of all tags deployed in the social tier.
  *
  * @return array all tags deployed in the server. The returned array is a list of
  *         associative arrays with each associative array list item including information
  *         about each deployed tag
  */
 public function execute()
 {
     $_tagRegistry = Social_Dsl_TagRegistry::getInstance();
     $_metaInfoArray = $_tagRegistry->getAllTagMetaInfo();
     $_results = array();
     foreach ($_metaInfoArray as $_tagMetaInfo) {
         $_tagNamespace = $_tagMetaInfo->getTagNamespace();
         $_tagName = $_tagMetaInfo->getTagName();
         $_handlerClass = $_tagMetaInfo->getHandlerClassName();
         $_sourceFile = $_tagMetaInfo->getHandlerSourceFile();
         $_sourceFileLastModified = $_tagMetaInfo->getLastModified();
         // I don't think I care about the tidy metadata
         // $_tidyTagType = $_tagMetaInfo->getTagType();
         // $_tidyIsEmpty = $_tagMetaInfo->getIsEmpty();
         $_results[] = array('tag_namespace' => $_tagNamespace, 'tag_name' => $_tagName, 'handler_class' => $_handlerClass, 'source_file' => $_sourceFile, 'source_file_last_modified' => $_sourceFileLastModified);
     }
     return array('tag' => $_results);
 }
Example #2
0
 /**
  * Returns an array containing information on a tag.
  *
  * @return array info on a tag
  */
 public function execute()
 {
     $_tagRegistry = Social_Dsl_TagRegistry::getInstance();
     $_metaInfoArray = $_tagRegistry->getTagMetaInfo($this->tagNamespace, $this->tagName);
     $_info = array();
     if (!is_null($_metaInfoArray)) {
         $_tagNamespace = $_metaInfoArray->getTagNamespace();
         $_tagName = $_metaInfoArray->getTagName();
         $_handlerClass = $_metaInfoArray->getHandlerClassName();
         $_sourceFile = $_metaInfoArray->getHandlerSourceFile();
         $_sourceFileLastModified = $_metaInfoArray->getLastModified();
         // I don't think I care about the tidy metadata
         // $_tidyTagType = $_metaInfoArray->getTagType();
         // $_tidyIsEmpty = $_metaInfoArray->getIsEmpty();
         $_info['tag_namespace'] = $_tagNamespace;
         $_info['tag_name'] = $_tagName;
         $_info['handler_class'] = $_handlerClass;
         $_info['source_file'] = $_sourceFile;
         $_info['source_file_last_modified'] = $_sourceFileLastModified;
     }
     return array('tag' => $_info);
 }
Example #3
0
 public function testTidyConfig()
 {
     Social_Dsl_TagRegistry::removeCacheFile();
     $tagReg = Social_Dsl_TagRegistry::getInstance();
     $tidyConfig = $tagReg->getTidyConfiguration();
     $btags = explode(',', $tidyConfig['new-blocklevel-tags']);
     $this->assertTrue(count($btags) > 0);
     $this->assertTrue(in_array('fb:editor', $btags));
     $this->assertTrue(in_array('fb:if-is-app-user', $btags));
     $this->assertTrue(in_array('fb:editor-textarea', $btags));
     $this->assertTrue(in_array('fb:editor-text', $btags));
     $this->assertTrue(in_array('fb:message', $btags));
     $this->assertTrue(in_array('fb:success', $btags));
     $this->assertTrue(in_array('fb:dashboard', $btags));
     $this->assertTrue(in_array('fb:share-button', $btags));
     $this->assertTrue(in_array('fb:if-user-has-added-app', $btags));
     $this->assertTrue(in_array('fb:editor-buttonset', $btags));
     $this->assertTrue(in_array('fb:tabs', $btags));
     $this->assertTrue(in_array('fb:wide', $btags));
     $this->assertTrue(in_array('fb:comments', $btags));
     $this->assertTrue(in_array('fb:editor-custom', $btags));
     $this->assertTrue(in_array('fb:editor-button', $btags));
     $this->assertTrue(in_array('fb:action', $btags));
     $this->assertTrue(in_array('fb:mobile', $btags));
     $this->assertTrue(in_array('fb:editor-checkbox', $btags));
     $this->assertTrue(in_array('fb:if-can-see', $btags));
     $this->assertTrue(in_array('fb:error', $btags));
     $this->assertTrue(in_array('fb:explanation', $btags));
     $this->assertTrue(in_array('fb:editor-cancel', $btags));
     $this->assertTrue(in_array('fb:narrow', $btags));
     $this->assertTrue(in_array('fb:tab-item', $btags));
     $this->assertTrue(in_array('fb:else', $btags));
     $this->assertTrue(in_array('fb:multi-friend-selector', $btags));
     $this->assertTrue(in_array('fb:header', $btags));
     $this->assertTrue(in_array('fb:js-string', $btags));
     $this->assertTrue(in_array('fb:request-form', $btags));
     $this->assertTrue(in_array('rs:link', $btags));
     $this->assertTrue(in_array('rs:social-dsl', $btags));
     $this->assertTrue(in_array('rs:if-has-paid', $btags));
     $this->assertTrue(in_array('rs:flavor', $btags));
     $this->assertTrue(in_array('rs:payment-form', $btags));
     $this->assertTrue(in_array('rs:script', $btags));
     $this->assertTrue(in_array('rs:style', $btags));
     $itags = explode(',', $tidyConfig['new-inline-tags']);
     $this->assertTrue(count($itags) > 0);
     $this->assertTrue(in_array('fb:create-button', $itags));
     $this->assertTrue(in_array('fb:redirect', $itags));
     $this->assertTrue(in_array('fb:action', $itags));
     $this->assertTrue(in_array('fb:request-form-submit', $itags));
     $this->assertTrue(in_array('fb:profile-pic', $itags));
     $this->assertTrue(in_array('fb:name', $itags));
     $this->assertTrue(in_array('fb:help', $itags));
     $this->assertTrue(in_array('fb:userlink', $itags));
     $this->assertTrue(in_array('fb:title', $itags));
     $this->assertTrue(in_array('fb:google-analytics', $itags));
     $this->assertTrue(in_array('fb:user', $itags));
     $this->assertTrue(in_array('fb:profile-action', $itags));
     $this->assertTrue(in_array('fb:time', $itags));
     $this->assertTrue(in_array('fb:iframe', $itags));
     $this->assertTrue(in_array('rs:feed', $itags));
     $this->assertTrue(in_array('rs:authorize', $itags));
     $this->assertTrue(in_array('rs:link', $itags));
     $this->assertTrue(in_array('rs:payment-plans', $itags));
     $this->assertTrue(in_array('rs:meta', $itags));
     $this->assertTrue(in_array('xy:awesome-tag', $itags));
     $this->assertTrue(in_array('ab:another-tag', $itags));
     $this->assertTrue(!in_array('NULL:br', $itags));
     $etags = explode(',', $tidyConfig['new-empty-tags']);
     $this->assertTrue(count($etags) > 0);
     $this->assertTrue(in_array('fb:redirect', $etags));
     $this->assertTrue(in_array('fb:editor-button', $etags));
     $this->assertTrue(in_array('fb:friend-selector', $etags));
     $this->assertTrue(in_array('fb:profile-pic', $etags));
     $this->assertTrue(in_array('fb:name', $etags));
     $this->assertTrue(in_array('fb:editor-cancel', $etags));
     $this->assertTrue(in_array('fb:time', $etags));
     $this->assertTrue(in_array('fb:iframe', $etags));
     $this->assertTrue(in_array('rs:feed', $etags));
     $this->assertTrue(in_array('rs:authorize', $etags));
     $this->assertTrue(in_array('rs:payment-plans', $etags));
 }
Example #4
0
 * 
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 ******************************************************************************/
include_once 'utils.php';
include_once 'ringside/social/dsl/TagRegistry.php';
/**
 * Drop the SCHEMA from the database server. 
 * 
 * @author Richard Friedman
 */
writeDatabaseInformation();
writeLine("<b>Is your schema ready to be dropped!</b>");
dropSchema();
Social_Dsl_TagRegistry::removeCacheFile();
writeLine();
writeLine("<u>Other options</u>");
writeLink("index.php", "Start setup process.");
writeLink("drop.php", "Drop Schema, Start Again");
 /**
  * There are a few types of tags to consider
  * NO CHILDREN
  * CHILDREN unrelated to Parent
  * CHILDREN need parent
  * PARENT need children
  * PARENT with if/else
  * PARENT with loop
  *
  * @param TidyNode $node
  * @param Handler $parentHandler
  */
 function walk_nodes($node, &$parentHandler = null)
 {
     $flavorNodeName = $node->type == TIDY_NODETYPE_TEXT ? '#text' : $node->name;
     $tagNamespace = NULL;
     $tagName = NULL;
     $narr = explode(':', $node->name);
     if (count($narr) > 1) {
         $tagNamespace = $narr[0];
         $tagName = $narr[1];
     } else {
         if (count($narr) > 0) {
             $tagName = $narr[0];
         }
     }
     $tagRegistry = Social_Dsl_TagRegistry::getInstance();
     //HTML elements will have $tagNamespace == NULL, if a handler is
     //present and loaded it will still have tag meta info.
     $tagMetaInfo = $tagRegistry->getTagMetaInfo($tagNamespace, $tagName);
     $tagHasHandler = $tagMetaInfo != NULL;
     $tagIsValidForFlavor = $tagRegistry->isValidForFlavor($flavorNodeName, $this->application->getFlavorContext()->getFlavor());
     //error_log("[parser] name='$tagName', ns='$tagNamespace' flavorName='$flavorNodeName', hasHandler=" . ($tagHasHandler ? 'true' : 'false') . " isValid=" . ($tagIsValidForFlavor ? 'true' : 'false'));
     if ($tagNamespace != NULL && !$tagHasHandler && $tagName != 'script' && $tagName != 'style') {
         //just keeping this warning here until we're sure TagRegistry changes
         //don't break anything...
         error_log("[RingsideSocialDslParser] no handler found for {$tagNamespace}:{$tagName}!");
     }
     if (!empty($node->name) && $tagHasHandler && $tagIsValidForFlavor) {
         $handler = $tagMetaInfo->createTagHandlerInstance();
         $body = $handler->doStartTag($this->application, $parentHandler, $node->attribute);
         if ($body === true) {
             // returning true says call each child then call my doEndTag
             if ($node->hasChildren()) {
                 foreach ($node->child as $child) {
                     $this->walk_nodes($child, $handler);
                 }
             }
             $body = $handler->doEndTag($this->application, $parentHandler, $node->attribute);
         } else {
             if ($body === false) {
                 // return false says don't process me
             } else {
                 if (is_array($body)) {
                     // returning an array says ONLY process these tags.
                     if ($node->hasChildren()) {
                         foreach ($node->child as $child) {
                             if (in_array($child->name, $body)) {
                                 $this->walk_nodes($child, $handler);
                             }
                         }
                     }
                     $body = $handler->doEndTag($this->application, $parentHandler, $node->attribute);
                 } else {
                     if ($body == 'body') {
                         // returning the text body says collect the body text and call the doBody handler with the text passed in
                         $bodyValue = '';
                         if ($node->hasChildren()) {
                             foreach ($node->child as $child) {
                                 $value = $child->value;
                                 if ($value[strlen($value) - 1] == "\r") {
                                     // Trim right-hand carriage return on Windows
                                     $value = substr($value, 0, strlen($value) - 1);
                                 }
                                 $bodyValue .= $value;
                             }
                         }
                         $handler->doBody($this->application, $parentHandler, $node->attribute, $bodyValue);
                         $handler->doEndTag($this->application, $parentHandler, $node->attribute);
                     } else {
                         if ($body == 'print') {
                             // return 'print' and we print the begin tag, then walk the children, then print end tag.
                             $this->printNode($node);
                         } else {
                             if ($body == 'redirect') {
                                 // tell the caller we got a redirect
                                 $this->redirect = $handler->doBody($this->application, $parentHandler, $node->attribute, '');
                             } else {
                                 if ($body == 'mixed') {
                                     $bodyValue = '';
                                     if ($node->hasChildren()) {
                                         foreach ($node->child as $child) {
                                             $tagName = $child->name;
                                             if (strlen(trim($tagName)) > 0 && $tagRegistry->hasHandler($tagName)) {
                                                 //parse inline tag, append to body
                                                 ob_start();
                                                 $this->walk_nodes($child, $handler);
                                                 $bodyValue .= ob_get_contents();
                                                 ob_end_clean();
                                             } else {
                                                 //append text to string
                                                 $bodyValue .= $child->value;
                                             }
                                         }
                                     }
                                     $result = $handler->doBody($this->application, $parentHandler, $node->attribute, $bodyValue);
                                     $body = $handler->doEndTag($this->application, $parentHandler, $node->attribute);
                                 } else {
                                     // return a comma separate list of tags and we pre-process those tags
                                     // and then call doBody on parent walk other nodes call doEndTag on parent.
                                     // the do Body will also contain as text all nodes raw text that were not in the list.
                                     $preTags = explode(",", $body);
                                     $bodyValue = '';
                                     if ($node->hasChildren()) {
                                         foreach ($node->child as $child) {
                                             if (in_array($child->name, $preTags)) {
                                                 $this->walk_nodes($child, $handler);
                                             } else {
                                                 $value = $child->value;
                                                 if ($value[strlen($value) - 1] == "\r") {
                                                     $value = substr($value, 0, strlen($value) - 1);
                                                 }
                                                 $bodyValue .= $value;
                                             }
                                         }
                                     }
                                     $result = $handler->doBody($this->application, $parentHandler, $node->attribute, $bodyValue);
                                     if ($result !== true) {
                                         if ($node->hasChildren()) {
                                             foreach ($node->child as $child) {
                                                 if (!in_array($child->name, $preTags)) {
                                                     $this->walk_nodes($child, $handler);
                                                 }
                                             }
                                         }
                                     }
                                     $body = $handler->doEndTag($this->application, $parentHandler, $node->attribute);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         $old_do_output = $this->application->getFlavorContext()->doOutput();
         if (!$tagIsValidForFlavor) {
             $this->application->getFlavorContext()->setOutput(false);
         }
         $this->printNode($node);
         if (!$tagIsValidForFlavor) {
             $this->application->getFlavorContext()->setOutput($old_do_output);
         }
     }
 }
Example #6
0
 /**
  * Initialize the singleton instance
  */
 protected static function initInstance()
 {
     include 'LocalSettings.php';
     if (!isset($cacheTags) || empty($cacheTags)) {
         $cacheTags = false;
     }
     if (!isset($scanTags) || empty($scanTags)) {
         $scanTags = false;
     }
     //construct object instance
     self::$m_instance = new Social_Dsl_TagRegistry($cacheTags, $scanTags);
 }