Ejemplo n.º 1
0
 /**
  * Performs an authentication attempt.
  *
  * @return Zend_Auth_Result The result of the authentication.
  */
 public function authenticate()
 {
     // Use the parent method to authenticate the user.
     $result = parent::authenticate();
     // Check if user actually authenticated.
     if ($result->isValid()) {
         if (get_option('central_auth_email')) {
             // If user matching is by email, create email address.
             $lookup = $this->getUsername() . '@' . get_option('central_auth_email_domain');
             // Lookup the user by their email address in the user table.
             $user = get_db()->getTable('User')->findByEmail($lookup);
         } else {
             // Otherwise use the username.
             $lookup = $this->getUsername();
             // Lookup the user by their username in the user table.
             $user = get_db()->getTable('User')->findBySql('username = ?', array($lookup), true);
         }
         // If the user was found and active, return success.
         if ($user && $user->active) {
             return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user->id);
         }
         // Return that the user does not have an active account.
         return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $lookup, array(__('User matching "%s" not found.', $lookup)));
     }
     // Otherwise, log messages to error log.
     $messages = $result->getMessages();
     _log('CentralAuth_LdapAdapter: ' . implode("\n", $messages), Zend_Log::ERR);
     // Return the parent's result with error message meant for user.
     return new Zend_Auth_Result($result->getCode(), $result->getIdentity(), array($messages[0]));
 }
Ejemplo n.º 2
0
function update_news_pos($pos)
{
    $db = get_db();
    $category = new category_class('news');
    if ($pos == 1) {
        $category_id = $category->find_by_name('富豪报道');
        $category_id = $category_id->id;
        $type = 'richindex_news_';
    } else {
        $category_id = $category->find_by_name('创富者说');
        $category_id = $category_id->id;
        $type = 'richindex_news1_';
    }
    $table = new table_class('fb_page_pos');
    $db->echo_sql = true;
    $items = $db->query("select id,title,created_at,description,author from fb_news where category_id={$category_id} order by created_at desc limit 6");
    $exist_items = $table->find('all', array('conditions' => "name like '{$type}%' and (end_time <= now() or end_time is null)", 'order' => "name"));
    $db->echo_sql = false;
    $len = empty($exist_items) ? 0 : count($exist_items);
    for ($i = 0; $i < $len; $i++) {
        $exist_items[$i]->display = $items[$i]->title;
        $exist_items[$i]->description = $items[$i]->description;
        $exist_items[$i]->href = dynamic_news_url($items[$i]);
        $exist_items[$i]->statci_href = static_news_url($items[$i]);
        $exist_items[$i]->title = $items[$i]->title;
        $exist_items[$i]->alias = $items[$i]->author;
        $exist_items[$i]->end_time = dt_increase(1, 'h', $exist_itmes->end_time);
        $exist_items[$i]->save();
    }
}
 public function itemGoogleMap($item = null, $width = '200px', $height = '200px', $hasBalloonForMarker = false, $markerHtmlClassName = 'geolocation_balloon')
 {
     $divId = "item-map-{$item->id}";
     $location = get_db()->getTable('Location')->findLocationByItem($item, true);
     // Only set the center of the map if this item actually has a location
     // associated with it
     if ($location) {
         $center['latitude'] = $location->latitude;
         $center['longitude'] = $location->longitude;
         $center['zoomLevel'] = $location->zoom_level;
         $center['show'] = true;
         if ($hasBalloonForMarker) {
             $titleLink = link_to_item(metadata($item, array('Dublin Core', 'Title'), array(), $item), array(), 'show', $item);
             $thumbnailLink = !item_image('thumbnail') ? '' : link_to_item(item_image('thumbnail', array(), 0, $item), array(), 'show', $item);
             $description = metadata($item, array('Dublin Core', 'Description'), array('snippet' => 150), $item);
             $center['markerHtml'] = '<div class="' . $markerHtmlClassName . '">' . '<div class="geolocation_balloon_title">' . $titleLink . '</div>' . '<div class="geolocation_balloon_thumbnail">' . $thumbnailLink . '</div>' . '<p class="geolocation_balloon_description">' . $description . '</p></div>';
         }
         $options = array();
         $options['mapType'] = get_option('geolocation_map_type');
         $center = js_escape($center);
         $options = js_escape($options);
         $style = "width: {$width}; height: {$height}";
         $html = '<div id="' . $divId . '" class="map geolocation-map" style="' . $style . '"></div>';
         $js = "var " . Inflector::variablize($divId) . ";";
         $js .= "OmekaMapSingle = new OmekaMapSingle(" . js_escape($divId) . ", {$center}, {$options}); ";
         $html .= "<script type='text/javascript'>{$js}</script>";
     } else {
         $html = '<p class="map-notification">' . __('This item has no location info associated with it.') . '</p>';
     }
     return $html;
 }
