Esempio n. 1
0
 /**
  * Gets the data in HTML mode.
  *
  * @param CMS_language &$language The language of the administration frontend
  * @param CMS_page &$page The page which contains the client space
  * @param CMS_clientSpace &$clientSpace The client space which contains the row
  * @param CMS_row &$row The row which contains the block
  * @param integer $visualizationMode The visualization mode used
  * @return string the HTML data
  * @access public
  */
 function getData(&$language, &$page, &$clientSpace, &$row, $visualizationMode)
 {
     parent::getData($language, $page, $clientSpace, $row, $visualizationMode);
     //get the data
     switch ($visualizationMode) {
         case PAGE_VISUALMODE_HTML_PUBLIC:
         case PAGE_VISUALMODE_PRINT:
             $location = RESOURCE_LOCATION_USERSPACE;
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_USERSPACE, true);
             break;
         case PAGE_VISUALMODE_HTML_EDITED:
             $location = RESOURCE_LOCATION_USERSPACE;
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_USERSPACE, false);
             break;
         case PAGE_VISUALMODE_HTML_EDITION:
         case PAGE_VISUALMODE_FORM:
         case PAGE_VISUALMODE_CLIENTSPACES_FORM:
             $location = RESOURCE_LOCATION_EDITION;
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_EDITION, false);
             break;
     }
     //build the HTML
     $html_attributes = "";
     if (isset($this->_attributes['class']) && $this->_attributes['class']) {
         $this->_attributes['class'] .= ' atm-link';
     } else {
         $this->_attributes['class'] = 'atm-link';
     }
     foreach ($this->_attributes as $name => $value) {
         if ($name != "module" && $name != "type") {
             $html_attributes .= ' ' . $name . '="' . $value . '"';
         }
     }
     $link = new CMS_href($data["value"]);
     switch ($visualizationMode) {
         case PAGE_VISUALMODE_HTML_PUBLIC:
         case PAGE_VISUALMODE_PRINT:
             if ($link->hasValidHREF()) {
                 return $this->_replaceBlockVars($link, $html_attributes, RESOURCE_DATA_LOCATION_PUBLIC, true);
             }
             break;
         case PAGE_VISUALMODE_HTML_EDITED:
             if ($link->hasValidHREF()) {
                 return $this->_replaceBlockVars($link, $html_attributes, RESOURCE_DATA_LOCATION_EDITED, false);
             }
             break;
         case PAGE_VISUALMODE_HTML_EDITION:
             if ($link->hasValidHREF()) {
                 return $this->_replaceBlockVars($link, $html_attributes, RESOURCE_DATA_LOCATION_EDITION, false);
             }
             break;
         case PAGE_VISUALMODE_FORM:
             $this->_hasContent = $link->hasValidHREF();
             $this->_editable = true;
             if ($link->hasValidHREF()) {
                 $form_data = $this->_replaceBlockVars($link, $html_attributes, RESOURCE_DATA_LOCATION_EDITION, false);
             } else {
                 if (isset($this->_attributes['default'])) {
                     $html = $this->_attributes['default'];
                 } else {
                     $html = $language->getMessage(self::MESSAGE_BLOCK_LINK_LABEL);
                 }
                 $replace = array('{{data}}' => '<a href="#"' . $html_attributes . ' title="' . io::htmlspecialchars($language->getMessage(self::MESSAGE_BLOCK_LINK_LABEL)) . '">' . $html . '</a>', '{{href}}' => '#', '{{label}}' => $html, '{{jslabel}}' => io::htmlspecialchars($html), '{{target}}' => '', '{{type}}' => '');
                 $form_data = str_replace(array_keys($replace), $replace, $this->_definition);
             }
             return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
             break;
         case PAGE_VISUALMODE_CLIENTSPACES_FORM:
             $this->_hasContent = false;
             $this->_editable = true;
             if (isset($this->_attributes['default'])) {
                 $html = $this->_attributes['default'];
             } else {
                 $html = $language->getMessage(self::MESSAGE_BLOCK_LINK_LABEL);
             }
             $replace = array('{{data}}' => '<a href="#"' . $html_attributes . ' title="' . io::htmlspecialchars($language->getMessage(self::MESSAGE_BLOCK_LINK_LABEL)) . '">' . $html . '</a>', '{{href}}' => '#', '{{label}}' => $html, '{{jslabel}}' => io::htmlspecialchars($html), '{{target}}' => '', '{{type}}' => '');
             $form_data = str_replace(array_keys($replace), $replace, $this->_definition);
             return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
             break;
     }
 }
Esempio n. 2
0
 /**
  * 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;
     }
 }
Esempio n. 3
0
     }
 }
 $item->setReplaceURL($replaceURL);
 $item->setPermanent($permanent);
 $item->setProtected($protected);
 if ($pageId) {
     $page = CMS_tree::getPageById($pageId);
     if ($page && !$page->hasError()) {
         if (!$item->setPage($page)) {
             $cms_message .= $cms_language->getMessage(MESSAGE_ERROR_PAGE_ALREADY_ALIASED, array($page->getID()), 'cms_aliases');
             break;
         }
     }
 } else {
     $href = new CMS_href($redirection);
     if (!$href->hasValidHREF()) {
         $cms_message .= $cms_language->getMessage(MESSAGE_ERROR_REDIRECTION_INCORRECT, false, 'cms_aliases');
         break;
     }
     if ($href->getLinkType() == RESOURCE_LINK_TYPE_EXTERNAL) {
         $item->setURL($href->getExternalLink());
     } elseif ($href->getLinkType() == RESOURCE_LINK_TYPE_INTERNAL) {
         $page = $href->getInternalLinkPage();
         if ($page && !$page->hasError()) {
             if (!$item->setPage($page)) {
                 $cms_message .= $cms_language->getMessage(MESSAGE_ERROR_PAGE_ALREADY_ALIASED, array($page->getID()), 'cms_aliases');
                 break;
             }
         } else {
             $cms_message .= $cms_language->getMessage(MESSAGE_ERROR_PAGE_REDIRECTION_INCORRECT, false, 'cms_aliases');
             break;