Beispiel #1
0
 /**
  * @method POST
  */
 function get()
 {
     // get an authuser
     $authUser = new AuthUser();
     if (isset($authUser->UserUniqId)) {
         // check if authorized
         $pageTypeId = -1;
         parse_str($this->request->data, $request);
         // parse request
         if (isset($request['pageTypeId'])) {
             $pageTypeId = $request['pageTypeId'];
         }
         if (isset($request['friendlyId'])) {
             $friendlyId = $request['friendlyId'];
             $pageType = PageType::GetByFriendlyId($friendlyId, $authUser->SiteId);
             // look up id
             $pageTypeId = $pageType['PageTypeId'];
         }
         if (isset($request['pageTypeUniqId'])) {
             $pageType = PageType::GetByPageTypeUniqId($request['pageTypeUniqId']);
             // look up id
             $pageTypeId = $pageType['PageTypeId'];
         }
         // check that pageTypeId was set
         if ($pageTypeId != -1) {
             $list = Category::GetCategories($pageTypeId);
             // return a json response
             $response = new Tonic\Response(Tonic\Response::OK);
             $response->contentType = 'application/json';
             $response->body = json_encode($list);
             return $response;
         } else {
             // return an empty response (e.g. root has not categories)
             $response = new Tonic\Response(Tonic\Response::OK);
             $response->contentType = 'application/json';
             $response->body = '[]';
             return $response;
         }
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
Beispiel #2
0
 /**
  * @method POST
  */
 function post()
 {
     parse_str($this->request->data, $request);
     // parse request
     $friendlyId = $request['friendlyId'];
     $name = $request['name'];
     $s_passcode = $request['passcode'];
     $timeZone = $request['timeZone'];
     $email = '';
     $password = '';
     $language = 'en-us';
     // language for the app
     $userId = -1;
     $theme = DEFAULT_THEME;
     // set theme
     if (isset($request['theme'])) {
         $theme = $request['theme'];
     }
     // set language if set
     if (isset($request['language'])) {
         $language = $request['language'];
     }
     // check for email and password
     if (isset($request['email'])) {
         $userLanguage = 'en-us';
         if (isset($request['userLanguage'])) {
             $userLanguage = $request['userLanguage'];
         }
         $email = $request['email'];
         $password = $request['password'];
     } else {
         // get an authuser
         $authUser = new AuthUser();
         if ($authUser->UserUniqId && $authUser->IsSuperAdmin == true) {
             // check if authorized
             $userId = $authUser->UserId;
         } else {
             return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
         }
     }
     // defaults
     $firstName = 'New';
     $lastName = 'User';
     $domain = APP_URL . '/sites/' . $friendlyId;
     $domain = str_replace('http://', '', $domain);
     $logoUrl = 'sample-logo.png';
     if ($s_passcode == PASSCODE) {
         // check for uniqueness of email
         if ($email != '') {
             $isUserUnique = User::IsLoginUnique($email);
             if ($isUserUnique == false) {
                 return new Tonic\Response(Tonic\Response::CONFLICT);
             }
         }
         $isFriendlyIdUnique = Site::IsFriendlyIdUnique($friendlyId);
         if ($isFriendlyIdUnique == false) {
             return new Tonic\Response(Tonic\Response::CONFLICT);
         }
         // add the site
         $site = Site::Add($domain, $name, $friendlyId, $logoUrl, $theme, $email, $timeZone, $language);
         // add the site
         // add the admin
         if ($email != '') {
             $isActive = 1;
             // admins by default are active
             $user = User::Add($email, $password, $firstName, $lastName, 'Admin', $userLanguage, $isActive, $site['SiteId']);
             $userId = $user['UserId'];
         }
         // set the stripe plan, customer id, status
         if (DEFAULT_STRIPE_PLAN != '') {
             Stripe::setApiKey(STRIPE_API_KEY);
             $customer = Stripe_Customer::create(array("plan" => DEFAULT_STRIPE_PLAN, "email" => $email));
             $customerId = $customer->id;
             Site::EditCustomer($site['SiteUniqId'], $customerId);
         }
         // read the defaults file
         $default_json_file = '../themes/' . $theme . '/default.json';
         // set $siteId
         $siteId = $site['SiteId'];
         // check to make sure the defaults.json exists
         if (file_exists($default_json_file)) {
             // get json from the file
             $json_text = file_get_contents($default_json_file);
             // decode json
             $json = json_decode($json_text, true);
             // pagetypes
             $pagetypes = array();
             // menu counts
             $primaryMenuCount = 0;
             $footerMenuCount = 0;
             // walk through defaults array
             foreach ($json as &$value) {
                 // get values from array
                 $url = $value['url'];
                 $source = $value['source'];
                 $name = $value['name'];
                 $description = $value['description'];
                 $layout = $value['layout'];
                 $stylesheet = $value['stylesheet'];
                 $primaryMenu = $value['primaryMenu'];
                 $footerMenu = $value['footerMenu'];
                 if (strpos($url, '/') !== false) {
                     // the url has a pagetype
                     $arr = explode('/', $url);
                     // get friendly ids from $url
                     $pageTypeFriendlyId = $arr[0];
                     $pageFriendlyId = $arr[1];
                     $pageTypeId = -1;
                     $pageType = PageType::GetByFriendlyId($pageTypeFriendlyId, $siteId);
                     // create a new pagetype
                     if ($pageType == NULL) {
                         $pageType = PageType::Add($pageTypeFriendlyId, 'Page', 'Pages', $layout, $stylesheet, 0, $siteId, $userId, $userId);
                     }
                     // get newly minted page type
                     $pageTypeId = $pageType['PageTypeId'];
                 } else {
                     // root, no pagetype
                     $pageFriendlyId = $url;
                     $pageTypeId = -1;
                 }
                 // create a page
                 $page = Page::Add($pageFriendlyId, $name, $description, $layout, $stylesheet, $pageTypeId, $site['SiteId'], $userId);
                 // set the page to active
                 Page::SetIsActive($page['PageUniqId'], 1);
                 // build the content file
                 $filename = '../themes/' . $theme . '/' . $source;
                 $content = '';
                 // get the content for the page
                 if (file_exists($filename)) {
                     $content = file_get_contents($filename);
                     // fix images
                     $content = str_replace('{{site-dir}}', 'sites/' . $site['FriendlyId'], $content);
                 }
                 // publish the fragment
                 Publish::PublishFragment($site['FriendlyId'], $page['PageUniqId'], 'publish', $content);
                 // build the primary menu
                 if ($primaryMenu == true) {
                     MenuItem::Add($name, '', 'primary', $url, $page['PageId'], $primaryMenuCount, $site['SiteId'], $userId, $userId);
                     $primaryMenuCount++;
                 }
                 // build the footer menu
                 if ($footerMenu == true) {
                     MenuItem::Add($name, '', 'footer', $url, $page['PageId'], $footerMenuCount, $site['SiteId'], $userId, $userId);
                     $footerMenuCount++;
                 }
             }
         } else {
             return new Tonic\Response(Tonic\Response::BADREQUEST);
         }
         // publishes a theme for a site
         Publish::PublishTheme($site, $theme);
         // publish the site
         Publish::PublishSite($site['SiteUniqId']);
         // send welcome email
         if (SEND_WELCOME_EMAIL == true && $email != '') {
             $to = $email;
             $from = REPLY_TO;
             $fromName = REPLY_TO_NAME;
             $subject = BRAND . ': Welcome to ' . BRAND;
             $file = 'emails/new-user.html';
             // create strings to replace
             $loginUrl = APP_URL;
             $newSiteUrl = APP_URL . '/sites/' . $site['FriendlyId'];
             $replace = array('{{brand}}' => BRAND, '{{reply-to}}' => REPLY_TO, '{{new-site-url}}' => $newSiteUrl, '{{login-url}}' => $loginUrl);
             // send email from file
             Utilities::SendEmailFromFile($to, $from, $fromName, $subject, $replace, $file);
         }
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
Beispiel #3
0
 public static function PublishDefaultContent($site, $theme, $userId)
 {
     // read the defaults file
     $default_json_file = APP_LOCATION . THEMES_FOLDER . '/' . $theme . '/default.json';
     // set $siteId
     $siteId = $site['SiteId'];
     // check to make sure the defaults.json exists
     if (file_exists($default_json_file)) {
         // get json from the file
         $json_text = file_get_contents($default_json_file);
         // decode json
         $json = json_decode($json_text, true);
         // pagetypes
         $pagetypes = array();
         // menu counts
         $primaryMenuCount = 0;
         $footerMenuCount = 0;
         // clear default types
         MenuItem::RemoveForType('primary', $siteId);
         MenuItem::RemoveForType('footer', $siteId);
         // walk through defaults array
         foreach ($json as &$value) {
             // get values from array
             $url = $value['url'];
             $source = $value['source'];
             $name = $value['name'];
             $description = $value['description'];
             $layout = $value['layout'];
             $stylesheet = $value['stylesheet'];
             $primaryMenu = $value['primaryMenu'];
             $footerMenu = $value['footerMenu'];
             $includeOnly = 0;
             // set includeOnly (if specified in default)
             if (isset($value['includeOnly'])) {
                 if ($value['includeOnly'] == true) {
                     $includeOnly = 1;
                 }
             }
             // initialize PT
             $pageType = NULL;
             if (strpos($url, '/') !== false) {
                 // the url has a pagetype
                 $arr = explode('/', $url);
                 // get friendly ids from $url
                 $pageTypeFriendlyId = $arr[0];
                 $pageFriendlyId = $arr[1];
                 $pageTypeId = -1;
                 $pageType = PageType::GetByFriendlyId($pageTypeFriendlyId, $siteId);
                 // create a new pagetype
                 if ($pageType == NULL) {
                     $pageType = PageType::Add($pageTypeFriendlyId, $layout, $stylesheet, 0, $siteId, $userId);
                 }
                 // get newly minted page type
                 $pageTypeId = $pageType['PageTypeId'];
             } else {
                 // root, no pagetype
                 $pageFriendlyId = $url;
                 $pageTypeId = -1;
             }
             // determine if page is unique
             $isUnique = Page::IsFriendlyIdUnique($pageFriendlyId, $pageTypeId, $site['SiteId']);
             // initialize page
             $page = NULL;
             // if page has not been created, create a page
             if ($isUnique == true) {
                 // create a page
                 $page = Page::Add($pageFriendlyId, $name, $description, $layout, $stylesheet, $pageTypeId, $site['SiteId'], $userId);
             } else {
                 // get the page
                 $page = Page::GetByFriendlyId($pageFriendlyId, $pageTypeId, $site['SiteId']);
             }
             // quick check
             if ($page != NULL) {
                 // set the page to active
                 Page::SetIsActive($page['PageId'], 1);
                 // set include only
                 Page::SetIncludeOnly($page['PageId'], $includeOnly);
                 // build the content file
                 $filename = APP_LOCATION . THEMES_FOLDER . '/' . $theme . '/' . $source;
                 $content = '';
                 // get the content for the page
                 if (file_exists($filename)) {
                     $content = file_get_contents($filename);
                     // fix images
                     $content = str_replace('{{site-dir}}', $site['Domain'], $content);
                 }
                 // edit the page content
                 Page::EditContent($page['PageId'], $content, $userId);
                 // build the primary menu
                 if ($primaryMenu == true) {
                     MenuItem::Add($name, '', 'primary', $url, $page['PageId'], $primaryMenuCount, $site['SiteId'], $userId);
                     $primaryMenuCount++;
                 }
                 // build the footer menu
                 if ($footerMenu == true) {
                     MenuItem::Add($name, '', 'footer', $url, $page['PageId'], $footerMenuCount, $site['SiteId'], $userId);
                     $footerMenuCount++;
                 }
             }
         }
     }
 }
Beispiel #4
0
 public static function GetByUrl($url, $siteId)
 {
     if (strpos($url, '/') !== false) {
         // get by
         $arr = explode('/', $url);
         $pageTypeFriendlyId = $arr[0];
         $pageFriendlyId = $arr[1];
         $pageType = PageType::GetByFriendlyId($pageTypeFriendlyId, $siteId);
         $page = Page::GetByFriendlyId($pageFriendlyId, $pageType['PageTypeId'], $siteId);
         return $page;
     } else {
         $pageFriendlyId = $url;
         $page = Page::GetByFriendlyId($pageFriendlyId, -1, $siteId);
         return $page;
     }
 }
Beispiel #5
0
 /**
  * @method POST
  */
 function post()
 {
     parse_str($this->request->data, $request);
     // parse request
     $siteId = $request['siteId'];
     $friendlyId = $request['type'];
     // get pagetype
     $pageType = PageType::GetByFriendlyId($friendlyId, $siteId);
     // get a count
     $count = Page::GetPagesCount($siteId, $pageType['PageTypeId'], true);
     // return a json response
     $response = new Tonic\Response(Tonic\Response::OK);
     $response->contentType = 'applicaton/json';
     $response->body = '{"count":' . $count . '}';
     return $response;
     return new Tonic\Response(Tonic\Response::CREATED);
 }
Beispiel #6
0
 /**
  * @method GET
  */
 function get($friendlyId)
 {
     // get an authuser
     $authUser = new AuthUser();
     if (isset($authUser->UserUniqId)) {
         // check if authorized
         $siteId = $authUser->SiteId;
         $pageSize = 100;
         $orderBy = 'Created DESC';
         $page = 0;
         $pageTypeId = -1;
         $dir = '/';
         if ($friendlyId != 'root') {
             // get pagetype
             $pageType = PageType::GetByFriendlyId($friendlyId, $siteId);
             $pageTypeId = $pageType['PageTypeId'];
             $dir = strtolower($pageType['TypeS']) . '/';
         }
         // get site url
         $site = Site::GetBySiteId($authUser->SiteId);
         $dir = 'sites/' . $site['FriendlyId'] . '/files/';
         // get pages
         $list = Page::GetPages($siteId, $pageTypeId, $pageSize, $page, $orderBy);
         $pages = array();
         foreach ($list as $row) {
             $page = Page::GetByPageId($row['PageId']);
             $fullName = $row['FirstName'] . ' ' . $row['LastName'];
             $page['LastModifiedFullName'] = $fullName;
             $thumbUrl = '';
             if ($page['Image'] != '') {
                 if (strpos($page['Image'], 't-') !== false) {
                     $thumbUrl = $dir . $page['Image'];
                 } else {
                     $thumbUrl = $dir . 't-' . $page['Image'];
                 }
             }
             // set thumb
             $page['Thumb'] = $thumbUrl;
             $url = $page['FriendlyId'];
             if ($page['PageTypeId'] != -1) {
                 $pageType = PageType::GetByPageTypeId($page['PageTypeId']);
                 $url = strtolower($pageType['TypeS']) . '/' . $page['FriendlyId'];
             }
             // set url
             $page['Url'] = $url;
             // permissions are not applicable to this API call
             $page['CanEdit'] = '';
             $page['CanPublish'] = '';
             $page['CanRemove'] = '';
             $pages[$row['PageUniqId']] = $page;
         }
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         $response->contentType = 'application/json';
         $response->body = json_encode($pages);
         return $response;
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
Beispiel #7
0
 public static function ParseHTML($site, $page, $content, $preview, $root = '../')
 {
     $html = str_get_html($content, true, true, DEFAULT_TARGET_CHARSET, false, DEFAULT_BR_TEXT);
     $mapcount = 0;
     $pageId = $page['PageId'];
     $rootloc = '';
     $commonloc = '../common/';
     // set page url
     $pageurl = 'http://' . $site['Domain'];
     if ($page['PageTypeId'] != -1) {
         $pageType = PageType::GetByPageTypeId($page['PageTypeId']);
         $pageurl .= '/' . $pageType['FriendlyId'] . '/' . $page['FriendlyId'];
     } else {
         $pageurl .= '/' . $page['FriendlyId'];
     }
     // set root and common locations
     if ($page['PageTypeId'] != -1 || $preview == true) {
         $rootloc = '../';
         $commonloc = '../../common/';
     }
     $css = $rootloc . 'css/' . $page['Stylesheet'] . '.css';
     if ($html == null) {
         return '';
     }
     // setup gettext blockquote, h1, h2, h3, p, td, th, li, meta tags for multi-lingual support
     foreach ($html->find('#content blockquote') as $el) {
         $el->innertext = Utilities::GenerateGettext($el->innertext);
     }
     foreach ($html->find('#content h1') as $el) {
         $el->innertext = Utilities::GenerateGettext($el->innertext);
     }
     foreach ($html->find('#content h2') as $el) {
         $el->innertext = Utilities::GenerateGettext($el->innertext);
     }
     foreach ($html->find('#content h3') as $el) {
         $el->innertext = Utilities::GenerateGettext($el->innertext);
     }
     foreach ($html->find('#content p') as $el) {
         $el->innertext = Utilities::GenerateGettext($el->innertext);
     }
     foreach ($html->find('#content td') as $el) {
         $el->innertext = Utilities::GenerateGettext($el->innertext);
     }
     foreach ($html->find('#content th') as $el) {
         $el->innertext = Utilities::GenerateGettext($el->innertext);
     }
     foreach ($html->find('#content li') as $el) {
         $el->innertext = Utilities::GenerateGettext($el->innertext);
     }
     foreach ($html->find('meta[name=description]') as $el) {
         $content = $el->content;
         $el->content = Utilities::GenerateGettext($content);
     }
     foreach ($html->find('meta[name=keywords]') as $el) {
         $content = $el->content;
         $el->content = Utilities::GenerateGettext($content);
     }
     foreach ($html->find('meta[name=callout]') as $el) {
         $content = $el->content;
         $el->content = Utilities::GenerateGettext($content);
     }
     // parse module
     foreach ($html->find('module') as $el) {
         if (isset($el->name)) {
             $name = $el->name;
             if ($name == 'styles') {
                 $el->outertext = '<link href="' . $css . '" type="text/css" rel="stylesheet" media="screen">' . '<link href="' . BOOTSTRAP_CSS . '" rel="stylesheet">' . '<link href="' . FONTAWESOME_CSS . '" rel="stylesheet">' . '<link href="' . $rootloc . 'css/prettify.css" type="text/css" rel="stylesheet" media="screen">';
             } else {
                 if ($name == 'header') {
                     ob_start();
                     include $root . 'sites/common/modules/header.php';
                     // loads the module
                     $content = ob_get_contents();
                     // holds the content
                     ob_end_clean();
                     $el->outertext = $content;
                 } else {
                     if ($name == 'scripts') {
                         ob_start();
                         include $root . 'sites/common/modules/scripts.php';
                         // loads the module
                         $content = ob_get_contents();
                         // holds the content
                         ob_end_clean();
                         $el->outertext = $content;
                     } else {
                         if ($name == 'analytics') {
                             ob_start();
                             $webpropertyid = $site['AnalyticsId'];
                             include $root . 'sites/common/modules/analytics.php';
                             // loads the module
                             $content = ob_get_contents();
                             // holds the content
                             ob_end_clean();
                             $el->outertext = $content;
                         } else {
                             if ($name == 'rss') {
                                 ob_start();
                                 include $root . 'sites/common/modules/rss.php';
                                 // loads the module
                                 $content = ob_get_contents();
                                 // holds the content
                                 ob_end_clean();
                                 $el->outertext = $content;
                             } else {
                                 if ($name == 'list') {
                                     $pageTypeUniqId = '';
                                     if (isset($el->type)) {
                                         $pageTypeUniqId = $el->type;
                                     }
                                     // translate a friendlyId to a pageTypeUniqId
                                     if (isset($el->pagetype)) {
                                         $friendlyId = $el->pagetype;
                                         $pageType = PageType::GetByFriendlyId($friendlyId, $site['SiteId']);
                                         $pageTypeUniqId = $pageType['PageTypeUniqId'];
                                     }
                                     if ($pageTypeUniqId != '') {
                                         $label = $el->label;
                                         $isAjax = false;
                                         $pageNo = 1;
                                         $curr = 0;
                                         $listid = $el->id;
                                         $display = $el->display;
                                         $desclength = $el->desclength;
                                         $length = $el->length;
                                         $orderby = $el->orderby;
                                         $category = $el->category;
                                         $pageresults = $el->pageresults;
                                         if ($el->display == 'blog') {
                                             $list = '';
                                             ob_start();
                                             include $root . 'sites/common/modules/list-blog.php';
                                             // loads the module
                                             $list = ob_get_contents();
                                             // get content from module
                                             ob_end_clean();
                                         } else {
                                             if ($el->display == 'list') {
                                                 $list = '';
                                                 ob_start();
                                                 include $root . 'sites/common/modules/list.php';
                                                 // loads the module
                                                 $list = ob_get_contents();
                                                 // get content from module
                                                 ob_end_clean();
                                             } else {
                                                 if ($el->display == 'thumbnails') {
                                                     $list = '';
                                                     ob_start();
                                                     include $root . 'sites/common/modules/list-thumbnails.php';
                                                     // loads the module
                                                     $list = ob_get_contents();
                                                     // get content from module
                                                     ob_end_clean();
                                                 } else {
                                                     if ($el->display == 'calendar') {
                                                         $list = '';
                                                         ob_start();
                                                         include $root . 'sites/common/modules/list-calendar.php';
                                                         // loads the module
                                                         $list = ob_get_contents();
                                                         // get content from module
                                                         ob_end_clean();
                                                     } else {
                                                         if ($el->display == 'map') {
                                                             $list = '';
                                                             $id = 'map-' + $mapcount;
                                                             $cssClass = '';
                                                             $zoom = 'auto';
                                                             ob_start();
                                                             include $root . 'sites/common/modules/list-map.php';
                                                             // loads the module
                                                             $list = ob_get_contents();
                                                             // get content from module
                                                             ob_end_clean();
                                                             $mapcount++;
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         $el->outertext = $list;
                                     }
                                 } else {
                                     if ($name == 'featured') {
                                         $id = $el->id;
                                         $pageName = $el->pagename;
                                         $pageUniqId = '';
                                         if (isset($el->pageuniqid)) {
                                             $pageUniqId = $el->pageuniqid;
                                         }
                                         // translate a friendlyId to a pageTypeUniqId
                                         if (isset($el->url)) {
                                             $url = $el->url;
                                             $page = Page::GetByUrl($url, $site['SiteId']);
                                             $pageUniqId = $page['PageUniqId'];
                                         }
                                         $featured = '<div id="' . $id . '" data-pageuniqid="' . $pageUniqId . '" data-pagename="' . $pageName . '" class="featured-content">' . '<p class="featured-loading"><i class="fa fa-spinner fa-spin"></i> <?php print _("Loading..."); ?></p>' . '</div>';
                                         $el->outertext = $featured;
                                     } else {
                                         if ($name == 'secure') {
                                             if (isset($el->type)) {
                                                 $type = $el->type;
                                             } else {
                                                 $type = 'login';
                                             }
                                             $el->outertext = '<?php include "' . $commonloc . 'modules/' . $type . '.php"; ?>';
                                         } else {
                                             if ($name == 'menu') {
                                                 if (isset($el->type)) {
                                                     $type = $el->type;
                                                 } else {
                                                     $type = 'primary';
                                                 }
                                                 $el->outertext = '<?php $type="' . $type . '"; include "' . $commonloc . 'modules/menu.php"; ?>';
                                             } else {
                                                 if ($name == 'footer') {
                                                     ob_start();
                                                     $copy = $el->innertext;
                                                     include $root . 'sites/common/modules/footer.php';
                                                     // loads the module
                                                     $content = ob_get_contents();
                                                     // holds the content
                                                     ob_end_clean();
                                                     $el->outertext = $content;
                                                 } else {
                                                     if ($name == 'slideshow') {
                                                         $id = $el->id;
                                                         $display = 'slideshow';
                                                         if (isset($el->display)) {
                                                             $display = $el->display;
                                                         }
                                                         $imgList = $el->innertext;
                                                         ob_start();
                                                         if ($display == 'gallery') {
                                                             include $root . 'sites/common/modules/gallery.php';
                                                             // loads the module
                                                         } else {
                                                             include $root . 'sites/common/modules/slideshow.php';
                                                             // loads the module
                                                         }
                                                         $content = ob_get_contents();
                                                         // holds the content
                                                         ob_end_clean();
                                                         $el->outertext = $content;
                                                     } else {
                                                         if ($name == 'html') {
                                                             $h = $el->innertext;
                                                             $el->outertext = $h;
                                                         } else {
                                                             if ($name == 'youtube' || $name == 'vimeo') {
                                                                 $el->outertext = $el->innertext;
                                                             } else {
                                                                 if ($name == 'file') {
                                                                     $file = $el->file;
                                                                     $description = $el->description;
                                                                     ob_start();
                                                                     include $root . 'sites/common/modules/file.php';
                                                                     // loads the module
                                                                     $content = ob_get_contents();
                                                                     // holds the content
                                                                     ob_end_clean();
                                                                     $el->outertext = $content;
                                                                 } else {
                                                                     if ($name == 'form') {
                                                                         $formId = 'form-0';
                                                                         if (isset($el->id)) {
                                                                             $formId = $el->id;
                                                                         }
                                                                         $type = 'default';
                                                                         if (isset($el->type)) {
                                                                             $type = $el->type;
                                                                         }
                                                                         $action = '';
                                                                         if (isset($el->action)) {
                                                                             $action = $el->action;
                                                                         }
                                                                         $successMessage = '';
                                                                         if (isset($el->success)) {
                                                                             $successMessage = $el->success;
                                                                         }
                                                                         $errorMessage = '';
                                                                         if (isset($el->error)) {
                                                                             $errorMessage = $el->error;
                                                                         }
                                                                         $submitText = '';
                                                                         if (isset($el->submit)) {
                                                                             $submitText = $el->submit;
                                                                         }
                                                                         // place gettext around labels
                                                                         foreach ($el->find('label') as $el_label) {
                                                                             if (count($el_label->find('input')) > 0) {
                                                                                 // generate gettext for radios, checkboxes
                                                                                 $input_arr = $el_label->find('input');
                                                                                 $input_txt = $input_arr[0]->outertext;
                                                                                 $text = str_replace($input_txt, '', $el_label->innertext);
                                                                                 // replace input text
                                                                                 $el_label->innertext = $input_txt . Utilities::GenerateGettext($text);
                                                                             } else {
                                                                                 $el_label->innertext = Utilities::GenerateGettext($el_label->innertext);
                                                                             }
                                                                         }
                                                                         // place gettext around spans
                                                                         foreach ($el->find('.help-block') as $el_block) {
                                                                             $el_block->innertext = Utilities::GenerateGettext($el_block->innertext);
                                                                         }
                                                                         if (strpos($el->innertext, '{{reCaptcha}}') > 0) {
                                                                             $replace = '<?php require_once(\'' . $root . 'libs/recaptchalib.php\'); echo recaptcha_get_html("' . $site['FormPublicId'] . '");?>';
                                                                             $el->innertext = str_replace('{{reCaptcha}}', $replace, $el->innertext);
                                                                         }
                                                                         $form = $el->innertext;
                                                                         ob_start();
                                                                         include $root . 'sites/common/modules/form.php';
                                                                         // loads the module
                                                                         $content = ob_get_contents();
                                                                         // holds the content
                                                                         ob_end_clean();
                                                                         $el->outertext = $content;
                                                                     } else {
                                                                         if ($name == 'map') {
                                                                             $address = $el->address;
                                                                             if (isset($el->zoom)) {
                                                                                 $zoom = $el->zoom;
                                                                             } else {
                                                                                 $zoom = 'auto';
                                                                             }
                                                                             if (isset($el->id)) {
                                                                                 $id = $el->id;
                                                                             } else {
                                                                                 $id = 'map-' + $mapcount;
                                                                             }
                                                                             if (isset($el->class)) {
                                                                                 $cssClass = $el->class;
                                                                             } else {
                                                                                 $cssClass = '';
                                                                             }
                                                                             ob_start();
                                                                             include $root . 'sites/common/modules/map.php';
                                                                             // loads the module
                                                                             $content = ob_get_contents();
                                                                             // holds the content
                                                                             ob_end_clean();
                                                                             $el->outertext = $content;
                                                                             $mapcount++;
                                                                         } else {
                                                                             if ($name == 'like') {
                                                                                 $username = $el->username;
                                                                                 ob_start();
                                                                                 include $root . 'sites/common/modules/like.php';
                                                                                 // loads the module
                                                                                 $content = ob_get_contents();
                                                                                 // holds the content
                                                                                 ob_end_clean();
                                                                                 $el->outertext = $content;
                                                                             } else {
                                                                                 if ($name == 'comments') {
                                                                                     ob_start();
                                                                                     include $root . 'sites/common/modules/comments.php';
                                                                                     // loads the module
                                                                                     $content = ob_get_contents();
                                                                                     // holds the content
                                                                                     ob_end_clean();
                                                                                     $el->outertext = $content;
                                                                                 } else {
                                                                                     if ($name == 'byline') {
                                                                                         ob_start();
                                                                                         include $root . 'sites/common/modules/byline.php';
                                                                                         // loads the module
                                                                                         $content = ob_get_contents();
                                                                                         // holds the content
                                                                                         ob_end_clean();
                                                                                         $el->outertext = $content;
                                                                                     } else {
                                                                                         if ($name == 'shelf') {
                                                                                             // place gettext around descripton
                                                                                             foreach ($el->find('.shelf-description') as $el_label) {
                                                                                                 $el_label->innertext = Utilities::GenerateGettext($el_label->innertext);
                                                                                             }
                                                                                             // place gettext around shipping
                                                                                             foreach ($el->find('.shelf-shipping') as $el_label) {
                                                                                                 $el_label->innertext = Utilities::GenerateGettext($el_label->innertext);
                                                                                             }
                                                                                             // place gettext around add to cart button
                                                                                             foreach ($el->find('.btn span') as $el_label) {
                                                                                                 $el_label->innertext = Utilities::GenerateGettext($el_label->innertext);
                                                                                             }
                                                                                             $shelfId = $el->id;
                                                                                             $shelf = $el->innertext;
                                                                                             ob_start();
                                                                                             include $root . 'sites/common/modules/shelf.php';
                                                                                             // loads the module
                                                                                             $content = ob_get_contents();
                                                                                             // holds the content
                                                                                             ob_end_clean();
                                                                                             $el->outertext = $content;
                                                                                         } else {
                                                                                             // do nothing
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     foreach ($html->find('plugin') as $el) {
         $attrs = $el->attr;
         $p_vars = '';
         foreach ($attrs as $key => &$val) {
             ${$key} = $val;
             // set variable
             $p_vars .= '$' . $key . '="' . $val . '";';
         }
         $id = $el->id;
         $name = $el->name;
         if ($render == 'publish') {
             ob_start();
             include $root . 'plugins/' . $type . '/render.php';
             // loads the module
             $content = ob_get_contents();
             // holds the content
             ob_end_clean();
             $el->outertext = $content;
         } else {
             if ($render == 'runtime') {
                 $list = '<?php ' . $p_vars . 'include "' . $rootloc . 'plugins/' . $type . '/render.php"; ?>';
                 $el->outertext = $list;
             }
         }
     }
     return $html;
 }