Ejemplo n.º 4
0
 /**
  * Initialize the form.
  */
 public function init()
 {
     parent::init();
     $this->_columnDelimiter = CsvImport_RowIterator::getDefaultColumnDelimiter();
     $this->_fileDelimiter = CsvImport_ColumnMap_File::getDefaultFileDelimiter();
     $this->_tagDelimiter = CsvImport_ColumnMap_Tag::getDefaultTagDelimiter();
     $this->_elementDelimiter = CsvImport_ColumnMap_Element::getDefaultElementDelimiter();
     $this->setAttrib('id', 'csvimport');
     $this->setMethod('post');
     $this->_addFileElement();
     $values = get_db()->getTable('ItemType')->findPairsForSelectForm();
     $values = array('' => __('Select Item Type')) + $values;
     $this->addElement('checkbox', 'omeka_csv_export', array('label' => __('Use an export from Omeka CSV Report'), 'description' => __('Selecting this will override the options below.')));
     $this->addElement('checkbox', 'automap_columns_names_to_elements', array('label' => __('Automap Column Names to Elements'), 'description' => __('Automatically maps columns to elements based on their column names. The column name must be in the form: <br/> {ElementSetName}:{ElementName}'), 'value' => true));
     $this->addElement('select', 'item_type_id', array('label' => __('Select Item Type'), 'multiOptions' => $values));
     $values = get_db()->getTable('Collection')->findPairsForSelectForm();
     $values = array('' => __('Select Collection')) + $values;
     $this->addElement('select', 'collection_id', array('label' => __('Select Collection'), 'multiOptions' => $values));
     $this->addElement('checkbox', 'items_are_public', array('label' => __('Make All Items Public?')));
     $this->addElement('checkbox', 'items_are_featured', array('label' => __('Feature All Items?')));
     $this->_addColumnDelimiterElement();
     $this->_addTagDelimiterElement();
     $this->_addFileDelimiterElement();
     $this->_addElementDelimiterElement();
     $this->applyOmekaStyles();
     $this->setAutoApplyOmekaStyles(false);
     $submit = $this->createElement('submit', 'submit', array('label' => __('Next'), 'class' => 'submit submit-medium'));
     $submit->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'csvimportnext'))));
     $this->addElement($submit);
 }
 /**
  * Set the filters pre-dispatch only on configured routes.
  * 
  * @param Zend_Controller_Request_Abstract
  */
 public function preDispatch($request)
 {
     $db = get_db();
     // Some routes don't have a default module, which resolves to NULL.
     $currentModule = is_null($request->getModuleName()) ? 'default' : $request->getModuleName();
     $currentController = $request->getControllerName();
     $currentAction = $request->getActionName();
     // Allow plugins to register routes that contain form inputs rendered by
     // Omeka_View_Helper_ElementForm::_displayFormInput().
     $routes = apply_filters('simple_vocab_routes', $this->_defaultRoutes);
     // Apply filters to defined routes.
     foreach ($routes as $route) {
         // Check registered routed against the current route.
         if ($route['module'] != $currentModule || $route['controller'] != $currentController || !in_array($currentAction, $route['actions'])) {
             continue;
         }
         // Add the filters if the current route is registered. Cache the
         // vocab terms for use by the filter callbacks.
         $select = $db->getTable('SimpleVocabTerm')->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns(array('element_id', 'terms'));
         $this->_simpleVocabTerms = $db->fetchPairs($select);
         foreach ($this->_simpleVocabTerms as $element_id => $terms) {
             $element = $db->getTable('Element')->find($element_id);
             $elementSet = $db->getTable('ElementSet')->find($element->element_set_id);
             add_filter(array('ElementInput', 'Item', $elementSet->name, $element->name), array($this, 'filterElementInput'));
         }
         // Once the filter is applied for one route there is no need to
         // continue looping the routes.
         break;
     }
 }
 public function hookConfigForm()
 {
     $table = get_db()->getTable('Element');
     $select = $table->getSelect()->order('elements.element_set_id')->order('ISNULL(elements.order)')->order('elements.order');
     $elements = $table->fetchObjects($select);
     include 'config-form.php';
 }
