示例#1
0
 /**
  * Copy all layout data from one layout to another by ID
  * @param  integer $from_layout_id source layout ID
  * @param  integer $to_layout_id   target layout ID
  * @return boolean true on success, false - otherwise
  */
 public function copyById($from_layout_id, $to_layout_id)
 {
     $from_layout = $this->get($from_layout_id);
     if (empty($from_layout)) {
         return false;
     }
     $object_ids = array();
     $location = Location::instance($from_layout_id)->copy($to_layout_id);
     $target_company_id = 0;
     if (fn_allowed_for('ULTIMATE')) {
         $target_company_id = db_get_field("SELECT company_id FROM ?:bm_layouts WHERE layout_id = ?i", $to_layout_id);
     }
     // Copy logos
     $types = fn_get_logo_types();
     foreach ($types as $type => $data) {
         if (!empty($data['for_layout'])) {
             $object_ids[$type] = fn_create_logo(array('type' => $type, 'layout_id' => $to_layout_id), $target_company_id);
         }
     }
     $logo_ids = db_get_hash_single_array("SELECT logo_id, type FROM ?:logos WHERE layout_id = ?i AND type IN (?a)", array('type', 'logo_id'), $from_layout_id, array_keys($object_ids));
     foreach ($logo_ids as $type => $logo_id) {
         fn_clone_image_pairs($object_ids[$type], $logo_id, 'logos');
     }
     return true;
 }
示例#2
0
/**
 * Creates logotypes for companies and assign it to the layout
 *
 * @param int $layout_id Layout ID
 * @param int $company_id Company ID
 * @param bool $for_company Get logos only for companies
 * @return array created logo IDs
 */
function fn_create_theme_logos_by_layout_id($theme_name, $layout_id = 0, $company_id = 0, $for_company = false)
{
    $repo_dest = fn_get_theme_path('[themes]/' . $theme_name, 'C');
    $manifest = Themes::factory($theme_name)->getManifest();
    $logo_ids = array();
    $logo_types = fn_get_logo_types($for_company);
    Registry::set('runtime.allow_upload_external_paths', true);
    foreach ($logo_types as $type => $logo) {
        if (!$for_company) {
            $image_path = isset($manifest[$type]) ? $repo_dest . '/' . $manifest[$type] : '';
        } else {
            $image_path = '';
        }
        $logo_ids[$type] = fn_create_logo(array('type' => $type, 'layout_id' => !empty($logo['for_layout']) ? $layout_id : 0, 'image_path' => $image_path), $company_id);
    }
    Registry::set('runtime.allow_upload_external_paths', false);
    return $logo_ids;
}
示例#3
0
function fn_gift_certificates_install($d, $action)
{
    if ($action == 'install') {
        if (fn_allowed_for('ULTIMATE')) {
            $company_ids = fn_get_all_companies_ids();
        } else {
            $company_ids = array(0);
        }
        foreach ($company_ids as $company_id) {
            fn_create_logo(array('type' => 'gift_cert', 'image_path' => fn_get_theme_path('[themes]/[theme]/mail/media/', 'C', $company_id, false) . 'images/gift_cert_logo.png'), $company_id);
        }
    } else {
        fn_delete_logo('gift_cert');
    }
}
function fn_clone_layouts($data, $from, $to)
{
    // We need to clone logos, not attached to any layout too
    $logos = fn_get_logos($from, 0);
    if (!empty($logos)) {
        Registry::set('runtime.allow_upload_external_paths', true);
        foreach ($logos as $type => $logo) {
            fn_create_logo(array('type' => $logo['type'], 'layout_id' => $logo['layout_id'], 'image_path' => !empty($logo['image']['absolute_path']) ? $logo['image']['absolute_path'] : ''), $to);
        }
        Registry::set('runtime.allow_upload_external_paths', false);
    }
    return Layout::instance($from)->copy($to);
}