/** * Get : a XHTML render of the "A" tag * * @param string $module, the module concerned by this link * @param string $dataLocation Where does the data lies ? @see CMS_resource constants * @return string, the XHTML Tag * @access public */ function getHTML($module = MOD_STANDARD_CODENAME, $dataLocation = RESOURCE_DATA_LOCATION_EDITED) { if (!is_a($this->_href, 'CMS_href')) { $this->raiseError("\$this->_href isn't a CMS_href"); return ''; } return $this->_href->getHTML(false, $module, $dataLocation); }
/** * get an object value * * @param string $name : the name of the value to get * @param string $parameters (optional) : parameters for the value to get * @return multidimentionnal array : the object values structure * @access public */ function getValue($name, $parameters = '') { $href = new CMS_href($this->_subfieldValues[0]->getValue()); switch ($name) { case 'validhref': return $href->hasValidHREF(); break; case 'hrefvalue': //get module codename $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID()); //set location $location = $this->_public ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED; return $href->getHTML(false, $moduleCodename, $location, false, true); break; case 'hreflabel': return io::htmlspecialchars($href->getLabel()); break; case 'hreftarget': return $href->getTarget(); break; case 'hreftype': return $href->getLinkType(); break; case 'popupWidth': $popup = $href->getPopup(); return $popup['width']; break; case 'popupHeight': $popup = $href->getPopup(); return $popup['height']; break; case 'hrefHTML': //get module codename $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID()); //set location $location = $this->_public ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED; //add link title (if any) if ($parameters) { $title = $parameters; //add title attribute to link $href->setAttributes(array('title' => io::htmlspecialchars($href->getLabel() . ' (' . $title . ')'))); } else { $title = false; //add title attribute to link $href->setAttributes(array('title' => io::htmlspecialchars($href->getLabel()))); } return $href->getHTML($title, $moduleCodename, $location); break; default: return parent::getValue($name, $parameters); break; } }
/** * Replace block definition vars. * * @param array data : the block datas * @param string html_attributes : html attributes * @param integer $location The location of the page * @param boolean $public The needed precision for USERSPACE location * @return string the HTML data * @access public */ function _replaceBlockVars($data, $html_attributes, $location, $public) { switch ($location) { case RESOURCE_DATA_LOCATION_PUBLIC: $folder = $public ? "public" : "edited"; break; case RESOURCE_DATA_LOCATION_ARCHIVED: $folder = "archived"; break; case RESOURCE_DATA_LOCATION_DELETED: $folder = "deleted"; break; case RESOURCE_DATA_LOCATION_EDITION: $folder = "edition"; break; } $currentLink = new CMS_href($data["externalLink"]); //must put the main website URL before $html_imgZoomHtml = ''; $html_imgZoomName = ''; $html_imageZoomHref = ''; $html_imageZoomPop = ''; if ($public && ALTERNATIVE_DOMAIN) { $domain = ALTERNATIVE_DOMAIN; } else { $domain = CMS_websitesCatalog::getCurrentDomain(@$this->_pageID); } if ($data["file"]) { $html_img = '<img src="' . $domain . PATH_MODULES_FILES_STANDARD_WR . '/' . $folder . '/' . $data["file"] . '" alt="' . io::htmlspecialchars($data["label"]) . '" ' . $html_attributes . ' />'; } if ($data["enlargedFile"]) { $html_imgZoomName = $data["enlargedFile"]; $html_imgZoomHtml = '<img src="' . $domain . PATH_MODULES_FILES_STANDARD_WR . '/' . $folder . '/' . $data["enlargedFile"] . '" alt="' . io::htmlspecialchars($data["label"]) . '" ' . $html_attributes . ' />'; } if ($data["enlargedFile"]) { $href = OPEN_ZOOMIMAGE_IN_POPUP ? CMS_websitesCatalog::getCurrentDomain(@$this->_pageID) . PATH_REALROOT_WR . "/" . CMS_block_image::BLOCK_IMAGE_POPUP . '?location=' . $folder . '&file=' . $data["enlargedFile"] . '&label=' . urlencode($data["label"]) : $domain . PATH_MODULES_FILES_STANDARD_WR . '/' . $folder . '/' . $data["enlargedFile"]; $popup = OPEN_ZOOMIMAGE_IN_POPUP ? ' onclick="javascript:CMS_openPopUpImage(\'' . addslashes($href) . '\');return false;"' : ''; if ($html_img) { $html = '<a target="_blank" rel="atm-enlarge" href="' . $href . '"' . $popup . ' title="' . io::htmlspecialchars($data["label"]) . '">' . $html_img . '</a>'; } $html_imageZoomHref = $href; $linkLabel = '<a class="imagezoomlink" target="_blank" href="' . $href . '"' . $popup . ' title="' . io::htmlspecialchars($data["label"]) . '">' . io::htmlspecialchars($data["label"]) . '</a>'; } else { if ($currentLink->getHTML(false, MOD_STANDARD_CODENAME, $location)) { $html = $currentLink->getHTML($html_img, MOD_STANDARD_CODENAME, $location); $currentLink->setLabel(''); $linkLabel = $currentLink->getHTML($data['label'], MOD_STANDARD_CODENAME, $location); } else { $html = $html_img; $linkLabel = io::htmlspecialchars($data["label"]); } } $replace = array('{{data}}' => $html, '{{label}}' => io::htmlspecialchars($data["label"]), '{{jslabel}}' => io::htmlspecialchars($data["label"]), '{{linkLabel}}' => $linkLabel, '{{imageZoomHtml}}' => $html_imgZoomHtml, '{{imagePath}}' => $domain . PATH_MODULES_FILES_STANDARD_WR . '/' . $folder, '{{imageName}}' => $data["file"], '{{imageZoomHref}}' => $html_imageZoomHref, '{{imageZoomName}}' => $html_imgZoomName); if (io::strpos($this->_definition, 'Width}}') !== false || io::strpos($this->_definition, 'Height}}') !== false) { list($sizeX, $sizeY) = @getimagesize(PATH_MODULES_FILES_STANDARD_FS . '/' . $folder . '/' . $data["file"]); if (isset($data["enlargedFile"])) { list($sizeZoomX, $sizeZoomY) = @getimagesize(PATH_MODULES_FILES_STANDARD_FS . '/' . $folder . '/' . $data["enlargedFile"]); } $replace['{{imageWidth}}'] = isset($sizeX) ? $sizeX : "0"; $replace['{{imageHeight}}'] = isset($sizeY) ? $sizeY : "0"; $replace['{{imageZoomWidth}}'] = isset($sizeZoomX) ? $sizeZoomX : "0"; $replace['{{imageZoomHeight}}'] = isset($sizeZoomY) ? $sizeZoomY : "0"; } return str_replace(array_keys($replace), $replace, $this->_definition); }