コード例 #1
0
ファイル: object_href.php プロジェクト: davidmottet/automne
 /**
  * Return the needed form field tag for current object field
  *
  * @param array $values : parameters values array(parameterName => parameterValue) in :
  *     id : the form field id to set
  * @param multidimentionnal array $tags : xml2Array content of atm-function tag
  * @return string : the form field HTML tag
  * @access public
  */
 function getInput($fieldID, $language, $inputParams)
 {
     $params = $this->getParamsValues();
     if (isset($inputParams['prefix'])) {
         $prefixName = $inputParams['prefix'];
     } else {
         $prefixName = '';
     }
     if (!isset($inputParams['no_admin'])) {
         $options['no_admin'] = true;
     }
     //create a sub prefix for CMS_dialog_href object
     $subPrefixName = 'href' . $prefixName . $this->_field->getID() . '_0';
     if (isset($inputParams['hidden']) && ($inputParams['hidden'] == 'true' || $inputParams['hidden'] == 1)) {
         if (isset($inputParams['value'])) {
             $value = $inputParams['value'];
         } elseif (isset($this->_subfieldValues[0]) && is_object($this->_subfieldValues[0]) && !is_null($this->_subfieldValues[0]->getValue())) {
             //create object CMS_href & CMS_dialog_href
             $href = new CMS_href($this->_subfieldValues[0]->getValue());
             $value = $href->getTextDefinition();
         } else {
             $value = '';
         }
         $html = '<input type="hidden" name="' . $subPrefixName . '" value="' . $value . '" />' . "\n";
     } else {
         //get module codename
         $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
         //create object CMS_href & CMS_dialog_href
         $href = new CMS_href($this->_subfieldValues[0]->getValue());
         foreach ($inputParams as $k => $v) {
             if (in_array($k, array('id', 'class', 'style', 'tabindex', 'disabled', 'dir', 'lang', 'width', 'height', 'alt', 'title'))) {
                 $href->setAttribute($k, $v);
             }
         }
         //redefine temporarily this constant here, because it is defined in cms_rc_admin and sometimes, only cms_rc_frontend is available
         if (!defined("PATH_ADMIN_WR")) {
             define("PATH_ADMIN_WR", PATH_MAIN_WR . "/admin");
         }
         if (!defined("PATH_ADMIN_IMAGES_WR")) {
             define("PATH_ADMIN_IMAGES_WR", PATH_ADMIN_WR . "/img");
         }
         $hrefDialog = new CMS_dialog_href($href, $subPrefixName);
         $existingLink = $hrefDialog->getHTML($moduleCodename) ? $hrefDialog->getHTML($moduleCodename) : $language->getMessage(self::MESSAGE_OBJECT_HREF_FIELD_NONE);
         $html .= $hrefDialog->getHTMLFields($language, $moduleCodename, RESOURCE_DATA_LOCATION_EDITED, $options) . '<br />' . $language->getMessage(self::MESSAGE_OBJECT_HREF_EXISTING_LINK, false, MOD_POLYMOD_CODENAME) . ' : ' . $existingLink;
         if (POLYMOD_DEBUG) {
             $html .= ' <span class="admin_text_alert">(Field : ' . $this->_field->getID() . ' - SubField : 0)</span>';
         }
     }
     //append html hidden field which store field name
     if ($html) {
         $html .= '<input type="hidden" name="polymodFields[' . $this->_field->getID() . ']" value="' . $this->_field->getID() . '" />';
     }
     return $html;
 }