/**
 * Loads the profile fields.
 *
 * @param $account
 *   An user object.
 * @param $type
 *   The type used - if supported by the module.
 */
function hook_load_profile(&$account, $type = NULL)
{
    $profile = content_profile_load($type, $account->uid);
    if (!$profile) {
        return;
    }
    $fields = content_fields(NULL, $type);
    foreach ($fields as $field_name => $field_attributes) {
        if (isset($profile->{$field_name})) {
            $values = array();
            $contents = $profile->{$field_name};
            foreach ($contents as $content) {
                if (isset($content['value'])) {
                    $values[] = $content['value'];
                } else {
                    $values[] = content_format($field_name, $content);
                }
            }
            if (empty($account->{$field_name})) {
                switch (count($values)) {
                    case 0:
                        $account->{$field_name} = NULL;
                        break;
                    case 1:
                        $account->{$field_name} = $values[0];
                        break;
                    default:
                        $account->{$field_name} = $values;
                }
            }
        }
    }
}
Example #2
0
function commons_origins_preprocess_page(&$variables)
{
    $variables['pre_header_top'] = theme('grid_row', $variables['header_top'], 'header-top', 'full-width', $variables['grid_width']);
    $variables['pre_secondary_links'] = theme('grid_block', theme('links', $variables['secondary_links']), 'secondary-menu');
    $variables['pre_search_box'] = theme('grid_block', $variables['search_box'], 'search-box');
    $variables['pre_primary_links_tree'] = theme('grid_block', $variables['primary_links_tree'], 'primary-menu');
    $variables['pre_breadcrumb'] = theme('grid_block', $variables['breadcrumb'], 'breadcrumbs');
    $variables['pre_preface_top'] = theme('grid_row', $variables['preface_top'], 'preface-top', 'full-width', $variables['grid_width']);
    $variables['pre_sidebar_first'] = theme('grid_row', $variables['sidebar_first'], 'sidebar-first', 'nested', $variables['sidebar_first_width']);
    $variables['pre_preface_bottom'] = theme('grid_row', $variables['preface_bottom'], 'preface-bottom', 'nested');
    $variables['pre_help'] = theme('grid_block', $variables['help'], 'content-help');
    $variables['pre_messages'] = theme('grid_block', $variables['messages'], 'content-messages');
    $variables['pre_tabs'] = theme('grid_block', $variables['tabs'], 'content-tabs');
    $variables['pre_content_bottom'] = theme('grid_row', $variables['content_bottom'], 'content-bottom', 'nested');
    $variables['pre_sidebar_last'] = theme('grid_row', $variables['sidebar_last'], 'sidebar-last', 'nested', $variables['sidebar_last_width']);
    $variables['pre_postscript_top'] = theme('grid_row', $variables['postscript_top'], 'postscript-top', 'nested');
    $variables['pre_postscript_bottom'] = theme('grid_row', $variables['postscript_bottom'], 'postscript-bottom', 'full-width', $variables['grid_width']);
    $variables['pre_footer'] = theme('grid_row', $variables['footer'] . $variables['footer_message'], 'footer', 'full-width', $variables['grid_width']);
    //show group description if group node present
    if (isset($variables['node'])) {
        $node = $variables['node'];
        if (og_is_group_type($node->type)) {
            $variables['group_header_image'] = content_format('field_group_image', $node->field_group_image[0], 'user_picture_meta_default');
            if (!empty($node->body)) {
                $variables['group_header_text'] = check_markup($node->body, $node->format);
            } else {
                $variables['group_header_text'] = check_plain($node->og_description);
            }
        }
    }
}
Example #3
0
 function get_all_like($id)
 {
     $sql = "SELECT ext.id,ext.identifier,ext.form_type,extc.content,ext.ext,ext.module FROM " . $this->db->prefix . "ext ext ";
     $sql .= "JOIN " . $this->db->prefix . "extc extc ON(ext.id=extc.id) ";
     $sql .= "WHERE ext.module LIKE '" . $id . "%' ORDER BY ext.taxis ASC,ext.id DESC";
     $rslist = $this->db->get_all($sql);
     if (!$rslist) {
         return false;
     }
     $list = false;
     foreach ($rslist as $key => $value) {
         $list[$value["module"]][$value["identifier"]] = content_format($value);
     }
     return $list;
 }
        if ($link['nid']) {
            ?>
           <li class="internal_link"><?php 
            print content_format('field_internal_link', $link);
            ?>
</li>
       <?php 
        }
    }
    ?>
       <?php 
    foreach ($field_useful_link as $link) {
        if ($link['url']) {
            ?>
           <li class="external_link"><?php 
            print content_format('field_useful_link', $link);
            ?>
</li>
        <?php 
        }
    }
    ?>
      
      </ul>
    </div>
    <?php 
}
?>
    
    <?php 
