Пример #1
0
 function &fillContainer(&$container, $templateID, $pageID)
 {
     global $modulesMgr, $structureMgr, $authenticationMgr, $permissionsMgr;
     $filledContainer = "";
     //parse parameters
     $params = preg_split("/(?<=\")\\s+/", $container, -1, PREG_SPLIT_NO_EMPTY);
     $cType = "inline";
     $id = "";
     $style = "";
     $class = "";
     $namedId = "";
     $moduleName = "";
     $funcName = "";
     $args = array($pageID);
     for ($i = 0; $i < count($params); $i++) {
         if (preg_match("/(\\w+)\\=\"((?:.|^\")+)\"/", $params[$i], $matches)) {
             switch ($matches[1]) {
                 case "type":
                     $cType = $matches[2];
                     break;
                 case "module":
                     $moduleName = $matches[2];
                     break;
                 case "function":
                     $funcName = $matches[2];
                     break;
                 case "id":
                     $namedId = $matches[2];
                     $id = " id=\"" . $namedId . "\"";
                     $args["id"] = $namedId;
                     break;
                 case "style":
                     $style = " style=\"" . $matches[2] . "\"";
                     break;
                 case "class":
                     $class = " class=\"" . $matches[2] . "\"";
                     break;
                 default:
                     $args[strtoupper($matches[1])] = $matches[2];
             }
         }
     }
     if (!$namedId) {
         trigger_error("No [id] defined in container " . htmlentities($container), PM_WARNING);
         continue;
     }
     //this type of content means that we must get the name of module from structure and call it's method "getContent"
     if ($cType == "MainContent") {
         $funcName = "getContent";
         $metaData = $structureMgr->getMetaData($pageID);
         $moduleName = $metaData["ModuleName"];
         $cType = "inline";
         if ($permissionsMgr->canUpdate($pageID, $authenticationMgr->getUserID())) {
             require_once "_quickAdmin.php";
             $filledContainer = quickAdminBlock($pageID);
         }
     }
     //here we decide, what kind of container will be filled and how it will be performed
     if (!$moduleName || !$funcName) {
         list($moduleName, $funcName) = $this->getTemplateContainerParams($templateID, $namedId);
     }
     //next line does the mostly valueable thing in the whole system - it executes the needed function of exact module
     $fillValue = $modulesMgr->execute($moduleName, $funcName, $args, false);
     //this switch identifies the behaviour of replacing the container - with div or without it.
     //maybe later some other types will appear, but I am not sure that it is necessary
     switch ($cType) {
         case "div":
             $filledContainer .= "<div{$id}{$style}{$class}>{$fillValue}</div>";
             break;
         case "inline":
             $filledContainer .= $fillValue;
             break;
     }
     return $filledContainer;
 }
Пример #2
0
 function &fillContainer(&$container, $templateID, $pageID)
 {
     global $modulesMgr, $structureMgr, $authenticationMgr, $permissionsMgr, $stime, $iter;
     $filledContainer = '';
     //parse parameters
     $params = preg_split('@(?<=")\\s+@', $container, -1, PREG_SPLIT_NO_EMPTY);
     $cType = 'inline';
     $id = '';
     $style = '';
     $class = '';
     $namedId = '';
     $moduleName = '';
     $funcName = '';
     $args = array($pageID);
     foreach ($params as $i => $v) {
         if (preg_match('@(\\w+)\\="((?:.|^")+)"@', $v, $matches)) {
             switch ($matches[1]) {
                 case 'type':
                     $cType = $matches[2];
                     break;
                 case 'module':
                     $moduleName = $matches[2];
                     break;
                 case 'function':
                     $funcName = $matches[2];
                     break;
                 case 'id':
                     $namedId = $matches[2];
                     $id = ' id="' . $namedId . '"';
                     $args['id'] = $namedId;
                     $args['DEPTH'] = 1;
                     break;
                 case 'style':
                     $style = ' style="' . $matches[2] . '"';
                     break;
                 case 'class':
                     $class = ' class="' . $matches[2] . '"';
                     break;
                 default:
                     $args[strtoupper($matches[1])] = $matches[2];
             }
         }
     }
     if (!$namedId) {
         trigger_error('No [id] defined in container ' . htmlentities($container), PM_WARNING);
         continue;
     }
     //this type of content means that we must get the name of module from structure and call it's method "getContent"
     if ($cType == 'MainContent') {
         $funcName = 'getContent';
         $metaData = $structureMgr->getMetaData($pageID);
         $moduleName = $metaData['ModuleName'];
         $cType = 'inline';
         if ($permissionsMgr->canUpdate($pageID, $authenticationMgr->getUserID())) {
             require_once '_quickAdmin.php';
             $filledContainer = quickAdminBlock($pageID);
         }
     }
     //here we decide, what kind of container will be filled and how it will be performed
     if (!$moduleName || !$funcName) {
         list($moduleName, $funcName) = $this->getTemplateContainerParams($templateID, $namedId);
     }
     //next line does the mostly valueable thing in the whole system - it executes the needed function of exact module
     $fillValue = $modulesMgr->execute($moduleName, $funcName, $args, false);
     //print 'iter:'.$iter.' time='.( round(get_microtime() - $stime, 4) )."\n";
     //this switch identifies the behaviour of replacing the container - with div or without it.
     //maybe later some other types will appear, but I am not sure that it is necessary
     switch ($cType) {
         case "div":
             $filledContainer .= '<div' . $id . $style . $class . '>' . $fillValue . '</div>';
             break;
         case "inline":
             $filledContainer .= $fillValue;
             break;
     }
     return $filledContainer;
 }