function getXMLString($name = false, $data, $ret = false, $debug = false)
{
    // given string $data, will return the text string content of the $name attribute content of a given valid xml document.
    if ($debug) {
        ezDebug::writeNotice($name, 'getXMLString:name');
    }
    // get information out of eZXML
    $xml = new eZXML();
    $xmlDoc = $data;
    if ($debug) {
        ezDebug::writeNotice($data, 'getXMLString:data');
    }
    // continue only with content
    if ($xmlDoc != null and $name != null) {
        $dom = $xml->domTree($xmlDoc);
        $element = $dom->elementsByName("{$name}");
        if (is_object($element[0])) {
            $string = $element[0]->textContent();
            $ret = $string;
        } else {
            eZDebug::writeNotice('Key "' . $name . '" does not exist.', 'wrap_operator');
        }
    }
    if ($debug) {
        ezDebug::writeNotice($ret, 'getXMLString:ret');
    }
    return $ret;
}
Example #2
0
function tidy($input, $debug = true, $ret = false)
{
    /*
    if ( $debug )
        ezDebug::writeNotice( 'call', 'getCountryList:fetch' );
    */
    /*
    $PHP_COMMAND='/usr/local/php4.4.4/bin/php -d memory_limit=456M';
    $exec = $PHP_COMMAND . ' update/common/scripts/updatesearchindex2_sub.php ' . $optionString . $objectID;
    */
    // okay - we have valid key.  Let's encrypt the contents now.
    // $call = "$input | /usr/bin/tidy --show-body-only";
    $call = "/usr/bin/tidy --show-body-only";
    // $call .= $this->gpg_decrypt_cmd_parm;
    // $call .= " 3<<< '$key' <<< '$data' ";
    $call .= " <<< '{$input}' ";
    if ($debug) {
        // ezDebug::writeNotice( $call, 'tidy:call' );
        // $last_line = system( $gpg_call, $decrypted );
        // $decrypted = passthru( $gpg_call, $retcode );
        // $decrypted = passthru( $gpg_call, $retcode );
        /* Add redirection so we can get stderr.
           $handle = popen( $call, 'rw' );
           $contents = fread( $handle, 2096 );
           */
        // @exec( $call.' "'..'"', $contents);
        @exec($call, $contents);
    }
    // $contents = shell_exec( $call );
    // $contents = 0;
    if ($debug) {
        ezDebug::writeNotice($contents, 'tidy:ret');
    }
    // $PHP_COMMAND='/usr/local/php4.4.4/bin/php -d memory_limit=456M';
    // $exec="$input|tidy --show-body-only"; // . $optionString . $objectID";
    /*
    $retval='';
    echo "Executing $exec\n";
    $result = passthru( $exec, $retval );
    $ret = $retval;
    */
    $ret = $contents;
    /*
    include_once( 'extension/ezdbug/autoloads/ezdbug.php' );
    $d = new eZDBugOperators();
    $d->ezdbugDump( $contents );
    */
    // echo('<hr />');
    //     die("$call <hr />");
    /*
    if ( $debug )
        ezDebug::writeNotice( $ret, 'getXMLString:ret' );
    */
    return $ret;
}
function getCountryList($ret = false, $debug = false)
{
    /*
    if ( $debug )
        ezDebug::writeNotice( 'call', 'getCountryList:fetch' );
    */
    $countryType = new eZCountryType();
    $countries = $countryType->fetchCountryList();
    /*
    include_once( 'extension/ezdbug/autoloads/ezdbug.php' );
    $d = new eZDBugOperators();
    $d->ezdbugDump( $countries );
    */
    $ret =& $countries;
    if ($debug) {
        ezDebug::writeNotice($ret, 'getXMLString:ret');
    }
    return $ret;
}
 function getClassAttributes($attribute_names = array())
 {
     $debug = false;
     $db = eZDb::instance();
     $ret = array();
     $result = array();
     $result2 = array();
     if (count($attribute_names) > 1) {
         foreach ($attribute_names as $key => $attribute_name) {
             $sql = "SELECT tmp.id, tmp.identifier from (select ezcontentclass.id, ezcontentclass.identifier from ezcontentclass,ezcontentclass_attribute where (ezcontentclass.id=ezcontentclass_attribute.contentclass_id AND ezcontentclass_attribute.identifier='servizio')) as tmp, ezcontentclass_attribute where tmp.id=ezcontentclass_attribute.contentclass_id AND ezcontentclass_attribute.identifier='argomento'";
             $ret[] = $db->arrayQuery($sql);
         }
     } else {
         foreach ($attribute_names as $key => $attribute_name) {
             $sql = "SELECT ezcontentclass.id, ezcontentclass.identifier \n                FROM ezcontentclass_attribute, ezcontentclass \n                WHERE ezcontentclass.id=ezcontentclass_attribute.contentclass_id \n                AND ezcontentclass_attribute.identifier='" . $attribute_name . "'";
             $ret[] = $db->arrayQuery($sql);
         }
     }
     if ($debug) {
         ezDebug::writeNotice($ret[0], 'getClassAttributes: risultato per ' . implode(',', $attribute_names));
     }
     return $ret[0];
 }