if ($page && $glossary_terms) {
Example #5
0
function phpok_ext_list($mid, $tid = 0)
{
    if (!$mid || !$tid) {
        return false;
    }
    $GLOBALS['app']->model("module");
    $rslist = $GLOBALS['app']->model('module')->fields_all($mid, "identifier");
    if (!$rslist) {
        return false;
    }
    $idlist = array_keys($rslist);
    $GLOBALS['app']->model("list");
    $infolist = $GLOBALS['app']->model('list')->get_ext_list($mid, $tid);
    if (!$infolist) {
        $infolist = array();
    }
    foreach ($idlist as $key => $value) {
        foreach ($infolist as $k => $v) {
            unset($v["site_id"], $v["project_id"], $v["cate_id"], $v["id"]);
            if ($v[$value]) {
                $tmp = $rslist[$value];
                $tmp["content"] = $v[$value];
                $v[$value] = content_format($tmp);
            }
            $infolist[$k] = $v;
        }
    }
    return $infolist;
}
Example #6
0
/**
 * Define the behavior of a field type.
 *
 * @param $op
 *   What kind of action is being performed. Possible values:
 *   - "load": The node is about to be loaded from the database. This hook
 *     should be used to load the field.
 *   - "view": The node is about to be presented to the user. The module
 *     should prepare and return an HTML string containing a default
 *     representation of the field.
 *     It will be called only if 'view' was set to TRUE in hook_field_settings('callbacks')
 *   - "validate": The user has just finished editing the node and is
 *     trying to preview or submit it. This hook can be used to check or
 *     even modify the node. Errors should be set with form_set_error().
 *   - "submit": The user has just finished editing the node and the node has
 *     passed validation. This hook can be used to modify the node.
 *   - "insert": The node is being created (inserted in the database).
 *   - "update": The node is being updated.
 *   - "delete": The node is being deleted.
 * @param &$node
 *   The node the action is being performed on. This argument is passed by
 *   reference for performance only; do not modify it.
 * @param $field
 *   The field the action is being performed on.
 * @param &$node_field
 *   The contents of the field in this node. Changes to this variable will
 *   be saved back to the node object.
 * @return
 *   This varies depending on the operation.
 *   - The "load" operation should return an object containing extra values
 *     to be merged into the node object.
 *   - The "view" operation should return a string containing an HTML
 *     representation of the field data.
 *   - The "insert", "update", "delete", "validate", and "submit" operations
 *     have no return value.
 *
 * In most cases, only "validate" operations is relevant ; the rest
 * have default implementations in content_field() that usually suffice.
 */
function hook_field($op, &$node, $field, &$node_field, $teaser, $page)
{
    switch ($op) {
        case 'view':
            $context = $teaser ? 'teaser' : 'full';
            $formatter = isset($field['display_settings'][$context]['format']) ? $field['display_settings'][$context]['format'] : 'default';
            $items = array();
            foreach ($node_field as $delta => $item) {
                $items[$delta]['view'] = content_format($field, $item, $formatter, $node);
            }
            return theme('field', $node, $field, $items, $teaser, $page);
        case 'validate':
            $allowed_values = text_allowed_values($field);
            if (is_array($items)) {
                foreach ($items as $delta => $item) {
                    $error_field = $field['field_name'] . '][' . $delta . '][value';
                    if ($item['value'] != '') {
                        if (count($allowed_values) && !array_key_exists($item['value'], $allowed_values)) {
                            form_set_error($error_field, t('Illegal value for %name.', array('%name' => t($field['widget']['label']))));
                        }
                    }
                }
            }
            break;
    }
}