/**
 * Tests whether an item contains Fedora streams.
 *
 * @param Item $item The item.
 * @return bool Is the item a Fedora stream?
 * @author Eric Rochester <*****@*****.**>
 **/
function fc_isFedoraStream($item = null)
{
    $item = $item ? $item : get_current_record('item');
    $objects = get_db()->getTable('FedoraConnectorObject');
    $isStream = $item && $objects->findByItem($item);
    return $isStream;
}
 public function updateFromText($vocab_id, $text)
 {
     //set this to all rows
     $deleted = array();
     $added = array();
     $termObjs = $this->fetchObjects("Select `term` from omeka_svp_terms where vocab_id = " . $vocab_id);
     foreach ($termObjs as $termObj) {
         $deleted[] = trim($termObj['term']);
     }
     $terms = $this->_parseText($text);
     foreach ($terms as $term) {
         $i = array_search(trim($term), $deleted);
         if ($i !== false) {
             unset($deleted[$i]);
         } else {
             $added[] = $term;
         }
     }
     foreach ($deleted as $delete) {
         $sql = 'delete from omeka_svp_terms where vocab_id = "' . $vocab_id . '" and term = "' . trim($delete) . '"';
         //die($sql);
         get_db()->query($sql);
     }
     foreach ($added as $add) {
         $term = trim($term);
         $svpTerm = new SvpTerm();
         $svpTerm->vocab_id = $vocab_id;
         $svpTerm->term = $add;
         $svpTerm->save();
     }
     if (!empty($added) && !empty($deleted)) {
         return array('add' => array_values($added), 'delete' => array_values($deleted));
     }
     return false;
 }
 /**
  * Return the identifier of a record, if any. It can be sanitized.
  *
  * @param Omeka_Record_AbstractRecord|string $record
  * @param boolean $rawEncoded Sanitize the identifier for http or not.
  * @return string Identifier of the record, if any, else empty string.
  */
 public function getRecordIdentifier($record, $rawEncoded = true)
 {
     // Get the current record from the view if passed as a string.
     if (is_string($record)) {
         $record = $this->view->getCurrentRecord($record);
     }
     if (empty($record)) {
         return '';
     }
     if (!$record instanceof Omeka_Record_AbstractRecord) {
         throw new Omeka_View_Exception(__('Invalid record passed while getting record URL.'));
     }
     // Use a direct query in order to improve speed.
     $db = get_db();
     $elementId = (int) get_option('clean_url_identifier_element');
     $bind = array(get_class($record), $record->id);
     $prefix = get_option('clean_url_identifier_prefix');
     if ($prefix) {
         // Keep only the identifier without the configured prefix.
         $prefixLength = strlen($prefix) + 1;
         $sqlSelect = 'SELECT TRIM(SUBSTR(element_texts.text, ' . $prefixLength . '))';
         $sqlWhereText = 'AND element_texts.text LIKE ?';
         $bind[] = $prefix . '%';
     } else {
         $sqlSelect = 'SELECT element_texts.text';
         $sqlWhereText = '';
     }
     $sql = "\n            {$sqlSelect}\n            FROM {$db->ElementText} element_texts\n            WHERE element_texts.element_id = '{$elementId}'\n                AND element_texts.record_type = ?\n                AND element_texts.record_id = ?\n                {$sqlWhereText}\n            ORDER BY element_texts.id\n            LIMIT 1\n        ";
     $identifier = $db->fetchOne($sql, $bind);
     return $rawEncoded ? rawurlencode($identifier) : $identifier;
 }
