Exemple #1
0
 private static function buildXmlNodes($intElmntId = 0, $strType = "elements", $strAction = "list", $childId = 0, $strChildren = "")
 {
     global $objLang, $objLiveUser;
     $strReturn = "";
     switch ($strType) {
         case "elements-ckeditor":
         case "elements":
             $objElements = Elements::getFromParent($intElmntId);
             foreach ($objElements as $objElement) {
                 if ($objLiveUser->checkRightLevel(PUNCHCMS_ELEMENTS_VIEW, $objElement->getPermissions()->getUserId(), $objElement->getPermissions()->getGroupId())) {
                     $objChildren = $objElement->getElements();
                     $isPage = $objElement->isPage() ? 'font-weight:bold;' : '';
                     if (is_object($objChildren) && $objChildren->count() > 0 && $objElement->getTypeId() != ELM_TYPE_FOLDER) {
                         if (!$objElement->getActive()) {
                             $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" style=\"{$isPage}color:#999\" im0=\"elementClosedInactive.gif\" im1=\"elementOpenInactive.gif\" im2=\"elementClosedInactive.gif\" child=\"1\">";
                         } else {
                             $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" style=\"{$isPage}\" im0=\"elementClosed.gif\" im1=\"elementOpen.gif\" im2=\"elementClosed.gif\" child=\"1\">";
                         }
                         if ($childId == $objElement->getId()) {
                             $strReturn .= $strChildren;
                         }
                         $strReturn .= "</item>";
                     } else {
                         if ($objElement->getTypeId() == ELM_TYPE_FOLDER) {
                             $intChild = is_object($objChildren) && $objChildren->count() > 0 ? 1 : 0;
                             if (!$objElement->getActive()) {
                                 $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" style=\"{$isPage}color:#999\" im0=\"folderClosedInactive.gif\" im1=\"folderOpenInactive.gif\" im2=\"folderClosedInactive.gif\" child=\"{$intChild}\">";
                             } else {
                                 $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" style=\"{$isPage}\" im0=\"folderClosed.gif\" im1=\"folderOpen.gif\" im2=\"folderClosed.gif\" child=\"{$intChild}\">";
                             }
                             if ($childId == $objElement->getId()) {
                                 $strReturn .= $strChildren;
                             }
                             $strReturn .= "</item>";
                         } else {
                             if (!$objElement->getActive()) {
                                 $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" style=\"{$isPage}color:#999\" im0=\"leafInactive.gif\" im1=\"leafInactive.gif\" im2=\"leafInactive.gif\" child=\"0\" />";
                             } else {
                                 $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" style=\"{$isPage}\" child=\"0\" />";
                             }
                         }
                     }
                 }
             }
             if ($strAction == "init") {
                 $objParent = Element::selectByPk($intElmntId);
                 if (is_object($objParent)) {
                     $intParent = $objParent->getParentId();
                     $strReturn = self::buildXmlNodes($intParent, $strType, $strAction, $intElmntId, $strReturn);
                 }
             }
             break;
         case "templates":
             $objTemplates = Templates::getFromParent($intElmntId);
             foreach ($objTemplates as $objTemplate) {
                 $objChildren = $objTemplate->getTemplates();
                 if (is_object($objChildren) && $objChildren->count() > 0) {
                     $strReturn .= "<item text=\"" . self::escapeForXml($objTemplate->getName()) . "\" id=\"{$objTemplate->getId()}\" im0=\"templateClosed.gif\" im1=\"templateOpen.gif\" im2=\"templateClosed.gif\" child=\"1\">";
                     if ($childId == $objTemplate->getId()) {
                         $strReturn .= $strChildren;
                     }
                     $strReturn .= "</item>";
                 } else {
                     $strReturn .= "<item text=\"" . self::escapeForXml($objTemplate->getName()) . "\" id=\"{$objTemplate->getId()}\" im0=\"template.gif\" im1=\"template.gif\" im2=\"template.gif\" child=\"0\" />";
                 }
             }
             if ($strAction == "init") {
                 $objParent = Template::selectByPk($intElmntId);
                 if (is_object($objParent)) {
                     $intParent = $objParent->getParentId();
                     $strReturn = self::buildXmlNodes($intParent, $strType, $strAction, $intElmntId, $strReturn);
                 }
             }
             break;
         case "users":
             $strReturn = "<item text=\"" . self::escapeForXml($objLang->get("users", "usersLabel")) . "\" id=\"" . NAV_MYPUNCH_USERS_USER . "\" im0=\"misc.gif\" im1=\"misc.gif\" im2=\"misc.gif\" child=\"0\" />";
             $strReturn .= "<item text=\"" . self::escapeForXml($objLang->get("groups", "usersLabel")) . "\" id=\"" . NAV_MYPUNCH_USERS_GROUP . "\" im0=\"misc.gif\" im1=\"misc.gif\" im2=\"misc.gif\" child=\"0\" />";
             $strReturn .= "<item text=\"" . self::escapeForXml($objLang->get("applications", "usersLabel")) . "\" id=\"" . NAV_MYPUNCH_USERS_APPLICATION . "\" im0=\"misc.gif\" im1=\"misc.gif\" im2=\"misc.gif\" child=\"0\" />";
             $strReturn .= "<item text=\"" . self::escapeForXml($objLang->get("areas", "usersLabel")) . "\" id=\"" . NAV_MYPUNCH_USERS_AREA . "\" im0=\"misc.gif\" im1=\"misc.gif\" im2=\"misc.gif\" child=\"0\" />";
             $strReturn .= "<item text=\"" . self::escapeForXml($objLang->get("rights", "usersLabel")) . "\" id=\"" . NAV_MYPUNCH_USERS_RIGHT . "\" im0=\"misc.gif\" im1=\"misc.gif\" im2=\"misc.gif\" child=\"0\" />";
             break;
         case "forms":
             $objForms = Form::selectByAccountId();
             foreach ($objForms as $objForm) {
                 $strReturn .= "<item text=\"" . self::escapeForXml($objForm->getName()) . "\" id=\"{$objForm->getId()}\" im0=\"template.gif\" im1=\"template.gif\" im2=\"template.gif\" child=\"0\" />";
             }
             break;
         case "media-ckeditor":
         case "storage":
             $objFolders = StorageItems::getFromParent($intElmntId, STORAGE_TYPE_ALL);
             foreach ($objFolders as $objElement) {
                 $objChildren = $objElement->getItems(STORAGE_TYPE_ALL);
                 if ($objElement->getTypeId() != STORAGE_TYPE_FOLDER) {
                     $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" child=\"0\">";
                     if ($childId == $objElement->getId()) {
                         $strReturn .= $strChildren;
                     }
                     $strReturn .= "</item>";
                 } else {
                     if ($objElement->getTypeId() == STORAGE_TYPE_FOLDER) {
                         $intChild = is_object($objChildren) && $objChildren->count() > 0 ? 1 : 0;
                         $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" style=\"font-weight:bold;\" im0=\"folderClosed.gif\" im1=\"folderOpen.gif\" im2=\"folderClosed.gif\" child=\"{$intChild}\">";
                         if ($childId == $objElement->getId()) {
                             $strReturn .= $strChildren;
                         }
                         $strReturn .= "</item>";
                     } else {
                         $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\"  im0=\"elementClosed.gif\" im1=\"elementOpen.gif\" im2=\"elementClosed.gif\" child=\"0\" />";
                     }
                 }
             }
             if ($strAction == "init") {
                 $objParent = StorageItem::selectByPk($intElmntId);
                 if (is_object($objParent)) {
                     $intParent = $objParent->getParentId();
                     $strReturn = self::buildXmlNodes($intParent, $strType, $strAction, $intElmntId, $strReturn);
                 }
             }
             break;
     }
     return $strReturn;
 }
