当前位置: 首页>>代码示例>>PHP>>正文


PHP BaseModel::getAppConfig方法代码示例

本文整理汇总了PHP中BaseModel::getAppConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseModel::getAppConfig方法的具体用法?PHP BaseModel::getAppConfig怎么用?PHP BaseModel::getAppConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BaseModel的用法示例。


在下文中一共展示了BaseModel::getAppConfig方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: caEmbedMetadataIntoRepresentation

/**
 * Embed XMP metadata into representation media. Embedding is performed on a copy of the representation media and placed
 * into the system tmp directory. The original media is never modified.
 *
 * @param BaseModel $po_object ca_objects instance to pull metadata from for embedding
 * @param BaseModel $po_representation ca_object_representations instance to pull metadata from for embedding
 * @param string $ps_version Version of media to embed into. If omitted "original" version is used.
 * @return string Path to copy of media with embedded metadata. False is returned in the embedding failed.
 */
function caEmbedMetadataIntoRepresentation($po_object, $po_representation, $ps_version = "original")
{
    if (!($vs_media_metadata_config = $po_representation->getAppConfig()->get('media_metadata'))) {
        return false;
    }
    $o_metadata_config = Configuration::load($vs_media_metadata_config);
    $vs_mimetype = $po_representation->getMediaInfo('media', $ps_version, 'MIMETYPE');
    if (!in_array($vs_mimetype, array('image/jpeg'))) {
        return false;
    }
    // Don't try to embed in files other than JPEGs
    $vs_filepath = $po_representation->getMediaPath('media', $ps_version);
    if (!file_exists($vs_filepath)) {
        return false;
    }
    $va_mappings = $o_metadata_config->getAssoc('export_mappings');
    $o_xmp = new XMPParser();
    copy($vs_filepath, $vs_tmp_filepath = caGetTempDirPath() . "/" . time() . md5($vs_filepath));
    $o_xmp->parse($vs_tmp_filepath);
    $o_xmp->initMetadata();
    if (is_object($po_object) && isset($va_mappings['ca_objects']) && is_array($va_mappings['ca_objects'])) {
        $va_mapping = $va_mappings['ca_objects'];
        $vs_type = $po_object->getTypeCode();
        if (isset($va_mapping[$vs_type]) && is_array($va_mapping[$vs_type])) {
            $va_mapping = $va_mapping[$vs_type];
        } else {
            if (isset($va_mapping['__default__']) && is_array($va_mapping['__default__'])) {
                $va_mapping = $va_mapping['__default__'];
            } else {
                return null;
            }
        }
        if (is_array($va_mapping)) {
            foreach ($va_mapping as $vs_xmp => $va_ca) {
                $va_tmp = explode(':', $vs_xmp);
                if (sizeof($va_tmp) > 1) {
                    $vs_xmp = $va_tmp[1];
                }
                foreach ($va_ca as $vs_ca => $va_opts) {
                    if (preg_match('!^static:!', $vs_ca)) {
                        $vs_val = preg_replace('!^static:!', '', $vs_ca);
                    } else {
                        $vs_val = $po_object->get($vs_ca, $va_opts);
                    }
                    if ($vs_val) {
                        $o_xmp->set($vs_xmp, $vs_val);
                    }
                }
            }
        }
    }
    if (is_object($po_representation) && isset($va_mappings['ca_object_representations']) && is_array($va_mappings['ca_object_representations'])) {
        $va_mapping = $va_mappings['ca_object_representations'];
        $vs_type = $po_representation->getTypeCode();
        if (isset($va_mapping[$vs_type]) && is_array($va_mapping[$vs_type])) {
            $va_mapping = $va_mapping[$vs_type];
        } else {
            if (isset($va_mapping['__default__']) && is_array($va_mapping['__default__'])) {
                $va_mapping = $va_mapping['__default__'];
            } else {
                return null;
            }
        }
        if (is_array($va_mapping)) {
            foreach ($va_mapping as $vs_xmp => $va_ca) {
                $va_tmp = explode(':', $vs_xmp);
                if (sizeof($va_tmp) > 1) {
                    $vs_xmp = $va_tmp[1];
                }
                foreach ($va_ca as $vs_ca => $va_opts) {
                    if (preg_match('!^static:!', $vs_ca)) {
                        $vs_val = preg_replace('!^static:!', '', $vs_ca);
                    } else {
                        $vs_val = $po_representation->get($vs_ca, $va_opts);
                    }
                    if ($vs_val) {
                        $o_xmp->set($vs_xmp, $vs_val);
                    }
                }
            }
        }
    }
    $o_xmp->write();
    return $vs_tmp_filepath;
}
开发者ID:idiscussforum,项目名称:providence,代码行数:94,代码来源:mediaPluginHelpers.php