Ejemplo n.º 10
0
 /**
  * Runs the delete import process.
  * 
  * @param array $args Required arguments to run the process.
  */
 public function run($args)
 {
     ini_set('memory_limit', '500M');
     $this->_db = get_db();
     $this->_processId = $args['processId'];
     $this->_deleteImport();
 }
 public function getComments($options = array(), $record_id = null, $record_type = null)
 {
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $params = $request->getParams();
     if (!$record_id) {
         $record_id = $this->_getRecordId($params);
     }
     if (!$record_type) {
         $record_type = $this->_getRecordType($params);
     }
     $db = get_db();
     $commentTable = $db->getTable('Comment');
     $searchParams = array('record_type' => $record_type, 'record_id' => $record_id);
     if (isset($options['approved'])) {
         $searchParams['approved'] = $options['approved'];
     }
     if (!is_allowed('Commenting_Comment', 'update-approved')) {
         $searchParams['flagged'] = 0;
         $searchParams['is_spam'] = 0;
     }
     $select = $commentTable->getSelectForFindBy($searchParams);
     if (isset($options['order'])) {
         $select->order("ORDER BY added " . $options['order']);
     }
     return $commentTable->fetchObjects($select);
 }
Ejemplo n.º 12
0
 /**
  * Set PUT data to an item type.
  *
  * @param ItemType $data
  * @param mixed $data
  */
 public function setPutData(Omeka_Record_AbstractRecord $record, $data)
 {
     if (isset($data->name)) {
         $record->name = $data->name;
     }
     if (isset($data->description)) {
         $record->description = $data->description;
     }
     if (isset($data->elements) && is_array($data->elements)) {
         $db = get_db();
         // Delete the existing item type elements.
         $sql = "DELETE FROM {$db->ItemTypesElements} WHERE item_type_id = ?";
         $db->query($sql, $record->id);
         // Insert new item type elements.
         $elementTable = $db->getTable('Element');
         $i = 1;
         foreach ($data->elements as $element) {
             if (!is_object($element) || !isset($element->id)) {
                 continue;
             }
             // Ignore if the element does not exist.
             if (!$elementTable->exists($element->id)) {
                 continue;
             }
             $itemTypesElement = new ItemTypesElements();
             $itemTypesElement->item_type_id = $record->id;
             $itemTypesElement->element_id = $element->id;
             $itemTypesElement->order = $i;
             $itemTypesElement->save();
             $i++;
         }
     }
 }
Ejemplo n.º 13
0
 /**
  * Get a URI for a "stored" file.
  *
  * @param string $path
  * @return string URI
  */
 public function getUri($path)
 {
     list($size, $filename) = explode('/', $path, 2);
     $db = get_db();
     $select = $db->select()->from(array("f" => $db->File), array('metadata'));
     $select->where('f.filename = ?', $filename);
     $metadata = $db->getTable('File')->fetchOne($select);
     if ($metadata == '{"iiif":{}}') {
         return '/plugins/Iiif/views/public/img/placeholder.png';
     }
     $metadata = json_decode($metadata, True);
     if (isset($metadata) and array_key_exists('iiif', $metadata) and array_key_exists('@id', $metadata['iiif'])) {
         $base_image_url = $metadata['iiif']['@id'];
     } else {
         # Fallback to Omeka_Storage_Adapter_Filesystem method
         return $this->_webDir . '/' . $path;
     }
     $square_thumbnail_size = get_option('square_thumbnail_constraint');
     $thumbnail_size = get_option('thumbnail_constraint');
     $fullsize_size = get_option('fullsize_constraint');
     $mapping = array('square_thumbnails' => "{$square_thumbnail_size},{$square_thumbnail_size}", 'thumbnails' => "!{$thumbnail_size},{$thumbnail_size}", 'fullsize' => "!{$fullsize_size},{$fullsize_size}", 'original' => 'full');
     if ($size == 'square_thumbnails') {
         $region = 'square';
     } else {
         $region = 'full';
     }
     return $base_image_url . "/{$region}/" . $mapping[$size] . "/0/native.jpg";
 }
 public function findByVocabAndPropertyName($vocabUri, $predName)
 {
     $db = get_db();
     $select = $this->getSelect()->join(array($db->RecordRelationsVocabulary => $db->RecordRelationsVocabulary), "{$db->RecordRelationsVocabulary}.namespace_uri = '{$vocabUri}'", array())->where("vocabulary_id = {$db->RecordRelationsVocabulary}.id")->where("local_part = ?", $predName);
     $prop = $this->fetchObject($select);
     return $prop;
 }
 /**
  * Return identifiers for a record type, if any. It can be sanitized.
  *
  * @param string $recordType Should be "Collection", "Item" or "File".
  * @param boolean $rawEncoded Sanitize the identifier for http or not.
  * @return array Associative array of record id and identifiers.
  */
 public function getRecordTypeIdentifiers($recordType, $rawEncoded = true)
 {
     if (!in_array($recordType, array('Collection', 'Item', 'File'))) {
         return array();
     }
     // Use a direct query in order to improve speed.
     $db = get_db();
     $elementId = (int) get_option('clean_url_identifier_element');
     $bind = array();
     $prefix = get_option('clean_url_identifier_prefix');
     if ($prefix) {
         // Keep only the identifier without the configured prefix.
         $prefixLenght = strlen($prefix) + 1;
         $sqlSelect = 'SELECT element_texts.record_id, TRIM(SUBSTR(element_texts.text, ' . $prefixLenght . '))';
         $sqlWereText = 'AND element_texts.text LIKE ?';
         $bind[] = $prefix . '%';
     } else {
         $sqlSelect = 'SELECT element_texts.record_id, element_texts.text';
         $sqlWereText = '';
     }
     // The "order by id DESC" allows to get automatically the first row in
     // php result and avoids a useless subselect in sql (useless because in
     // almost all cases, there is only one identifier).
     $sql = "\n            {$sqlSelect}\n            FROM {$db->ElementText} element_texts\n            WHERE element_texts.element_id = '{$elementId}'\n                AND element_texts.record_type = '{$recordType}'\n                {$sqlWereText}\n            ORDER BY element_texts.record_id, element_texts.id DESC\n        ";
     $result = $db->fetchPairs($sql, $bind);
     return $rawEncoded ? array_map('rawurlencode', $result) : $result;
 }
