/**
     * Compute an atm-object-link tag
     *
     * @param array $tag : the reference atm-object-link tag to compute
     * @return string the PHP / HTML content computed
     * @access private
     */
    protected function _linkObject(&$tag)
    {
        if (!$this->checkTagRequirements($tag, array('field' => 'field', 'objectId' => true))) {
            return;
        }
        $uniqueID = CMS_XMLTag::getUniqueID();
        $return = '
		//OBJECT-LINK TAG START ' . $uniqueID . '
		$error_' . $uniqueID . ' = false;
		if (strtolower(get_class("' . $tag['attributes']['field'] . '")) != \'cms_multi_poly_object\') {
			CMS_grandFather::raiseError("Malformed atm-object-link tag : field attribute must be a valid multi object field");
			$error_' . $uniqueID . ' = true;
		}
		if (!io::isPositiveInteger("' . $tag['attributes']['objectId'] . '")) {
			CMS_grandFather::raiseError("Malformed atm-object-link tag : objectId attribute must be a valid object Id : ' . $tag['attributes']['objectId'] . '");
			$error_' . $uniqueID . ' = true;
		}
		//load object to add
		$object_' . $uniqueID . ' = CMS_poly_object_catalog::getObjectByID("' . $tag['attributes']['objectId'] . '");
		if (!is_object($object_' . $uniqueID . ') || $object_' . $uniqueID . '->hasError() || !$object_' . $uniqueID . '->getID()) {
			CMS_grandFather::raiseError("Malformed atm-object-link tag : objectId attribute must be a valid object Id : ' . $tag['attributes']['objectId'] . '");
			$error_' . $uniqueID . ' = true;
		}
		//check object type and field object type
		if (!$error_' . $uniqueID . ' && "' . $tag['attributes']['field'] . '"->getObjectID() != $object_' . $uniqueID . '->getObjectID()) {
			CMS_grandFather::raiseError("Malformed atm-object-link tag : field object type ("."' . $tag['attributes']['field'] . '"->getObjectID().") and objectId type (".$object_' . $uniqueID . '->getObjectID().") does not match ...");
			$error_' . $uniqueID . ' = true;
		}
		//if no error append object into field ids
		if (!$error_' . $uniqueID . ') {
			$ids_' . $uniqueID . ' = "' . $tag['attributes']['field'] . '"->getValue(\'ids\');
			//$ids_' . $uniqueID . '[$object_' . $uniqueID . '->getID()] = $object_' . $uniqueID . '->getID();
			array_unshift($ids_' . $uniqueID . ', $object_' . $uniqueID . '->getID());
			"' . $tag['attributes']['field'] . '"->setValues(array(\'list\'."' . $tag['attributes']['field'] . '"->getValue(\'fieldID\').\'_0\' => implode(\';\', $ids_' . $uniqueID . ')), \'\');
			$object[CMS_poly_object_catalog::getObjectIDForField("' . $tag['attributes']['field'] . '"->getValue(\'fieldID\'))]->writeToPersistence();
			unset($ids_' . $uniqueID . ');
		} else {
			return false;
		}
		unset($error_' . $uniqueID . ');
		unset($object_' . $uniqueID . ');
		//OBJECT-LINK TAG END ' . $uniqueID . '
		';
        return $return;
    }
Esempio n. 2
0
 /**
  * Compute the current tag according to compute parameters
  *
  * @return string the computed tag results
  * @access private
  * @static
  */
 function compute($parameters = array())
 {
     $this->_computeParams = (array) $parameters;
     $this->_uniqueID = CMS_XMLTag::getUniqueID();
     return $this->_returnComputedDatas($this->_compute());
 }