本文整理汇总了PHP中ca_sets::getSets方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_sets::getSets方法的具体用法?PHP ca_sets::getSets怎么用?PHP ca_sets::getSets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_sets
的用法示例。
在下文中一共展示了ca_sets::getSets方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
if (!$this->request->isLoggedIn()) {
$this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'form'));
return;
}
if (!($t_set = $this->_getSet())) {
$t_set = new ca_sets();
}
JavascriptLoadManager::register('sortableUI');
# --- get all sets for user
$va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'user_id' => $this->request->getUserID())));
$t_new_set = new ca_sets();
# --- new set object used for access drop down in new set form
$this->view->setVar('t_set', $t_set);
$this->view->setVar('t_new_set', $t_new_set);
$this->view->setVar('set_list', $va_sets);
$this->view->setVar('set_name', $t_set->getLabelForDisplay());
$this->view->setVar('set_description', $t_set->get("ca_sets.set_intro"));
$this->view->setVar('set_access', $t_set->get("ca_sets.access"));
if ($this->request->config->get("dont_enforce_access_settings")) {
$va_access_values = array();
} else {
$va_access_values = caGetUserAccessValues($this->request);
}
$this->view->setVar('items', caExtractValuesByUserLocale($t_set->getItems(array('thumbnailVersions' => array('thumbnail', 'icon'), 'checkAccess' => $va_access_values, 'user_id' => $this->request->getUserID()))));
$this->render('Sets/sets_html.php');
}
示例2: renderWidget
public function renderWidget($ps_widget_id, &$pa_settings)
{
parent::renderWidget($ps_widget_id, $pa_settings);
$this->opo_view->setVar('request', $this->getRequest());
$t_set = new ca_sets();
$va_tables = array("ca_objects", "ca_entities", "ca_places", "ca_object_lots", "ca_storage_locations", "ca_collections", "ca_occurrences");
$va_sets = array();
foreach ($va_tables as $vs_table) {
$va_sets[$vs_table][] = caExtractValuesByUserLocale($t_set->getSets(array('table' => $vs_table, 'user_id' => $this->request->getUserID())));
}
$this->opo_view->setVar("sets_by_table", $va_sets);
return $this->opo_view->render('main_html.php');
}
示例3: __call
/**
*
*/
public function __call($ps_function, $pa_args)
{
$ps_function = strtolower($ps_function);
# --- which type of set is configured for display in gallery section
$t_list = new ca_lists();
$vn_gallery_set_type_id = $t_list->getItemIDFromList('set_types', $this->config->get('gallery_set_type'));
$t_set = new ca_sets();
if ($ps_function == "index") {
if ($vn_gallery_set_type_id) {
$va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'checkAccess' => $this->opa_access_values, 'setType' => $vn_gallery_set_type_id)));
$va_set_first_items = $t_set->getFirstItemsFromSets(array_keys($va_sets), array("version" => "icon", "checkAccess" => $this->opa_access_values));
$o_front_config = caGetFrontConfig();
$vs_front_page_set = $o_front_config->get('front_page_set_code');
$vb_omit_front_page_set = (bool) $this->config->get('omit_front_page_set_from_gallery');
foreach ($va_sets as $vn_set_id => $va_set) {
if ($vb_omit_front_page_set && $va_set['set_code'] == $vs_front_page_set) {
unset($va_sets[$vn_set_id]);
}
}
$this->view->setVar('sets', $va_sets);
$this->view->setVar('first_items_from_sets', $va_set_first_items);
}
MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . ($this->config->get('gallery_section_name') ? $this->config->get('gallery_section_name') : _t("Gallery")));
$this->render("Gallery/index_html.php");
} else {
$ps_set_id = $ps_function;
$this->view->setVar("set_id", $ps_set_id);
$t_set->load($ps_set_id);
$this->view->setVar("set", $t_set);
$this->view->setVar("label", $t_set->getLabelForDisplay());
$this->view->setVar("description", $t_set->get($this->config->get('gallery_set_description_element_code')));
$this->view->setVar("set_items", caExtractValuesByUserLocale($t_set->getItems(array("thumbnailVersions" => array("icon", "iconlarge"), "checkAccess" => $this->opa_access_values))));
$pn_set_item_id = $this->request->getParameter('set_item_id', pInteger);
if (!in_array($pn_set_item_id, array_keys($t_set->getItemIDs()))) {
$pn_set_item_id = "";
}
$this->view->setVar("set_item_id", $pn_set_item_id);
MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . ($this->config->get('gallery_section_name') ? $this->config->get('gallery_section_name') : _t("Gallery")) . ": " . $t_set->getLabelForDisplay());
$this->render("Gallery/detail_html.php");
}
}
示例4: Index
public function Index()
{
JavascriptLoadManager::register('imageScroller');
$va_access_values = caGetUserAccessValues($this->request);
// get sets for public display
$t_list = new ca_lists();
$vn_public_set_type_id = $t_list->getItemIDFromList('set_types', $t_list->getAppConfig()->get('features_set_type'));
// get value for public access status value
$va_tmp = $t_list->getItemFromList('access_statuses', 'public_access');
$vn_public_access = $va_tmp['item_value'];
$t_set = new ca_sets();
$va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'checkAccess' => $va_access_values, 'setType' => $vn_public_set_type_id)));
$va_set_ids = array();
foreach ($va_sets as $va_set) {
$va_set_ids[] = $va_set['set_id'];
}
$this->view->setVar('sets', $va_sets);
$this->view->setVar('set_ids', $va_set_ids);
$this->view->setVar('set_display_items', ca_sets::getFirstItemsFromSets($va_set_ids, array("version" => "preview160")));
$this->render('features_landing_html.php');
}
示例5: getSets
/**
* Gets list of all sets
*
* @return array
* @throws SoapFault
*/
public function getSets()
{
$t_set = new ca_sets();
return $t_set->getSets(array('user_id' => $this->opo_request->getUserID()));
}
示例6: caGetClientServicesConfiguration
$o_client_services_config = caGetClientServicesConfiguration();
if ($vb_client_services && (bool) $o_client_services_config->get('enable_user_communication')) {
//
// Unread client communications
//
$t_comm = new ca_commerce_communications();
$va_unread_messages = $t_comm->getMessages(array('unreadOnly' => true, 'user_id' => $this->request->getUserID()));
$va_message_set_ids = array();
foreach ($va_unread_messages as $vn_transaction_id => $va_messages) {
$va_message_set_ids[] = $va_messages[0]['set_id'];
}
}
if (!$this->request->config->get('disable_my_collections')) {
# --- get all sets for user
$t_set = new ca_sets();
$va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'user_id' => $this->request->getUserID())));
if (is_array($va_sets) && sizeof($va_sets) > 1) {
print "<div id='lightboxLink'>\n\t\t\t\t\t\t\t\t\t\t<a href='#' onclick='\$(\"#lightboxList\").toggle(0, function(){\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(\$(\"#lightboxLink\").hasClass(\"lightboxLinkActive\")) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$(\"#lightboxLink\").removeClass(\"lightboxLinkActive\");\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$(\"#lightboxLink\").addClass(\"lightboxLinkActive\");\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});')>Lightbox</a>";
if (is_array($va_message_set_ids) && sizeof($va_message_set_ids)) {
print " <img src='" . $this->request->getThemeUrlPath() . "/graphics/icons/envelope.gif' border='0'>";
}
print "<div id='lightboxList'><b>" . _t("your lightboxes") . ":</b><br/>";
foreach ($va_sets as $va_set) {
print caNavLink($this->request, strlen($va_set["name"]) > 30 ? substr($va_set["name"], 0, 30) . "..." : $va_set["name"], "", "", "Sets", "Index", array("set_id" => $va_set["set_id"]));
if ($vb_client_services && is_array($va_message_set_ids) && in_array($va_set["set_id"], $va_message_set_ids)) {
print " <img src='" . $this->request->getThemeUrlPath() . "/graphics/icons/envelope.gif' border='0'>";
}
print "<br/>";
}
print "</div>";
print "</div>";
示例7: Tools
/**
* Set up variables for "tools" widget
*/
public function Tools($pa_parameters)
{
if (!($vn_items_per_page = $this->opo_result_context->getItemsPerPage())) {
$vn_items_per_page = $this->opa_items_per_page[0];
}
if (!($vs_view = $this->opo_result_context->getCurrentView())) {
$va_tmp = array_keys($this->opa_views);
$vs_view = array_shift($va_tmp);
}
if (!($vs_sort = $this->opo_result_context->getCurrentSort())) {
$va_tmp = array_keys($this->opa_sorts);
$vs_sort = array_shift($va_tmp);
}
$this->view->setVar('views', $this->opa_views);
// pass view list to view for rendering
$this->view->setVar('current_view', $vs_view);
$vn_type_id = $this->opo_result_context->getTypeRestriction($vb_dummy);
$va_sortable_elements = ca_metadata_elements::getSortableElements($this->ops_tablename, $vn_type_id);
if (!is_array($this->opa_sorts)) {
$this->opa_sorts = array();
}
foreach ($va_sortable_elements as $vn_element_id => $va_sortable_element) {
$this->opa_sorts[$this->ops_tablename . '.' . $va_sortable_element['element_code']] = $va_sortable_element['display_label'];
}
$this->view->setVar('sorts', $this->opa_sorts);
// pass sort list to view for rendering
$this->view->setVar('current_sort', $vs_sort);
$this->view->setVar('items_per_page', $this->opa_items_per_page);
$this->view->setVar('current_items_per_page', $vn_items_per_page);
//
// Available sets
//
$t_set = new ca_sets();
$this->view->setVar('available_sets', caExtractValuesByUserLocale($t_set->getSets(array('table' => $this->ops_tablename, 'user_id' => $this->request->getUserID()))));
$this->view->setVar('last_search', $this->opo_result_context->getSearchExpression());
$this->view->setVar('result_context', $this->opo_result_context);
$va_results_id_list = $this->opo_result_context->getResultList();
$this->view->setVar('result', is_array($va_results_id_list) && sizeof($va_results_id_list) > 0 ? caMakeSearchResult($this->ops_tablename, $va_results_id_list) : null);
$t_model = $this->opo_datamodel->getInstanceByTableName($this->ops_tablename, true);
$this->view->setVar('t_subject', $t_model);
}
示例8: displaySet
public function displaySet()
{
# --- set info
$pn_set_id = $this->request->getParameter('set_id', pInteger);
$t_set = new ca_sets($pn_set_id);
$va_access_values = caGetUserAccessValues($this->request);
# Enforce access control
if (sizeof($va_access_values) && !in_array($t_set->get("access"), $va_access_values)) {
$this->notification->addNotification(_t("This set is not available for view"), "message");
$this->response->setRedirect(caNavUrl($this->request, "", "", "", ""));
return;
}
$this->view->setVar('t_set', $t_set);
$va_items = caExtractValuesByUserLocale($t_set->getItems(array('thumbnailVersions' => array('widepreview', 'medium', 'setimage'), "checkAccess" => $va_access_values)));
$this->view->setVar('items', $va_items);
$va_row_ids = array();
foreach ($va_items as $vn_item_id => $va_item_info) {
$va_row_ids[] = $va_item_info['row_id'];
}
# --- all featured sets - for display in right hand column
// get sets for public display
$t_list = new ca_lists();
$vn_public_set_type_id = $t_list->getItemIDFromList('set_types', $t_list->getAppConfig()->get('simpleGallery_set_type'));
$t_set = new ca_sets($pn_set_id);
$va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'checkAccess' => $va_access_values, 'setType' => $vn_public_set_type_id)));
$va_set_first_items = array();
$va_set_first_items = $t_set->getFirstItemsFromSets(array_keys($va_sets), array("version" => "icon", "checkAccess" => $va_access_values));
$this->view->setVar('sets', $va_sets);
$this->view->setVar('first_items_from_sets', $va_set_first_items);
$this->view->setVar('set_title', $t_set->getLabelForDisplay());
$this->view->setVar('set_description', $t_set->get($this->opo_plugin_config->get('set_description_element_code'), array('convertLinkBreaks' => true)));
// Needed to figure out what result context to use on details
$this->opo_result_context->setParameter('set_id', $pn_set_id);
$this->opo_result_context->setResultList($va_row_ids);
$this->opo_result_context->setAsLastFind();
$this->opo_result_context->saveContext();
$this->render($this->ops_theme . '/set_info_html.php');
}
示例9: Info
/**
*
*/
public function Info()
{
$t_set = new ca_sets($vn_set_id = $this->request->getParameter('set_id', pInteger));
$vn_user_id = !(bool) $this->request->config->get('ca_sets_all_users_see_all_sets') ? $this->request->getUserID() : null;
$va_set_stats = array('mine' => caExtractValuesByUserLocale($t_set->getSets(array('user_id' => $this->request->getUserID(), 'access' => __CA_SET_EDIT_ACCESS__)), null, null, array()));
if ($this->request->user->canDoAction('is_administrator') || $this->request->user->canDoAction('can_administrate_sets')) {
$va_set_stats['user'] = caExtractValuesByUserLocale($t_set->getSets(array('user_id' => $vn_user_id, 'allUsers' => true)), null, null, array());
$va_set_stats['public'] = caExtractValuesByUserLocale($t_set->getSets(array('user_id' => $vn_user_id, 'publicUsers' => true)), null, null, array());
}
$o_result_context = new ResultContext($this->request, 'ca_sets', 'basic_search');
$pn_mode = (int) $o_result_context->getParameter('set_display_mode');
$this->view->setVar('mode', $pn_mode);
$this->view->setVar('sets', $va_set_stats);
return $this->render('widget_set_info_html.php', true);
}
示例10: array
if ($t_collection->get("access") == 1) {
$va_most_popular_collections[$vn_fav_collection_id] = $t_collection->getLabelForDisplay();
}
}
}
# - get staff picks sets
// get sets for public display
$t_list = new ca_lists();
$vn_public_set_type_id = $t_list->getItemIDFromList('set_types', 'Staff Pick');
// get value for public access status value
$va_tmp = $t_list->getItemFromList('access_statuses', 'public_access');
$vn_public_access = $va_tmp['item_value'];
$t_set = new ca_sets();
$va_staff_picks_sets = array();
#$va_staff_picks_sets = caExtractValuesByUserLocale($t_set->getSets('ca_collections', null, $va_access_values, null, $vn_public_set_type_id));
$va_staff_picks_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_collections', 'checkAccess' => $va_access_values, "setType" => $vn_public_set_type_id)));
if (is_array($va_most_popular_collections) && sizeof($va_most_popular_collections) > 0) {
?>
<div class="unit">
<div class="heading">Most Popular Collections:</div>
<ul class="crossList">
<?php
foreach ($va_most_popular_collections as $vn_pop_coll_id => $vs_pop_coll) {
print "<li>" . caNavLink($this->request, $vs_pop_coll, '', 'Detail', 'Collection', 'Show', array('collection_id' => $vn_pop_coll_id)) . "</li>";
}
?>
</ul>
</div><!-- end unit -->
<?php
}
示例11: Index
/**
*
*/
function Index()
{
if (!$this->request->isLoggedIn()) {
$this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'form'));
return;
}
if (!($t_set = $this->_getSet(__CA_SET_READ_ACCESS__))) {
$t_set = new ca_sets();
}
JavascriptLoadManager::register('sortableUI');
# --- get all sets for user
$va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'user_id' => $this->request->getUserID())));
if (sizeof($va_sets) == 0) {
# --- if there are not any sets for this user, make a new set for them
$t_new_set = new ca_sets();
$vn_new_set_id = null;
$t_new_set->setMode(ACCESS_WRITE);
$t_new_set->set('access', 0);
$t_new_set->set('table_num', 57);
// 57=ca_objects
$t_list = new ca_lists();
$vn_set_id = $t_list->getItemIDFromList('set_types', $this->request->config->get('user_set_type'));
$t_new_set->set('type_id', $vn_set_id);
$t_new_set->set('user_id', $this->request->getUserID());
$t_new_set->set('set_code', $this->request->getUserID() . '_' . time());
$t_new_set->insert();
if (!$t_new_set->numErrors()) {
if ($vn_new_set_id = $t_new_set->getPrimaryKey()) {
global $g_ui_locale_id;
// current locale_id for user
$t_new_set->addLabel(array('name' => _t("Your first lightbox")), $g_ui_locale_id, null, true);
// select the current set
$this->request->user->setVar('current_set_id', $vn_new_set_id);
# --- load new set
$t_set = new ca_sets($vn_new_set_id);
# --- get the sets again so the new set is included
$va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'user_id' => $this->request->getUserID())));
}
}
}
$t_new_set = new ca_sets();
# --- new set object used for access drop down in new set form
$this->view->setVar('t_set', $t_set);
$this->view->setVar('t_new_set', $t_new_set);
$this->view->setVar('set_list', $va_sets);
$this->view->setVar('set_name', $t_set->getLabelForDisplay());
$this->view->setVar('set_description', $t_set->get("ca_sets.set_intro"));
$this->view->setVar('set_access', $t_set->get("ca_sets.access"));
if ($this->request->config->get("dont_enforce_access_settings")) {
$va_access_values = array();
} else {
$va_access_values = caGetUserAccessValues($this->request);
}
$this->view->setVar('items', $va_items = caExtractValuesByUserLocale($t_set->getItems(array('thumbnailVersions' => array('thumbnail', 'icon'), 'checkAccess' => $va_access_values, 'user_id' => $this->request->getUserID()))));
$va_found_item_ids = array();
foreach ($va_items as $vn_i => $va_item) {
$va_found_item_ids[] = $va_item['row_id'];
}
$t_trans = new ca_commerce_transactions();
$t_trans->load(array('set_id' => $t_set->getPrimaryKey()));
$vn_transaction_id = $t_trans->getPrimaryKey();
$t_comm = new ca_commerce_communications();
$this->view->setVar('messages', $t_comm->getMessages($this->request->getUserID(), array('transaction_id' => $vn_transaction_id)));
$opo_result_context = new ResultContext($this->request, 'ca_objects', 'sets');
$opo_result_context->setResultList($va_found_item_ids);
$opo_result_context->setAsLastFind();
$opo_result_context->saveContext();
# --- use a different view if client services is enabled
if ($this->request->config->get("enable_client_services")) {
$this->render('Sets/client_services_html.php');
} else {
$this->render('Sets/sets_html.php');
}
}
示例12: importMediaFromDirectory
/**
* @param RequestHTTP $po_request
* @param null|array $pa_options
* progressCallback =
* reportCallback =
* sendMail =
* log = log directory path
* logLevel = KLogger constant for minimum log level to record. Default is KLogger::INFO. Constants are, in descending order of shrillness:
* KLogger::EMERG = Emergency messages (system is unusable)
* KLogger::ALERT = Alert messages (action must be taken immediately)
* KLogger::CRIT = Critical conditions
* KLogger::ERR = Error conditions
* KLogger::WARN = Warnings
* KLogger::NOTICE = Notices (normal but significant conditions)
* KLogger::INFO = Informational messages
* KLogger::DEBUG = Debugging messages
* @return array
*/
public static function importMediaFromDirectory($po_request, $pa_options = null)
{
global $g_ui_locale_id;
$vs_log_dir = caGetOption('log', $pa_options, __CA_APP_DIR__ . "/log");
$vs_log_level = caGetOption('logLevel', $pa_options, "INFO");
if (!is_writeable($vs_log_dir)) {
$vs_log_dir = caGetTempDirPath();
}
$vn_log_level = BatchProcessor::_logLevelStringToNumber($vs_log_level);
$o_log = new KLogger($vs_log_dir, $vn_log_level);
$vs_import_target = caGetOption('importTarget', $pa_options, 'ca_objects');
$t_instance = $po_request->getAppDatamodel()->getInstance($vs_import_target);
$o_eventlog = new Eventlog();
$t_set = new ca_sets();
$va_notices = $va_errors = array();
$vb_we_set_transaction = false;
$o_trans = isset($pa_options['transaction']) && $pa_options['transaction'] ? $pa_options['transaction'] : null;
if (!$o_trans) {
$vb_we_set_transaction = true;
$o_trans = new Transaction($t_set->getDb());
}
$o_batch_log = new Batchlog(array('user_id' => $po_request->getUserID(), 'batch_type' => 'MI', 'table_num' => (int) $t_instance->tableNum(), 'notes' => '', 'transaction' => $o_trans));
if (!is_dir($pa_options['importFromDirectory'])) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => $vs_msg = _t("Specified import directory '%1' is invalid", $pa_options['importFromDirectory'])));
$o_log->logError($vs_msg);
return null;
}
$vs_batch_media_import_root_directory = $po_request->config->get('batch_media_import_root_directory');
if (!preg_match("!^{$vs_batch_media_import_root_directory}!", $pa_options['importFromDirectory'])) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => $vs_msg = _t("Specified import directory '%1' is invalid", $pa_options['importFromDirectory'])));
$o_log->logError($vs_msg);
return null;
}
if (preg_match("!\\.\\./!", $pa_options['importFromDirectory'])) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => $vs_msg = _t("Specified import directory '%1' is invalid", $pa_options['importFromDirectory'])));
$o_log->logError($vs_msg);
return null;
}
$vb_include_subdirectories = (bool) $pa_options['includeSubDirectories'];
$vb_delete_media_on_import = (bool) $pa_options['deleteMediaOnImport'];
$vs_import_mode = $pa_options['importMode'];
$vs_match_mode = $pa_options['matchMode'];
$vn_type_id = $pa_options[$vs_import_target . '_type_id'];
$vn_rep_type_id = $pa_options['ca_object_representations_type_id'];
$va_limit_matching_to_type_ids = $pa_options[$vs_import_target . '_limit_matching_to_type_ids'];
$vn_access = $pa_options[$vs_import_target . '_access'];
$vn_object_representation_access = $pa_options['ca_object_representations_access'];
$vn_status = $pa_options[$vs_import_target . '_status'];
$vn_object_representation_status = $pa_options['ca_object_representations_status'];
$vn_rel_type_id = isset($pa_options[$vs_import_target . '_representation_relationship_type']) ? $pa_options[$vs_import_target . '_representation_relationship_type'] : null;
$vn_mapping_id = $pa_options[$vs_import_target . '_mapping_id'];
$vn_object_representation_mapping_id = $pa_options['ca_object_representations_mapping_id'];
$vs_idno_mode = $pa_options['idnoMode'];
$vs_idno = $pa_options['idno'];
$vs_representation_idno_mode = $pa_options['representationIdnoMode'];
$vs_representation_idno = $pa_options['representation_idno'];
$vs_set_mode = $pa_options['setMode'];
$vs_set_create_name = $pa_options['setCreateName'];
$vn_set_id = $pa_options['set_id'];
$vn_locale_id = $pa_options['locale_id'];
$vs_skip_file_list = $pa_options['skipFileList'];
$vs_skip_file_list = $pa_options['skipFileList'];
$vb_allow_duplicate_media = $pa_options['allowDuplicateMedia'];
$va_relationship_type_id_for = array();
if (is_array($va_create_relationship_for = $pa_options['create_relationship_for'])) {
foreach ($va_create_relationship_for as $vs_rel_table) {
$va_relationship_type_id_for[$vs_rel_table] = $pa_options['relationship_type_id_for_' . $vs_rel_table];
}
}
if (!$vn_locale_id) {
$vn_locale_id = $g_ui_locale_id;
}
$va_files_to_process = caGetDirectoryContentsAsList($pa_options['importFromDirectory'], $vb_include_subdirectories);
$o_log->logInfo(_t('Found %1 files in directory \'%2\'', sizeof($va_files_to_process), $pa_options['importFromDirectory']));
if ($vs_set_mode == 'add') {
$t_set->load($vn_set_id);
} else {
if ($vs_set_mode == 'create' && $vs_set_create_name) {
$va_set_ids = $t_set->getSets(array('user_id' => $po_request->getUserID(), 'table' => $t_instance->tableName(), 'access' => __CA_SET_EDIT_ACCESS__, 'setIDsOnly' => true, 'name' => $vs_set_create_name));
$vn_set_id = null;
if (is_array($va_set_ids) && sizeof($va_set_ids) > 0) {
$vn_possible_set_id = array_shift($va_set_ids);
//.........这里部分代码省略.........
示例13: importMediaFromDirectory
/**
* @param array $pa_options
* progressCallback =
* reportCallback =
* sendMail =
*/
public static function importMediaFromDirectory($po_request, $pa_options = null)
{
global $g_ui_locale_id;
$t_object = new ca_objects();
$o_eventlog = new Eventlog();
$t_set = new ca_sets();
$va_notices = $va_errors = array();
$vb_we_set_transaction = false;
$o_trans = isset($pa_options['transaction']) && $pa_options['transaction'] ? $pa_options['transaction'] : null;
if (!$o_trans) {
$vb_we_set_transaction = true;
$o_trans = new Transaction();
}
$o_log = new Batchlog(array('user_id' => $po_request->getUserID(), 'batch_type' => 'MI', 'table_num' => (int) $t_object->tableNum(), 'notes' => '', 'transaction' => $o_trans));
if (!is_dir($pa_options['importFromDirectory'])) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => "Specified import directory is invalid"));
return null;
}
$vs_batch_media_import_root_directory = $po_request->config->get('batch_media_import_root_directory');
if (!preg_match("!^{$vs_batch_media_import_root_directory}!", $pa_options['importFromDirectory'])) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => "Specified import directory is invalid"));
return null;
}
if (preg_match("!/\\.\\.!", $vs_directory) || preg_match("!\\.\\./!", $pa_options['importFromDirectory'])) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => "Specified import directory is invalid"));
return null;
}
$vb_include_subdirectories = (bool) $pa_options['includeSubDirectories'];
$vb_delete_media_on_import = (bool) $pa_options['deleteMediaOnImport'];
$vs_import_mode = $pa_options['importMode'];
$vs_match_mode = $pa_options['matchMode'];
$vn_object_type_id = $pa_options['ca_objects_type_id'];
$vn_rep_type_id = $pa_options['ca_object_representations_type_id'];
$vn_object_access = $pa_options['ca_objects_access'];
$vn_object_representation_access = $pa_options['ca_object_representations_access'];
$vn_object_status = $pa_options['ca_objects_status'];
$vn_object_representation_status = $pa_options['ca_object_representations_status'];
$vs_idno_mode = $pa_options['idnoMode'];
$vs_idno = $pa_options['idno'];
$vs_set_mode = $pa_options['setMode'];
$vs_set_create_name = $pa_options['setCreateName'];
$vn_set_id = $pa_options['set_id'];
$vn_locale_id = $pa_options['locale_id'];
$vs_skip_file_list = $pa_options['skipFileList'];
$va_relationship_type_id_for = array();
if (is_array($va_create_relationship_for = $pa_options['create_relationship_for'])) {
foreach ($va_create_relationship_for as $vs_rel_table) {
$va_relationship_type_id_for[$vs_rel_table] = $pa_options['relationship_type_id_for_' . $vs_rel_table];
}
}
if (!$vn_locale_id) {
$vn_locale_id = $g_ui_locale_id;
}
$va_files_to_process = caGetDirectoryContentsAsList($pa_options['importFromDirectory'], $vb_include_subdirectories);
if ($vs_set_mode == 'add') {
$t_set->load($vn_set_id);
} else {
if ($vs_set_mode == 'create' && $vs_set_create_name) {
$va_set_ids = $t_set->getSets(array('user_id' => $po_request->getUserID(), 'table' => 'ca_objects', 'access' => __CA_SET_EDIT_ACCESS__, 'setIDsOnly' => true, 'name' => $vs_set_create_name));
$vn_set_id = null;
if (is_array($va_set_ids) && sizeof($va_set_ids) > 0) {
$vn_possible_set_id = array_shift($va_set_ids);
if ($t_set->load($vn_possible_set_id)) {
$vn_set_id = $t_set->getPrimaryKey();
}
} else {
$vs_set_code = mb_substr(preg_replace("![^A-Za-z0-9_\\-]+!", "_", $vs_set_create_name), 0, 100);
if ($t_set->load(array('set_code' => $vs_set_code))) {
$vn_set_id = $t_set->getPrimaryKey();
}
}
if (!$t_set->getPrimaryKey()) {
$t_set->setMode(ACCESS_WRITE);
$t_set->set('user_id', $po_request->getUserID());
$t_set->set('type_id', $po_request->config->get('ca_sets_default_type'));
$t_set->set('table_num', $t_object->tableNum());
$t_set->set('set_code', $vs_set_code);
$t_set->insert();
if ($t_set->numErrors()) {
$va_notices['create_set'] = array('idno' => '', 'label' => _t('Create set %1', $vs_set_create_name), 'message' => _t('Failed to create set %1: %2', $vs_set_create_name, join("; ", $t_set->getErrors())), 'status' => 'SET ERROR');
} else {
$t_set->addLabel(array('name' => $vs_set_create_name), $vn_locale_id, null, true);
if ($t_set->numErrors()) {
$va_notices['add_set_label'] = array('idno' => '', 'label' => _t('Add label to set %1', $vs_set_create_name), 'message' => _t('Failed to add label to set: %1', join("; ", $t_set->getErrors())), 'status' => 'SET ERROR');
}
$vn_set_id = $t_set->getPrimaryKey();
}
}
} else {
$vn_set_id = null;
// no set
}
}
if ($t_set->getPrimaryKey() && !$t_set->haveAccessToSet($po_request->getUserID(), __CA_SET_EDIT_ACCESS__)) {
//.........这里部分代码省略.........
示例14: caGetGallerySetsAsList
/**
* class -> class name of <ul>
*
*/
function caGetGallerySetsAsList($po_request, $vs_class, $pa_options = null)
{
$o_config = caGetGalleryConfig();
$va_access_values = caGetUserAccessValues($po_request);
$t_list = new ca_lists();
$vn_gallery_set_type_id = $t_list->getItemIDFromList('set_types', $o_config->get('gallery_set_type'));
$vs_set_list = "";
if ($vn_gallery_set_type_id) {
$t_set = new ca_sets();
$va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'checkAccess' => $va_access_values, 'setType' => $vn_gallery_set_type_id)));
$vn_limit = caGetOption('limit', $pa_options, 100);
if (sizeof($va_sets)) {
$vs_set_list = "<ul" . ($vs_class ? " class='" . $vs_class . "'" : "") . ">\n";
$vn_c = 0;
foreach ($va_sets as $vn_set_id => $va_set) {
$vs_set_list .= "<li>" . caNavLink($po_request, $va_set["name"], "", "", "Gallery", $vn_set_id) . "</li>\n";
$vn_c++;
if ($vn_c >= $vn_limit) {
break;
}
}
$vs_set_list .= "</ul>\n";
}
}
return $vs_set_list;
}
示例15: Index
/**
* Generates a form for specification of media import settings. The form is rendered into the current view, inherited from ActionController
*
* @param array $pa_values An optional array of values to preset in the format, overriding any existing values in the model of the record being editing.
* @param array $pa_options Array of options passed through to _initView
*
*/
public function Index($pa_values = null, $pa_options = null)
{
AssetLoadManager::register("directoryBrowser");
list($t_ui) = $this->_initView($pa_options);
$this->view->setVar('batch_mediaimport_last_settings', $va_last_settings = is_array($va_last_settings = $this->request->user->getVar('batch_mediaimport_last_settings')) ? $va_last_settings : array());
// get import type from request
$vs_import_target = $this->getRequest()->getParameter('target', pString);
$t_instance = $this->getRequest()->getAppDatamodel()->getInstance($vs_import_target);
// if that failed, try last settings
if (!$t_instance) {
$vs_import_target = $va_last_settings['importTarget'];
$t_instance = $this->getRequest()->getAppDatamodel()->getInstance($vs_import_target);
}
// if that too failed, go back to objects
if (!$t_instance) {
$t_instance = new ca_objects();
$vs_import_target = 'ca_objects';
}
$this->getView()->setVar('import_target', $vs_import_target);
$t_instance->set('status', $va_last_settings[$vs_import_target . '_status']);
$t_instance->set('access', $va_last_settings[$vs_import_target . '_access']);
$t_rep = new ca_object_representations();
$t_rep->set('status', $va_last_settings['ca_object_representations_status']);
$t_rep->set('access', $va_last_settings['ca_object_representations_access']);
$va_nav = $t_ui->getScreensAsNavConfigFragment($this->request, null, $this->request->getModulePath(), $this->request->getController(), $this->request->getAction(), array(), array());
if (!$this->request->getActionExtra() || !isset($va_nav['fragment'][str_replace("Screen", "screen_", $this->request->getActionExtra())])) {
$this->request->setActionExtra($va_nav['defaultScreen']);
}
$this->view->setVar('t_ui', $t_ui);
$this->view->setVar('import_target', caHTMLSelect('import_target', $this->opa_importable_tables, array('id' => 'caImportTargetSelect', 'onchange' => 'window.location.replace("' . caNavUrl($this->getRequest(), $this->getRequest()->getModulePath(), $this->getRequest()->getController(), $this->getRequest()->getAction()) . '/target/" + jQuery("#caImportTargetSelect").val()); return false;'), array('value' => $vs_import_target)));
$this->view->setVar('import_mode', caHTMLSelect('import_mode', array(_t('Import all media, matching with existing records where possible') => 'TRY_TO_MATCH', _t('Import only media that can be matched with existing records') => 'ALWAYS_MATCH', _t('Import all media, creating new records for each') => 'DONT_MATCH'), array(), array('value' => $va_last_settings['importMode'])));
$this->view->setVar('match_mode', caHTMLSelect('match_mode', array(_t('Match using file name') => 'FILE_NAME', _t('Match using directory name') => 'DIRECTORY_NAME', _t('Match using directory name, then file name') => 'FILE_AND_DIRECTORY_NAMES'), array(), array('value' => $va_last_settings['matchMode'])));
$this->view->setVar('match_type', caHTMLSelect('match_type', array(_t('matches exactly') => 'EXACT', _t('starts with') => 'STARTS', _t('ends with') => 'ENDS', _t('contains') => 'CONTAINS'), array(), array('value' => $va_last_settings['matchType'])));
$this->view->setVar($vs_import_target . '_type_list', $t_instance->getTypeListAsHTMLFormElement($vs_import_target . '_type_id', null, array('value' => $va_last_settings[$vs_import_target . '_type_id'])));
$this->view->setVar($vs_import_target . '_limit_to_types_list', $t_instance->getTypeListAsHTMLFormElement($vs_import_target . '_limit_matching_to_type_ids[]', array('multiple' => 1), array('height' => '100px', 'values' => $va_last_settings[$vs_import_target . '_limit_matching_to_type_ids'])));
$this->view->setVar('ca_object_representations_type_list', $t_rep->getTypeListAsHTMLFormElement('ca_object_representations_type_id', null, array('value' => $va_last_settings['ca_object_representations_type_id'])));
if ($vs_import_target != 'ca_objects') {
// non-object representations have relationship types
$t_rel = ca_relationship_types::getRelationshipTypeInstance($t_instance->tableName(), 'ca_object_representations');
$this->getView()->setVar($vs_import_target . '_representation_relationship_type', $t_rel->getRelationshipTypesAsHTMLSelect('ltor', null, null, array('name' => $vs_import_target . '_representation_relationship_type'), array('value' => $va_last_settings[$vs_import_target . '_representation_relationship_type'])));
}
$va_importer_list = ca_data_importers::getImporters(null, array('formats' => array('exif')));
$va_object_importer_options = $va_object_representation_importer_options = array("-" => '');
foreach ($va_importer_list as $vn_importer_id => $va_importer_info) {
if ($va_importer_info['table_num'] == $t_instance->tableNum()) {
// target table
$va_object_importer_options[$va_importer_info['label']] = $vn_importer_id;
} else {
$va_object_representation_importer_options[$va_importer_info['label']] = $vn_importer_id;
}
}
$this->view->setVar($vs_import_target . '_mapping_list', caHTMLSelect($vs_import_target . '_mapping_id', $va_object_importer_options, array(), array('value' => $va_last_settings[$vs_import_target . '_mapping_id'])));
$this->view->setVar($vs_import_target . '_mapping_list_count', sizeof($va_object_importer_options));
$this->view->setVar('ca_object_representations_mapping_list', caHTMLSelect('ca_object_representations_mapping_id', $va_object_representation_importer_options, array(), array('value' => $va_last_settings['ca_object_representations_mapping_id'])));
$this->view->setVar('ca_object_representations_mapping_list_count', sizeof($va_object_representation_importer_options));
//
// Available sets
//
$t_set = new ca_sets();
$va_available_set_list = caExtractValuesByUserLocale($t_set->getSets(array('table' => $vs_import_target, 'user_id' => $this->request->getUserID(), 'access' => __CA_SET_EDIT_ACCESS__, 'omitCounts' => true)));
$va_available_sets = array();
foreach ($va_available_set_list as $vn_set_id => $va_set) {
$va_available_sets[$va_set['name']] = $vn_set_id;
}
$this->view->setVar('available_sets', $va_available_sets);
$this->view->setVar('t_instance', $t_instance);
$this->view->setVar('t_rep', $t_rep);
$this->render('mediaimport/import_options_html.php');
}