Ejemplo n.º 16
0
/**
 *
 */
function insert()
{
    global $prof;
    $prof->log('enter insert');
    $res = array(0, 0, 0, 0);
    $db = get_db();
    try {
        $db->setQuery('insert', "INSERT INTO phplib (rid, name, age, height, weight) VALUES " . "({:=rid}, {:=name}, {:=age}, {:=height}, {:=weight})");
        $prof->log('set insert query');
        for ($i = 1001; $i <= 2000; $i++) {
            $r = array('rid' => $i, 'name' => 'i_' . $i, 'age' => 30, 'height' => 175, 'weight' => 90);
            $db->execute($db->getQuery('insert', $r));
        }
        $prof->log('execute 1000 insert queries');
        $res[0] = 1;
        $db->setQuery('insert_bind', "INSERT INTO phplib (rid, name, age, height, weight) VALUES " . "('{:=rid}', '{:=name}', '{:=age}', '{:=height}', '{:=weight}')");
        $prof->log('set insert_bind query');
        for ($i = 2001; $i <= 3000; $i++) {
            $r = array('rid' => $i, 'name' => 'ib_' . $i, 'age' => 25, 'height' => 185, 'weight' => 102);
            $db->execute($db->getQuery('insert_bind', $r));
        }
        $prof->log('execute 1000 insert bind queries');
        $res[1] = 1;
    } catch (Exception $e) {
        // ignore
    }
    $prof->log('exit insert');
    return $res;
}
Ejemplo n.º 17
0
function sckls_random_featured_collection()
{
    $html = '';
    $collection = get_db()->getTable('Collection')->findRandomFeatured();
    if ($collection) {
        set_current_record('collection', $collection);
        $html .= '<a href="' . record_url($collection, null, true) . '" class="featured">';
        $html .= '    <h6 class="header-label">Featured Collection</h6>';
        $html .= '    <div class="overlay"></div>';
        $items = get_records('Item', array('collection' => $collection->id), 8);
        set_loop_records('items', $items);
        if (has_loop_records('items')) {
            $image = $items[0]->Files;
            if ($image) {
                $html .= '<div style="background-image: url(' . file_display_url($image[0], 'fullsize') . ');" class="img"></div>';
            } else {
                $html .= '<div style="background-image: url(' . img('*****@*****.**') . ');" class="img default"></div>';
            }
        } else {
            $html .= '<div style="background-image: url(' . img('*****@*****.**') . ');" class="img default"></div>';
        }
        $html .= '    <span class="title">' . metadata('collection', array('Dublin Core', 'Title')) . '</span>';
        $html .= '</a>';
    } else {
        $html .= '<h4 class="not-featured">No featured collections.</h4>';
    }
    return $html;
}
 /**
  * Get database, add hooks and filters.
  *
  * @return void
  */
 public function __construct()
 {
     $this->_db = get_db();
     $this->servicesTable = $this->_db->getTable('NeatlineMapsService');
     $this->serversTable = $this->_db->getTable('NeatlineMapsServer');
     self::addHooksAndFilters();
 }
