Пример #1
0
/**
 *	implements save_state
 */
function image_save_state($args)
{
    $elem = $args['elem'];
    $obj = $args['obj'];
    // only take responsibility for the element when we are its main class
    if (array_shift(elem_classes($elem)) != 'image') {
        return false;
    }
    // make sure the type is set
    $obj['type'] = 'image';
    $obj['module'] = 'image';
    // by convention the main retrieving of the elements properties takes
    // place in alter_state
    // this way other objects types may "derive" from this one
    // it also allows other modules to chime in
    // notice: obj is passed as reference here
    // obj might be (almost) empty for newly created objects, so rely only
    // on $elem
    invoke_hook('alter_save', array('obj' => &$obj, 'elem' => $elem));
    // see image_alter_save() above
    // we could do some overriding here if we wanted to
    // finally save the object
    load_modules('glue');
    $ret = save_object($obj);
    if ($ret['#error']) {
        log_msg('error', 'image_save_state: save_object returned ' . quot($ret['#data']));
        return false;
    } else {
        return true;
    }
}
function iframe_save_state($args)
{
    $elem = $args['elem'];
    $obj = $args['obj'];
    if (array_shift(elem_classes($elem)) != 'iframe') {
        return false;
    }
    // make sure the type is set
    $obj['type'] = 'iframe';
    $obj['module'] = 'iframe';
    // hook
    invoke_hook('alter_save', array('obj' => &$obj, 'elem' => $elem));
    load_modules('glue');
    $ret = save_object($obj);
    if ($ret['#error']) {
        log_msg('error', 'iframe_save_state: save_object returned ' . quot($ret['#data']));
        return false;
    } else {
        return true;
    }
}
Пример #3
0
function download_save_state($args)
{
    $elem = $args['elem'];
    $obj = $args['obj'];
    if (array_shift(elem_classes($elem)) != 'download') {
        return false;
    }
    // make sure the type is set
    $obj['type'] = 'download';
    $obj['module'] = 'download';
    // hook
    invoke_hook('alter_save', array('obj' => &$obj, 'elem' => $elem));
    // make width and height only be determined by the css
    if (isset($obj['object-width'])) {
        unset($obj['object-width']);
    }
    if (isset($obj['object-height'])) {
        unset($obj['object-height']);
    }
    load_modules('glue');
    $ret = save_object($obj);
    if ($ret['#error']) {
        log_msg('error', 'download_save_state: save_object returned ' . quot($ret['#data']));
        return false;
    } else {
        return true;
    }
}