<?php

namespace Push\Lib;

use Dever;

class Manage
{
    //{source_id} > 0 ? ("{name}" ? "{name}" : Dever::load("sad/supply-one#name", {source_id})) : "{name}"
    public function col($id, $col = 'name')
    {
        $info = Dever::db('push/data')->one($id);

        if ($info[$col]) {
            return $info[$col];
        }

        if ($info['type'] < 10) {
            $table = Dever::config('base')->table_name[$info['type']];
            $id = str_replace('content/', '', $table) . '_id';
            $audit = array
            (
                'status' => 2,
                'state' => 1,
            );
            $audit['id'] = $info[$id];
            $data = Dever::db($table)->one($audit);

            if (isset($data) && $data && isset($data[$col])) {
                return $data[$col];
            }
        }

        return $info[$col];
    }
}