Ejemplo n.º 19
0
function spreadsheet_uninstall()
{
    $db = get_db();
    $db->exec("DROP TABLE IF EXISTS {$db->prefix}spreadsheets");
    delete_option('spreadsheet_version');
    delete_option('spreadsheet_expiry');
}
 function delete($id, $type)
 {
     $db = get_db();
     $sql = '';
     $sql = "DELETE from {$db->MapfigStudioItem} where id='{$id}'";
     $db->query($sql);
 }
Ejemplo n.º 21
0
 function __construct($u_id)
 {
     if ($u_id) {
         $member = new table_class('eachbb.member');
         $member->find($u_id);
         $this->id = $u_id;
         $this->name = $member->name;
         $this->password = $member->password;
         $this->email = $member->email;
         $this->birthday = $member->birthday;
         $this->address = $member->address;
         $this->nick_name = $member->ture_name;
         $db = get_db();
         $db->query("select * from member_status where uid={$u_id}");
         if ($db->record_count == 0) {
             $status = new table_class('member_status');
             $status->created_at = $member->created_at;
             $status->last_login = $member->last_login;
             $status->uid = $u_id;
             $status->save();
         }
         $this->score = $status->score;
         $this->visit_count = $status->visit_count;
         $this->level = $status->level;
         $this->last_login = $status->last_login;
     }
 }
Ejemplo n.º 22
0
 private function _defaultsInstalled()
 {
     $db = get_db();
     $sql = "select * from `" . $db->prefix . "MmdProfileAux`";
     $response = $db->query($sql);
     return $response->fetch() ? true : false;
 }
 public function exhibitSearch($args, $view)
 {
     // Get exhibit ID from shortcode
     if (isset($args['exhibit'])) {
         $eid = $args['exhibit'];
     }
     // Get page IDs for the exhibit
     $db = get_db();
     $select = "\n                    SELECT id\n                    FROM omeka_exhibit_pages\n                    WHERE (exhibit_id=?)\n                    ORDER BY id\n                    ";
     $pages = $db->getTable("ExhibitPage")->fetchObjects($select, array($eid));
     $page_ids = array();
     foreach ($pages as $page) {
         array_push($page_ids, $page['id']);
     }
     $page_string = join(",", $page_ids);
     // Build the options and filters arrays used for searches.
     $options = array();
     // Set the default flag indicating whether to show the advanced form.
     if (!isset($options['show_advanced'])) {
         $options['show_advanced'] = true;
     }
     // Set the default submit value.
     if (!isset($options['submit_value'])) {
         $options['submit_value'] = __('Search');
     }
     // Set the default form attributes.
     $options['form_attributes'] = array();
     $url = apply_filters('search_form_default_action', url('search'));
     $options['form_attributes']['action'] = $url;
     $options['form_attributes']['id'] = 'search-form';
     $options['form_attributes']['method'] = 'get';
     $options['form_attributes']['style'] = 'text-align:left;width:75%';
     $this->_validQueryTypes = get_search_query_types();
     $this->_validRecordTypes = get_custom_search_record_types();
     $filters = array();
     if (isset($_GET['query'])) {
         $filters['query'] = $_GET['query'];
     } else {
         $filters['query'] = '';
     }
     if (isset($_GET['query_type']) && array_key_exists($_GET['query_type'], $this->_validQueryTypes)) {
         $filters['query_type'] = $_GET['query_type'];
     } else {
         $filters['query_type'] = 'keyword';
     }
     if (isset($_GET['record_types'])) {
         $filters['record_types'] = $_GET['record_types'];
     } else {
         $filters['record_types'] = array_keys($this->_validRecordTypes);
     }
     // Add a filter for exhibit_id
     if (isset($_GET['exhibit_id'])) {
         $filters['exhibit_id'] = $_GET['exhibit_id'];
     } else {
         $filters['exhibit_id'] = $page_ids;
     }
     $this->_filters = $filters;
     // Pass variables to a view; the view returns a search box.
     return $view->partial('search/search.php', array('options' => $options, 'filters' => $this->_filters, 'recordIDs' => $page_string, 'query_types' => array('keyword' => __('Keyword')), 'record_types' => array('ExhibitPage' => __('Exhibit Page')), 'exhibit_id' => array($eid => "Record Id: {$eid}")));
 }
