Changeset 6164

Show
Ignore:
Timestamp:
06/03/07 14:43:30 (1 year ago)
Author:
w_i
Message:

Added unified search. closes #33

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.helper.imagepopup/config/manifest.inc

    r5819 r6164  
    33  'description' => 'Image upload and insertion tool', 
    44  'purecode' => true, 
    5   'version' => '0.1.5beta1', 
     5  'version' => '0.1.6beta1', 
    66  'state' => 'beta', 
    77  'privileges' =>  
     
    3434        'role' => 'developer', 
    3535      ), 
     36      'w_i' =>  
     37      array ( 
     38        'name' => 'Jerry Jalava', 
     39        'email' => 'jerry.jalava@nemein.com', 
     40        'role' => 'developer', 
     41      ), 
    3642    ), 
    3743    'dependencies' =>  
  • trunk/midcom/midcom.helper.imagepopup/handler/list.php

    r4283 r6164  
    2020    var $_controller = null; 
    2121     
     22        /** 
     23         * Listing type 
     24         */ 
     25        var $_list_type = null; 
     26 
     27        /** 
     28         * Search results 
     29         */ 
     30        var $_search_results = array(); 
     31         
    2232    function midcom_helper_imagepopup_handler_list()   
    2333    { 
    2434        parent::midcom_baseclasses_components_handler(); 
     35    } 
     36 
     37    function _prepare_request_data() 
     38    { 
     39        $this->_request_data['datamanager'] =& $this->_datamanager; 
    2540    } 
    2641     
     
    6883                $data['list_title'] = $_MIDCOM->i18n->get_string('page attachments', 'midcom.helper.imagepopup'); 
    6984                break; 
    70         } 
    71          
     85 
     86            case '____ais-imagepopup-list_unified_noobject': 
     87            case '____ais-imagepopup-list_unified': 
     88                $data['list_type'] = 'unified'; 
     89                $data['list_title'] = $_MIDCOM->i18n->get_string('unified search', 'midcom.helper.imagepopup'); 
     90                                $data['query'] = (array_key_exists('query', $_REQUEST) ? $_REQUEST['query'] : ''); 
     91                break; 
     92        } 
     93        $this->_list_type = $data['list_type']; 
     94 
     95        $_MIDCOM->set_pagetitle($data['list_title']); 
     96 
     97                if ($data['list_type'] != 'unified') 
     98                { 
     99                        $this->_create_controller($data); 
     100                } 
     101                else 
     102                { 
     103                        if($data['query'] != '') 
     104                        { 
     105                                $this->_run_search($data); 
     106                        } 
     107                } 
     108 
     109        $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL."/Pearified/JavaScript/Prototype/prototype.js"); 
     110        $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL . "/midcom.helper.imagepopup/functions.js"); 
     111         
     112        $image_info = "var imagepopup_images = new Array();\n"; 
     113        $image_info .= "imagepopup_images['prefix'] = \"{$_MIDGARD['self']}midcom-serveattachmentguid-\";\n";  
     114        $_MIDCOM->add_jscript($image_info); 
     115         
     116        //$_MIDCOM->add_jsonload("tinyMCEPopup.executeOnLoad('tinyMCEPopup.resizeToContent()');"); 
     117         
     118        // Ensure we get the correct styles 
     119        $_MIDCOM->style->prepend_component_styledir('midcom.helper.imagepopup'); 
     120         
     121        return true; 
     122    } 
     123 
     124    function _create_controller(&$data) 
     125    { 
    72126        // Run datamanager for handling the images 
    73127        $this->_controller =& midcom_helper_datamanager2_controller::create('simple'); 
    74128        $this->_controller->schemadb = $this->_load_schema($data['schema_name']); 
    75         $this->_controller->schemaname = $data['schema_name'];  
    76          
    77         $_MIDCOM->set_pagetitle($data['list_title']); 
    78          
     129        $this->_controller->schemaname = $data['schema_name']; 
     130 
    79131        if ($data['list_type'] == 'page') 
    80132        { 
     
    85137            $this->_controller->set_storage($data['folder']); 
    86138        } 
    87          
     139 
    88140        $this->_controller->initialize(); 
    89141        $this->_request_data['form'] = & $this->_controller; 
     
    95147        } 
    96148 
    97         $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL."/Pearified/JavaScript/Prototype/prototype.js"); 
    98         $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL . "/midcom.helper.imagepopup/functions.js"); 
    99          
    100         $image_info = "var imagepopup_images = new Array();\n"; 
    101         $image_info .= "imagepopup_images['prefix'] = \"{$_MIDGARD['self']}midcom-serveattachmentguid-\";\n";  
    102         $_MIDCOM->add_jscript($image_info); 
    103          
    104         //$_MIDCOM->add_jsonload("tinyMCEPopup.executeOnLoad('tinyMCEPopup.resizeToContent()');"); 
    105149        $_MIDCOM->add_jsonload("imagePopupConvertImagesForAddition();imagePopupConvertFilesForAddition();"); 
    106          
    107         // Ensure we get the correct styles 
    108         $_MIDCOM->style->prepend_component_styledir('midcom.helper.imagepopup'); 
    109          
    110         return true; 
    111     } 
     150    } 
     151 
     152        function _run_search(&$data) 
     153        { 
     154                $qb = midcom_baseclasses_database_attachment::new_query_builder(); 
     155                $query = str_replace('*', '%', $data['query']); 
     156                $qb->begin_group('OR'); 
     157                $qb->add_constraint('name', 'LIKE', $query); 
     158                $qb->add_constraint('title', 'LIKE', $query); 
     159                $qb->add_constraint('mimetype', 'LIKE', $query); 
     160                $qb->end_group(); 
     161 
     162                $this->_search_results = $qb->execute(); 
     163                 
     164                $_MIDCOM->add_jsonload("imagePopupConvertResultsForAddition();"); 
     165        } 
    112166     
    113167    function _show_list()  
    114168    {     
    115169        midcom_show_style('midcom_helper_imagepopup_init'); 
    116         midcom_show_style('midcom_helper_imagepopup_list'); 
     170                if ($this->_list_type == 'unified') 
     171                { 
     172                        midcom_show_style('midcom_helper_imagepopup_search'); 
     173                        $this->_show_search_results(); 
     174                } 
     175                else 
     176                { 
     177                        midcom_show_style('midcom_helper_imagepopup_list'); 
     178                } 
    117179        midcom_show_style('midcom_helper_imagepopup_finish'); 
     180    } 
     181 
     182    function _show_search_results()  
     183    {     
     184                midcom_show_style('midcom_helper_imagepopup_search_result_start'); 
     185                 
     186                if (count($this->_search_results) > 0) 
     187        { 
     188                        foreach ($this->_search_results as $key => $result) 
     189                        { 
     190                                $this->_request_data['result'] = $result; 
     191                                midcom_show_style('midcom_helper_imagepopup_search_result_item');        
     192                        } 
     193        } 
     194                 
     195                midcom_show_style('midcom_helper_imagepopup_search_result_end'); 
    118196    } 
    119197     
     
    173251                'widget' => 'images', 
    174252                'widget_config' => array ( 
    175                        'set_name_and_title_on_upload' => false 
    176                        ) , 
     253                    'set_name_and_title_on_upload' => false 
     254                    ) , 
    177255            ); 
    178256 
  • trunk/midcom/midcom.helper.imagepopup/locale/default.en.txt

    r4205 r6164  
    2424---STRINGEND 
    2525 
     26---STRING unified search 
     27Unified search 
     28---STRINGEND 
     29 
  • trunk/midcom/midcom.helper.imagepopup/locale/default.fi.txt

    r3629 r6164  
    2424---STRINGEND 
    2525 
     26---STRING unified search 
     27Yhdistetty haku 
     28---STRINGEND 
     29 
  • trunk/midcom/midcom.helper.imagepopup/locale/default.hu.txt

    r5392 r6164  
    2424---STRINGEND 
    2525 
     26---STRING unified search 
     27Unified search 
     28---STRINGEND 
  • trunk/midcom/midcom.helper.imagepopup/locale/default.pl.txt

    r4205 r6164  
    2626---STRINGEND 
    2727 
     28---STRING unified search 
     29Unified search 
     30---STRINGEND 
  • trunk/midcom/midcom.helper.imagepopup/static/functions.js

    r3489 r6164  
    192192        return html_code; 
    193193} 
     194 
     195function imagePopupConvertResultsForAddition() 
     196{ 
     197    // We convert the image "size lists" into the addition clickers 
     198    resultRows = document.getElementsByClassName('midcom_helper_imagepopup_search_result_item'); 
     199    if (resultRows) 
     200    { 
     201        for (i = 0; i < resultRows.length; i++)  
     202        { 
     203            itemGuid = resultRows[i].getAttribute('title'); 
     204            itemType = resultRows[i].getAttribute('rel'); 
     205            if (itemGuid) 
     206            { 
     207                item = new Array(); 
     208                item['guid'] = itemGuid; 
     209                item['type'] = itemType; 
     210                                 
     211                                informationBlocks = resultRows[i].getElementsByTagName('span'); 
     212                if (!informationBlocks) 
     213                { 
     214                    alert("No metadata information available!"); 
     215                } 
     216 
     217                                for (ii = 0; ii < informationBlocks.length; ii++) 
     218                                { 
     219                                        informationTitle = informationBlocks[ii].getAttribute('title'); 
     220                                        item[informationTitle] = informationBlocks[ii].innerHTML; 
     221                                } 
     222 
     223                imageLinks = resultRows[i].getElementsByTagName('a'); 
     224 
     225                // Tweak the image links 
     226                for (iii = 0; iii < imageLinks.length; iii++)  
     227                { 
     228                    imageLinks[iii].href = 'javascript:insertImage("' + itemGuid + '");'; 
     229                    imageLinks[iii].target = ''; 
     230                    imageLinks[iii].title = 'Click to insert'; 
     231                } 
     232                 
     233                // Populate image to the image info Array 
     234                imagepopup_images[itemGuid] = new Array(); 
     235                imagepopup_images[itemGuid]['title'] = item['title']; 
     236                imagepopup_images[itemGuid]['name'] = item['name']; 
     237                imagepopup_images[itemGuid]['type'] = itemType; 
     238            } 
     239        } 
     240    } 
     241} 
  • trunk/midcom/midcom.helper.imagepopup/static/styling.css

    r4265 r6164  
    6262 
    6363 
    64 #files 
     64#files, #search 
    6565{ 
    6666    padding-left: 2%; 
     
    121121    text-align: center; 
    122122} 
     123 
     124.search-form 
     125{ 
     126        margin: 10px 0 10px 0; 
     127} 
     128 
     129ul 
     130{ 
     131        margin: 0; 
     132        padding: 0; 
     133        list-style-type: none; 
     134} 
     135ul li 
     136{ 
     137        height: 59px; 
     138        margin: 0 0 5px 0; 
     139        padding: 5px; 
     140        border-bottom: 1px solid #D7DBD1; 
     141         
     142} 
  • trunk/midcom/midcom.helper.imagepopup/style/midcom_helper_imagepopup_list.php

    r5048 r6164  
    1 <?php 
    2 //$data =& $_MIDCOM->get_custom_context_data('request_data'); 
    3 $prefix = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_ANCHORPREFIX) . "__ais/imagepopup/"; 
    4 ?> 
    51<div class="midcom_helper_imagepopup"> 
    62    <h1><?php echo $data['list_title']; ?></h1> 
    73     
    8     <div id="top_navigation"> 
    9         <ul> 
    10         <?php 
    11         if ($data['list_type'] === 'folder') 
    12         { 
    13             if ($data['object']) 
    14             { 
    15                 echo "<li><a href=\"{$prefix}{$data['schema_name']}/{$data['object']->guid}/\">" . $_MIDCOM->i18n->get_string('page', 'midcom') . "</a></li>"; 
    16             } 
    17             echo "<li class=\"selected\"><a href=\"{$prefix}folder/{$data['schema_name']}/{$data['object']->guid}\">" . $_MIDCOM->i18n->get_string('folder', 'midcom') . "</a></li>"; 
    18         } 
    19         else 
    20         { 
    21             echo "<li class=\"selected\"><a href=\"{$prefix}{$data['schema_name']}/{$data['object']->guid}/\">" . $_MIDCOM->i18n->get_string('page', 'midcom') . "</a></li>"; 
    22             echo "<li><a href=\"{$prefix}folder/{$data['schema_name']}/{$data['object']->guid}\">" . $_MIDCOM->i18n->get_string('folder', 'midcom') . "</a></li>"; 
    23         } 
     4        <?php midcom_show_style("midcom_helper_imagepopup_navigation"); ?> 
    245 
    25        ?> 
    26        </ul> 
    27     </div> 
    286    <div id="files"> 
    297        <?php