Example #5
0
/**
 * Imports a value to an attribute adapting it to the proper type.
 * Not written by me, downloaded from ez.no! Extended it only!
 * @param data The value (string/int/float).
 * @param contentObjectAttribute The attribute to modify.
 */
function importAttribute($data, &$contentObjectAttribute)
{
    $contentClassAttribute = $contentObjectAttribute->attribute('contentclass_attribute');
    $dataTypeString = $contentClassAttribute->attribute('data_type_string');
    ezDebug::writeDebug("Converting " . $data . " to expected " . $dataTypeString);
    switch ($dataTypeString) {
        case 'ezfloat':
        case 'ezprice':
            $contentObjectAttribute->setAttribute('data_float', $data);
            $contentObjectAttribute->store();
            break;
        case 'ezboolean':
        case 'ezdate':
        case 'ezdatetime':
        case 'ezinteger':
        case 'ezsubtreesubscription':
        case 'eztime':
            $contentObjectAttribute->setAttribute('data_int', $data);
            $contentObjectAttribute->store();
            break;
        case 'ezobjectrelation':
            // $data is contentobject_id to relate to
            //            $oldData = $contentObjectAttribute->attribute( 'data_int' );
            $contentObjectAttribute->setAttribute('data_int', $data);
            $contentObjectAttribute->store();
            $object = $contentObjectAttribute->object();
            $contentObjectVersion = $contentObjectAttribute->attribute('version');
            $contentClassAttributeID = $contentObjectAttribute->attribute('contentclassattribute_id');
            // Problem with translations if removing old relations ?!
            //            $object->removeContentObjectRelation( $oldData, $contentObjectVersion, $contentClassAttributeID, eZContentObject::RELATION_ATTRIBUTE );
            $object->addContentObjectRelation($data, $contentObjectVersion, $contentClassAttributeID, RELATION_ATTRIBUTE);
            break;
        case 'ezurl':
            $urlID = eZURL::registerURL($data);
            $contentObjectAttribute->setAttribute('data_int', $urlID);
            // Fall through to set data_text
        // Fall through to set data_text
        case 'ezemail':
        case 'ezisbn':
        case 'ezstring':
        case 'eztext':
            $contentObjectAttribute->setAttribute('data_text', $data);
            $contentObjectAttribute->store();
            break;
        case 'ezxmltext':
            /*            $parser = new eZXMLInputParser();
                    $document = $parser->process( $data );
                    $data = eZXMLTextType::domString( $document );
                    $contentObjectAttribute->fromString( $data );*/
            $contentObjectAttribute->setAttribute('data_text', $data);
            $contentObjectAttribute->store();
            break;
            //    case 'ezimage':
            //        $this->saveImage( $data, $contentObjectAttribute );
            //        break;
            //    case 'ezbinaryfile':
            //        $this->saveFile( $data, $contentObjectAttribute );
            //        break;
            //    case 'ezenum':
            //removed enum - function can be found at ez.no
            //        break;
        //    case 'ezimage':
        //        $this->saveImage( $data, $contentObjectAttribute );
        //        break;
        //    case 'ezbinaryfile':
        //        $this->saveFile( $data, $contentObjectAttribute );
        //        break;
        //    case 'ezenum':
        //removed enum - function can be found at ez.no
        //        break;
        case 'ezuser':
            // $data is assumed to be an associative array( login, password, email );
            $user = new eZUser($contentObjectAttribute->attribute('contentobject_id'));
            if (isset($data['login'])) {
                $user->setAttribute('login', $data['login']);
            }
            if (isset($data['email'])) {
                $user->setAttribute('email', $data['email']);
            }
            if (isset($data['password'])) {
                $hashType = eZUser::hashType() . '';
                $newHash = $user->createHash($data['login'], $data['password'], eZUser::site(), $hashType);
                $user->setAttribute('password_hash_type', $hashType);
                $user->setAttribute('password_hash', $newHash);
            }
            $user->store();
            break;
        default:
            die('Can not store ' . $data . ' as datatype: ' . $dataTypeString);
    }
}