Ejemplo n.º 24
0
 /**
  * Process the element text data
  * @param array $responseData
  */
 protected function elementTexts($responseData = null)
 {
     $elementTexts = array();
     if (!$responseData) {
         $responseData = $this->responseData;
     }
     //need to work around a previous bug in contribution, which would store User Profile
     //elements on the Item as well. This made item elements from API also include
     //UP elements, which failed the lookup.
     $db = get_db();
     $elementTable = $db->getTable('Element');
     $sql = "\n            SELECT DISTINCT external_id FROM `{$db->ElementSet}`\n            JOIN `{$db->OmekaApiImportRecordIdMap}` ON {$db->ElementSet}.id = local_id\n            WHERE {$db->OmekaApiImportRecordIdMap}.record_type = 'ElementSet'\n            AND {$db->ElementSet}.record_type = 'UserProfilesType'\n        ";
     $userProfilesElementSetIdsMap = $db->fetchCol($sql);
     foreach ($responseData['element_texts'] as $elTextData) {
         if (in_array($elTextData['element_set']['id'], $userProfilesElementSetIdsMap)) {
             continue;
         }
         //work around some possible oddities from .net with element data being null
         if (is_null($elTextData['element_set']['id'])) {
             continue;
         }
         if (is_null($elTextData['element']['id'])) {
             continue;
         }
         $elName = $elTextData['element']['name'];
         $elSet = $elTextData['element_set']['name'];
         $elTextInsertArray = array('text' => $elTextData['text'], 'html' => $elTextData['html']);
         if (is_null($elTextInsertArray['text'])) {
             $elTextInsertArray['text'] = '';
         }
         $elementTexts[$elSet][$elName][] = $elTextInsertArray;
     }
     return $elementTexts;
 }
 public function uninstall()
 {
     $db = get_db();
     $db->query("DROP TABLE IF EXISTS `{$db->MapfigStudio}`");
     set_option('mapfig_studio_api_key', '');
     set_option('mapfig_studio_url', '');
 }
 /**
  * This is a filter function.  
  * 
  * If the relation text begins with thumb:, then the thumb: portion 
  * is stripped and the remaining urn is displayed as a thumbnail.
  * If the relation text begins with full:, the full: portion
  * is stripped and the remaining urn is displayed as a link.
  * 
  * Any other relation text not meeting the criteria is simply returned as is.
  * 
  * @param string - the text from the Relation field
  * @return string - this will be an img tag if thumb:, a href tag if full:, or currently existing text.
  */
 public function replaceDigitalObjectRelations($text, $args)
 {
     //If the relation has a full string, check to see if it has a thumb relation.  If so, then
     //display the thumb and link it out to the full image.  Otherwise just make it a link.
     if (preg_match(get_option('digitalobjectlinkerplugin_preg_full_image_string'), $text)) {
         //Strip the full: from the text.
         $fulllink = substr($text, strlen(get_option('digitalobjectlinkerplugin_full_image_tag')));
         $fullid = $this->parseUniqueId($fulllink);
         if ($fullid != 'no-id') {
             $fulllink = trim(str_replace($fullid . ":", "", $fulllink));
         }
         //Create the link with parameters.
         $fulllinkwithparams = $fulllink . "?buttons=Y";
         //The only way that I could find to get all relations during the filter was to pull the relations from the database.
         //Trying to pull from the metadata function seemed to throw this into an infinite loop.
         //This first gets the element_id for the 'Relation' element from the 'Element' table (omeka_elements if you are looking in the db).
         //Second, it then finds all of the 'Relation' element texts from the 'ElementText' table (omeka_element_texts) using
         //the record ID which was passed in from the filter and the element_id that was retrieved.
         $element = get_db()->getTable('Element')->findByElementSetNameAndElementName('Dublin Core', 'Relation');
         $elementID = $element->id;
         //Record ID that was passed in from the filter.
         $recordID = $args['record']->id;
         //We no longer need the element object that we retrieved so releas it.
         release_object($element);
         //Create the select for the ElementText table.
         $select = get_db()->select()->from(array(get_db()->ElementText), array('text'))->where('record_id=' . $recordID . ' AND element_id = ' . $elementID);
         //Fetch all of the relations.  They come back as an array in this form:
         //array(0 => array('text' => full:urn...), 1 => array('text' => thumb:urn....))
         $relations = get_db()->getTable('ElementText')->fetchAll($select);
         //Logger::log($relations);
         //As long as at least one relation was returned, we can continue.
         if (count($relations) > 0) {
             foreach ($relations as $relation) {
                 //Make sure the relation is not the full relation that we are filtering.  If it isn't,
                 //check to see if it is the thumb relation.
                 if ($relation['text'] != $text && preg_match(get_option('digitalobjectlinkerplugin_preg_thumb_string'), $relation['text'])) {
                     //Create a thumb image that links out to the full image.
                     $thumblink = substr($relation['text'], strlen(get_option('digitalobjectlinkerplugin_thumb_tag')));
                     if (!empty($thumblink)) {
                         $thumbid = $this->parseUniqueId($thumblink);
                         if ($thumbid != 'no-id') {
                             $thumblink = trim(str_replace($thumbid . ":", "", $thumblink));
                         }
                         if ($fullid == $thumbid) {
                             //Determine the width and height of the thumb.
                             $width = is_admin_theme() ? get_option('digitalobjectlinkerplugin_width_admin') : get_option('digitalobjectlinkerplugin_width_public');
                             return "<div class=\"item-relation\"><a href=\"" . $fulllinkwithparams . "\" target=\"_blank\"><img src=\"" . $thumblink . "\" alt=\"" . $thumblink . "\" height=\"" . $width . "\"></img></a></div>";
                         }
                     }
                 }
             }
         }
         //If it reaches this point, the relations did not contain a thumbnail so return a plain link.
         return "<a href=\"" . $fulllinkwithparams . "\" target=\"_blank\">" . $fulllink . "</a>";
     } elseif (!preg_match(get_option('digitalobjectlinkerplugin_preg_thumb_string'), $text)) {
         return $text;
     }
     return NULL;
 }