Exemple #2
0
 public function getTemplates($blnRecursive = FALSE)
 {
     if ($this->id > 0) {
         if (!is_object($this->objTemplateCollection)) {
             $this->objTemplateCollection = Templates::getFromParent($this->id, $blnRecursive);
         }
     } else {
         $this->objTemplateCollection = new DBA__Collection();
     }
     return $this->objTemplateCollection;
 }
Exemple #3
0
 public static function exportTemplate($objDoc, $intAccountId, $intId, $arrTemplateFilters = NULL, $includeSelf = false)
 {
     $objTemplates = $objDoc->createElement('templates');
     if ($includeSelf) {
         $objTemplate = Template::selectByPK($intId);
         $objDbTemplates = new DBA__Collection();
         $objDbTemplates->addObject($objTemplate);
     } else {
         $objDbTemplates = Templates::getFromParent($intId, false, $intAccountId);
     }
     if ($objDbTemplates->count() > 0) {
         foreach ($objDbTemplates as $objDbTemplate) {
             if ($arrTemplateFilters == NULL || in_array($objDbTemplate->getId(), $arrTemplateFilters)) {
                 $objTemplate = $objDoc->createElement('template');
                 $objTemplate->setAttribute("id", $objDbTemplate->getId());
                 $objTemplate->setAttribute("name", $objDbTemplate->getName());
                 $objTemplate->setAttribute("apiName", $objDbTemplate->getApiName());
                 $objTemplate->setAttribute("description", $objDbTemplate->getDescription());
                 $objTemplate->setAttribute("sort", $objDbTemplate->getSort());
                 $objTemplate->setAttribute("isPage", $objDbTemplate->getIsPage());
                 $objTemplate->setAttribute("forceCreation", $objDbTemplate->getForceCreation());
                 $objTemplate->setAttribute("isContainer", $objDbTemplate->getIsContainer());
                 $objTemplate->setAttribute("active", $objDbTemplate->getActive());
                 $objFields = $objDoc->createElement('fields');
                 foreach ($objDbTemplate->getFields() as $objDbField) {
                     $objField = $objDoc->createElement('field');
                     $objField->setAttribute("id", $objDbField->getId());
                     $objField->setAttribute("required", $objDbField->getRequired());
                     $objField->setAttribute("typeId", $objDbField->getTypeId());
                     $objField->setAttribute("name", $objDbField->getName());
                     $objField->setAttribute("apiName", $objDbField->getApiName());
                     $objField->setAttribute("description", $objDbField->getDescription());
                     $objField->setAttribute("username", $objDbField->getUsername());
                     $objField->setAttribute("sort", $objDbField->getSort());
                     $objValues = $objDoc->createElement('values');
                     foreach ($objDbField->getValues() as $objDbValue) {
                         $objValue = $objDoc->createElement('value');
                         $objValue->setAttribute("name", $objDbValue->getName());
                         $objValue->setAttribute("value", $objDbValue->getValue());
                         $objValues->appendChild($objValue);
                     }
                     $objField->appendChild($objValues);
                     $objFields->appendChild($objField);
                 }
                 $objTemplate->appendChild($objFields);
                 $objSubTemplates = self::exportTemplate($objDoc, $intAccountId, $objDbTemplate->getId(), $arrTemplateFilters);
                 if ($objSubTemplates) {
                     $objTemplate->appendChild($objSubTemplates);
                 }
                 $objTemplates->appendChild($objTemplate);
             }
         }
     }
     return $objTemplates;
 }