示例2: caGetBundleDisplayTemplate

/**
 * 
 *
 * @param BaseModel $pt_subject 
 * @param string $ps_related_table
 * @param array $pa_bundle_settings 
 * @param array $pa_options Supported options are:
 *		
 *
 * @return string
 */
function caGetBundleDisplayTemplate($pt_subject, $ps_related_table, $pa_bundle_settings, $pa_options = null)
{
    $vs_template = null;
    if (strlen(trim($pa_bundle_settings['display_template']))) {
        $vs_template = trim($pa_bundle_settings['display_template']);
    }
    // If no display_template set try to get a default out of the app.conf file
    if (!$vs_template) {
        if (is_array($va_lookup_settings = $pt_subject->getAppConfig()->getList("{$ps_related_table}_lookup_settings"))) {
            if (!($vs_lookup_delimiter = $pt_subject->getAppConfig()->get("{$ps_related_table}_lookup_delimiter"))) {
                $vs_lookup_delimiter = '';
            }
            $vs_template = join($vs_lookup_delimiter, $va_lookup_settings);
        }
    }
    // If no app.conf default then just show preferred_labels
    if (!$vs_template) {
        $vs_template = "^preferred_labels";
    }
    return $vs_template;
}
开发者ID:kai-iak,项目名称:providence,代码行数:32,代码来源:displayHelpers.php

示例3: _checkAccess

 /**
  * Called just after record is deleted. Individual editor controllers can override this to implement their
  * own post-deletion cleanup logic.
  *
  * @param BaseModel $pt_subject Model instance of row that was deleted
  * @return bool True if post-deletion cleanup was successful, false if not
  */
 protected function _checkAccess($pt_subject, $pa_options = null)
 {
     //
     // Is record deleted?
     //
     if ($pt_subject->hasField('deleted') && $pt_subject->get('deleted')) {
         if (!caGetOption('dontRedirectOnDelete', $pa_options, false)) {
             $this->response->setRedirect($this->request->config->get('error_display_url') . '/n/2550?r=' . urlencode($this->request->getFullUrlPath()));
         }
         return false;
     }
     //
     // Is record of correct type?
     //
     $va_restrict_to_types = null;
     if ($pt_subject->getAppConfig()->get('perform_type_access_checking')) {
         $va_restrict_to_types = caGetTypeRestrictionsForUser($this->ops_table_name, array('access' => __CA_BUNDLE_ACCESS_READONLY__));
     }
     if (is_array($va_restrict_to_types) && ($pt_subject->get('type_id') && ($pt_subject->getPrimaryKey() && !in_array($pt_subject->get('type_id'), $va_restrict_to_types)))) {
         $this->response->setRedirect($this->request->config->get('error_display_url') . '/n/2560?r=' . urlencode($this->request->getFullUrlPath()));
         return false;
     }
     //
     // Is record from correct source?
     //
     $va_restrict_to_sources = null;
     if ($pt_subject->getAppConfig()->get('perform_source_access_checking') && $pt_subject->hasField('source_id')) {
         if (is_array($va_restrict_to_sources = caGetSourceRestrictionsForUser($this->ops_table_name, array('access' => __CA_BUNDLE_ACCESS_READONLY__)))) {
             if (!$pt_subject->get('source_id') || $pt_subject->get('source_id') && !in_array($pt_subject->get('source_id'), $va_restrict_to_sources) || strlen($vn_source_id = $this->request->getParameter('source_id', pInteger)) && !in_array($vn_source_id, $va_restrict_to_sources)) {
                 $pt_subject->set('source_id', $pt_subject->getDefaultSourceID(array('request' => $this->request)));
             }
             if (is_array($va_restrict_to_sources) && !in_array($pt_subject->get('source_id'), $va_restrict_to_sources)) {
                 $this->response->setRedirect($this->request->config->get('error_display_url') . '/n/2562?r=' . urlencode($this->request->getFullUrlPath()));
                 return;
             }
         }
     }
     //
     // Does user have access to row?
     //
     if ($pt_subject->getAppConfig()->get('perform_item_level_access_checking') && $vn_subject_id) {
         if ($pt_subject->checkACLAccessForUser($this->request->user) < __CA_BUNDLE_ACCESS_READONLY__) {
             $this->response->setRedirect($this->request->config->get('error_display_url') . '/n/2580?r=' . urlencode($this->request->getFullUrlPath()));
             return false;
         }
     }
     return true;
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:55,代码来源:BaseEditorController.php


注:本文中的BaseModel::getAppConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。