Ejemplo n.º 27
0
/**
 * Delete relations from the relations table (NOT the target subject or object tables)
 * @param array $params
 */
function record_relations_delete_relations($params)
{
    $relTable = get_db()->getTable('RecordRelationsRelation');
    $rels = $relTable->findBy($params);
    foreach ($rels as $rel) {
        $rel->delete();
    }
}
Ejemplo n.º 28
0
function user_profiles_link_to_user_profile($user, $action = null, $text = null, $props = array(), $queryParams = array())
{
    if (empty($text)) {
        $text = $user->name;
    }
    $profiles = get_db()->getTable('UserProfilesProfile')->findByUserId($user->id);
    return link_to($profiles[0], $action, $text, $props, $queryParams);
}
Ejemplo n.º 29
0
 /**
  * Browse display profiles
  *
  * This action runs when a user browses existing assignments.
  *
  * @return void
  */
 public function browseAction()
 {
     $assigns = get_db()->getTable('MmdAssign')->findAll();
     if (count($assigns) == 0) {
         $this->forward('add');
     }
     $this->view->assigns = $assigns;
 }
Ejemplo n.º 30
-1
    function bousole($carte = "Map")
    {
        ?>
		<form class="boussole" method="post">
			<input type="submit" name="deplacement" value="-1|0" class="arrow topleft"/>
			<input type="submit" name="deplacement" value="0|1"  class="arrow up"/>
			<input type="submit" name="deplacement" value="-1|0" class="arrow left"/>
			<div id="position">
			<?php 
        if ($carte == "Map") {
            echo user_data("Account_PosX") . "-" . user_data("Account_PosY");
        }
        ?>
			<?php 
        if ($carte == "Town") {
            $recup = get_db("SELECT Position_PosX,Position_PosY FROM Caranille_Position WHERE Position_Account_ID = '" . user_data('Account_ID') . "' and Position_Town_ID = '" . $_SESSION['Town_ID'] . "' limit 1");
            echo $recup['Position_PosX'] . "-" . $recup['Position_PosX'];
        }
        ?>
  		
			</div><input type="submit" name="deplacement" value="1|0"  class="arrow right"/>
			<input type="submit" name="deplacement" value="0|-1" class="arrow down"/>
			<input type="hidden" name="token" value="<?php 
        echo generer_token('deplacement-' . $carte);
        ?>
" />
		</form>       
	<?php 
    }