Changeset 11744

Show
Ignore:
Timestamp:
08/27/07 16:39:26 (1 year ago)
Author:
adrenalin
Message:

Working copy of cc.kaktus.query

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/branch-2_6/src/cc.kaktus.query/config/config.inc

    r11698 r11744  
    1313// Order and navigation 
    1414'sort_order' => 'created DESC', 
    15 'display_in_navigation' => 0, 
     15'display_in_navigation' => 10, 
    1616'show_empty_groups' => false, 
     17 
     18'enable_ajax_editing' => true, 
  • branches/branch-2_6/src/cc.kaktus.query/config/mgdschema.sql

    r11699 r11744  
    99    end            INT(8)         NOT NULL   DEFAULT 0, 
    1010    score          INT(8)         NOT NULL   DEFAULT 0, 
     11    creator        INT(8)         NOT NULL   DEFAULT 0, 
     12    created        INT(8)         NOT NULL   DEFAULT 0, 
     13    revisor        INT(8)         NOT NULL   DEFAULT 0, 
     14    revised        INT(8)         NOT NULL   DEFAULT 0, 
     15    sitegroup      INT(8)         NOT NULL   DEFAULT 0, 
    1116    PRIMARY KEY (id) 
    1217); 
     
    2025    end            INT(8)         NOT NULL   DEFAULT 0, 
    2126    score          INT(8)         NOT NULL   DEFAULT 0, 
     27    creator        INT(8)         NOT NULL   DEFAULT 0, 
     28    created        INT(8)         NOT NULL   DEFAULT 0, 
     29    revisor        INT(8)         NOT NULL   DEFAULT 0, 
     30    revised        INT(8)         NOT NULL   DEFAULT 0, 
     31    sitegroup      INT(8)         NOT NULL   DEFAULT 0, 
    2232    PRIMARY KEY (id) 
    2333); 
     
    2939    answer         LONGTEXT       NOT NULL  DEFAULT '', 
    3040    identificator  VARCHAR(255)   NOT NULL  DEFAULT '', 
     41    creator        INT(8)         NOT NULL   DEFAULT 0, 
     42    created        INT(8)         NOT NULL   DEFAULT 0, 
     43    revisor        INT(8)         NOT NULL   DEFAULT 0, 
     44    revised        INT(8)         NOT NULL   DEFAULT 0, 
     45    sitegroup      INT(8)         NOT NULL   DEFAULT 0, 
    3146    PRIMARY KEY (id) 
    3247); 
     48 
     49ALTER TABLE cc_kaktus_query_group ADD COLUMN creator INT(8) NOT NULL DEFAULT 0; 
     50ALTER TABLE cc_kaktus_query_group ADD COLUMN created INT(8) NOT NULL DEFAULT 0; 
     51ALTER TABLE cc_kaktus_query_group ADD COLUMN revisor INT(8) NOT NULL DEFAULT 0; 
     52ALTER TABLE cc_kaktus_query_group ADD COLUMN revised INT(8) NOT NULL DEFAULT 0; 
     53ALTER TABLE cc_kaktus_query_group ADD COLUMN sitegroup INT(8) NOT NULL DEFAULT 0; 
     54 
     55ALTER TABLE cc_kaktus_query_question ADD COLUMN creator INT(8) NOT NULL DEFAULT 0; 
     56ALTER TABLE cc_kaktus_query_question ADD COLUMN created INT(8) NOT NULL DEFAULT 0; 
     57ALTER TABLE cc_kaktus_query_question ADD COLUMN revisor INT(8) NOT NULL DEFAULT 0; 
     58ALTER TABLE cc_kaktus_query_question ADD COLUMN revised INT(8) NOT NULL DEFAULT 0; 
     59ALTER TABLE cc_kaktus_query_question ADD COLUMN sitequestion INT(8) NOT NULL DEFAULT 0; 
     60 
     61ALTER TABLE cc_kaktus_query_answer ADD COLUMN creator INT(8) NOT NULL DEFAULT 0; 
     62ALTER TABLE cc_kaktus_query_answer ADD COLUMN created INT(8) NOT NULL DEFAULT 0; 
     63ALTER TABLE cc_kaktus_query_answer ADD COLUMN revisor INT(8) NOT NULL DEFAULT 0; 
     64ALTER TABLE cc_kaktus_query_answer ADD COLUMN revised INT(8) NOT NULL DEFAULT 0; 
     65ALTER TABLE cc_kaktus_query_answer ADD COLUMN siteanswer INT(8) NOT NULL DEFAULT 0; 
  • branches/branch-2_6/src/cc.kaktus.query/config/mgdschema.xml

    r11699 r11744  
    1010        <property name="end" type="integer" /> 
    1111        <property name="score" type="integer" /> 
     12        <property name="creator" link="midgard_person:id" reverse="no" type="integer"/> 
     13        <property name="created" type="integer" /> 
     14        <property name="revisor" link="midgard_person:id" reverse="no" type="integer"/> 
     15        <property name="revised" type="integer" /> 
    1216    </type> 
    1317     
     
    1923        <property name="end" type="integer" /> 
    2024        <property name="score" type="integer" /> 
     25        <property name="creator" link="midgard_person:id" reverse="no" type="integer"/> 
     26        <property name="created" type="integer" /> 
     27        <property name="revisor" link="midgard_person:id" reverse="no" type="integer"/> 
     28        <property name="revised" type="integer" /> 
    2129    </type> 
    2230     
     
    2634        <property name="answer" type="text" /> 
    2735        <property name="identificator" type="text" /> 
     36        <property name="creator" link="midgard_person:id" reverse="no" type="integer"/> 
     37        <property name="created" type="integer" /> 
     38        <property name="revisor" link="midgard_person:id" reverse="no" type="integer"/> 
     39        <property name="revised" type="integer" /> 
    2840    </type> 
    2941</Schema> 
  • branches/branch-2_6/src/cc.kaktus.query/config/schemadb_question_default.inc

    r11699 r11744  
    88            // COMPONENT-REQUIRED 
    99            'title' => 'title', 
    10             'storage' => 'title', 
     10            'storage' => 'question', 
    1111            'required' => true, 
    1212            'type' => 'text', 
  • branches/branch-2_6/src/cc.kaktus.query/dba_classes/group.php

    r11699 r11744  
    5555        } 
    5656         
     57        // Prevent saving duplicate names 
     58        if (cc_kaktus_query_group_dba::get_by_name($this->name)) 
     59        { 
     60            return false; 
     61        } 
     62         
    5763        return true; 
    5864    } 
     
    6773    { 
    6874        if (   !$this->node 
    69             && !$this->query
     75            && !$this->up
    7076        { 
    7177            return false; 
     
    7480        // Check that the node exists 
    7581        if (   !$this->up 
    76             && $this->node
     82            && $this->up
    7783        { 
    7884            $node = new midcom_db_topic($this->node); 
     
    8490                return false; 
    8591            } 
     92        } 
     93         
     94        // Prevent saving duplicate names 
     95        if (cc_kaktus_query_group_dba::get_by_name($this->name)) 
     96        { 
     97            return false; 
    8698        } 
    8799         
     
    96108     * @return cc_kaktus_query_group_dba object or false on failure 
    97109     */ 
    98     function get_by_name($name
     110    function get_by_name($name, $topic = null
    99111    { 
    100112        $qb = cc_kaktus_query_group_dba::new_query_builder(); 
    101113        $qb->add_constraint('name', '=', $name); 
    102114         
    103         // Get the current topic 
    104         $topic = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_CONTENTTOPIC); 
     115        // Get the content topic 
     116        if (is_null($topic)) 
     117        { 
     118            // Get the current topic 
     119            $topic = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_CONTENTTOPIC); 
     120        } 
    105121         
    106         $qb->add_constraint('node', '=', $topic->id); 
     122        if (is_object($topic)) 
     123        { 
     124            $id = (int) $topic->id; 
     125        } 
     126        else 
     127        { 
     128            $id = (int) $topic; 
     129        } 
     130         
     131        $qb->add_constraint('node', '=', $id); 
    107132        $qb->set_limit(1); 
    108133         
  • branches/branch-2_6/src/cc.kaktus.query/dba_classes/question.php

    r11699 r11744  
    3535    function _on_creating() 
    3636    { 
    37         if (!$this->group) 
     37        if (!$this->up) 
    3838        { 
    3939            return false; 
     
    5151    function _on_updating() 
    5252    { 
    53         if (!$this->group) 
     53        if (!$this->up) 
    5454        { 
    5555            return false; 
  • branches/branch-2_6/src/cc.kaktus.query/handler/create.php

    r11699 r11744  
    6767        $this->_group = new cc_kaktus_query_group_dba(); 
    6868        $this->_group->node = $this->_topic->id; 
     69        $this->_group->up = 0; 
    6970         
    70         if (! $this->_group->create()) 
     71        if (!$this->_group->create()) 
    7172        { 
    7273            debug_push_class(__CLASS__, __FUNCTION__); 
  • branches/branch-2_6/src/cc.kaktus.query/handler/view.php

    r11698 r11744  
    2222     
    2323    /** 
    24      * Queries stored in an array 
    25      *  
    26      * @access private 
    27      * @var array $_queries    Array of cc_kaktus_query_dba objects 
    28      */ 
    29     var $_queries = array(); 
     24     * Query group 
     25     *  
     26     * @access private 
     27     * @var cc_kaktus_query_group $_group 
     28     */ 
     29    var $_group; 
     30     
     31    /** 
     32     * Order of queries 
     33     *  
     34     * @access private 
     35     * @var array $_order 
     36     */ 
     37    var $_order = array 
     38    ( 
     39        'key' => 'created', 
     40        'order' => 'ASC', 
     41    ); 
     42     
     43    /** 
     44     * Store AJAX controller enabled HTML 
     45     *  
     46     * @access private 
     47     * @var Array $_view_html 
     48     */ 
     49    var $_view_html = array(); 
     50     
     51    /** 
     52     * Load datamanagers 
     53     *  
     54     * @access private 
     55     * @return boolean Indicating success 
     56     */ 
     57    function _load_datamanagers() 
     58    { 
     59        $this->_datamanager = new midcom_helper_datamanager2_datamanager($this->_request_data['schemadb_group']); 
     60        $this->_datamanager_question = new midcom_helper_datamanager2_datamanager($this->_request_data['schemadb_question']); 
     61         
     62        // Try to initialize the datamanagers 
     63        if (   $this->_datamanager->initialize() 
     64            || $this->_datamanager_question->initialize()) 
     65        { 
     66            $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 'Failed to load datamanagers'); 
     67            // This will exit 
     68        } 
     69         
     70        if ($this->_config->get('enable_ajax_editing')) 
     71        { 
     72            $this->_controller = midcom_helper_datamanager2_controller::create('ajax'); 
     73            $this->_controller->schemadb =& $this->_request_data['schemadb_group']; 
     74            $this->_controller->set_storage($this->_group); 
     75            $this->_controller->process_ajax(); 
     76        } 
     77    } 
    3078     
    3179    /** 
     
    4694    function _load_datamanager() 
    4795    { 
    48         $this->_datamanager = new midcom_helper_datamanager2_datamanager($this->_request_data['schemadb']); 
    49  
    50         if (!$this->_datamanager) 
    51         { 
     96        $this->_datamanager = new midcom_helper_datamanager2_datamanager($this->_request_data['schemadb_group']); 
     97 
     98        if (!$this->_datamanager)        { 
    5299            $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Failed to create a DM2 instance"); 
    53100            // This will exit. 
    54101        } 
    55102    } 
     103     
     104    /** 
     105     * Set the toolbar items and bind to metadata 
     106     *  
     107     * @access private 
     108     */ 
     109    function _process_group() 
     110    { 
     111        // Set the active page 
     112        $this->_component_data['active_leaf'] = $this->_group->guid; 
     113        $_MIDCOM->set_pagetitle($this->_group->title); 
     114         
     115        // Set the toolbar items 
     116        $this->_view_toolbar->add_item 
     117        ( 
     118            array 
     119            ( 
     120                MIDCOM_TOOLBAR_URL => "edit/{$this->_group->name}/", 
     121                MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('edit'), 
     122                MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', 
     123            ) 
     124        ); 
     125         
     126        // Bind to metadata 
     127        $_MIDCOM->bind_view_to_object($this->_group); 
     128        $_MIDCOM->set_26_request_metadata($this->_group->revised, $this->_group->guid); 
     129    } 
     130     
     131    /** 
     132     * Prevent URL hijacking 
     133     *  
     134     * @access public 
     135     * @return boolean True if this handler is allowed to process the request, false if another topic should try its luck 
     136     */ 
     137    function _can_handle_view($handler_id, $args) 
     138    { 
     139        if (!isset($args[0])) 
     140        { 
     141            $qb = cc_kaktus_query_group_dba::new_query_builder(); 
     142            $qb->add_constraint('node', '=', $this->_topic->id); 
     143            $qb->add_order('created', 'DESC'); 
     144            $qb->set_limit(1); 
     145             
     146            $results = $qb->execute(); 
     147             
     148            $this->_group =& $results[0]; 
     149            $prefix = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_ANCHORPREFIX); 
     150             
     151            $_MIDCOM->relocate("{$prefix}{$this->_topic->name}/{$results[0]->name}/"); 
     152            // This will exit 
     153        } 
     154         
     155        // Get the group 
     156        $this->_group = cc_kaktus_query_group_dba::get_by_name($args[0], $this->_topic->id); 
     157         
     158        if (   empty($this->_group) 
     159            || !isset($this->_group->guid) 
     160            || !$this->_group->guid) 
     161        { 
     162            return false; 
     163        } 
     164         
     165        return true; 
     166    } 
    56167 
    57168    /** 
     
    62173    function _handler_view($handler_id, $args, &$data) 
    63174    { 
     175        $this->_order = cc_kaktus_query_navigation::get_order($this->_config->get('sort_order')); 
     176         
     177        // Set the toolbar items and process metadata 
     178        $this->_process_group(); 
     179         
     180        // Load the DM2 instance 
     181        $this->_load_datamanager(); 
     182         
     183        // Get AJAXed HTML and controllers 
     184        if ($this->_config->get('enable_ajax_editing')) 
     185        { 
     186            $ajax_data = array(); 
     187            cc_kaktus_query_viewer::get_ajax_html($this->_config, $this->_group->id, &$ajax_data); 
     188            $this->_view_html = $ajax_data['view_html']; 
     189        } 
     190         
    64191        return true; 
    65192    } 
     
    72199    function _show_view($handler_id, &$data) 
    73200    { 
     201        $data['datamanager'] =& $this->_datamanager; 
    74202        midcom_show_style('query-header'); 
    75203         
    76         // Show every query item 
    77         foreach ($this->_queries as $query) 
    78         { 
    79             $data['query'] =& $query; 
    80             $data['datamanager']->autoset_storage($query); 
    81              
    82             // Check if the current user has answered to the question 
    83             if (cc_kaktus_query_dba::has_answered()) 
     204        $this->_show_query_group($this->_group, &$data); 
     205         
     206        midcom_show_style('query-footer'); 
     207    } 
     208     
     209    /** 
     210     * Show a query group and subsequent child groups 
     211     *  
     212     * @access private 
     213     * @param cc_kaktus_query_group $group 
     214     */ 
     215    function _show_query_group($group, &$data) 
     216    { 
     217        $data['group'] =& $group; 
     218        $this->_datamanager->autoset_storage($group); 
     219         
     220        if ($this->_config->get('enable_ajax_editing')) 
     221        { 
     222            $data['view'] = $this->_view_html[$group->guid]; 
     223        } 
     224        else 
     225        { 
     226            $data['view'] = $this->_datamanager->get_content_html(); 
     227        } 
     228         
     229        // Show the group header 
     230        midcom_show_style('query-group-header'); 
     231         
     232        // Get the subgroups with a query builder 
     233        $qb = cc_kaktus_query_group_dba::new_query_builder(); 
     234        $qb->add_constraint('up', '=', $group->id); 
     235        $qb->add_order($this->_order['key'], $this->_order['order']); 
     236         
     237        // Show the subgroups 
     238        foreach ($qb->execute() as $subgroup) 
     239        { 
     240            $this->_show_query_group($subgroup, &$data); 
     241        } 
     242         
     243        // Get the questions with a query builder 
     244        $qb = cc_kaktus_query_question_dba::new_query_builder(); 
     245        $qb->add_constraint('up', '=', $group->id); 
     246        $qb->add_order('score', 'DESC'); 
     247         
     248        foreach ($qb->execute() as $question) 
     249        { 
     250            if ($this->_config->get('enable_ajax_editing')) 
    84251            { 
    85                 midcom_show_style('query-item-answered')
     252                $data['view'] = $this->_view_html[$question->guid]
    86253            } 
    87254            else 
    88255            { 
    89                 midcom_show_style('query-item'); 
     256                $this->_datamanager_question->autoset_storage($question); 
     257                $data['view'] = $this->_datamanager_question->get_content_html(); 
    90258            } 
    91         } 
    92         midcom_show_style('query-footer'); 
    93         echo "<pre>\n"; 
    94         $group = new cc_kaktus_query_group_dba(); 
    95         print_r($group); 
    96          
    97         $question = new cc_kaktus_query_question_dba(); 
    98         print_r($question); 
    99          
    100         $answer = new cc_kaktus_query_answer_dba(); 
    101         print_r($answer); 
    102         echo "</pre>\n"; 
     259             
     260            midcom_show_style('query-question'); 
     261        } 
     262         
     263        midcom_show_style('query-group-footer'); 
    103264    } 
    104265} 
  • branches/branch-2_6/src/cc.kaktus.query/locale/default.en.txt

    r11698 r11744  
    44---LANGUAGE en 
    55 
    6 ---STRING Only show approved articles 
    7 Only show approved articles 
     6---STRING queries 
     7Queries 
    88---STRINGEND 
    99 
    10 ---STRING activate autoindex 
    11 Automatically create an index page for this topic? 
     10---STRING query 
     11Query 
    1212---STRINGEND 
    1313 
    14 ---STRING approv
    15 Approv
     14---STRING scor
     15Scor
    1616---STRINGEND 
    1717 
    18 ---STRING article 
    19 Article 
     18---STRING oldest first 
     19Oldest first 
    2020---STRINGEND 
    2121 
    22 ---STRING auto_approved 
    23 Approve new articles by defaul
     22---STRING newest first 
     23Newest firs
    2424---STRINGEND 
    2525 
    26 ---STRING autoindex-notes 
    27 The index page replaces the article with the URL name index and consists of a list of all articles and attachments of the current topic. 
     26---STRING new query 
     27New query 
    2828---STRINGEND 
    2929 
    30 ---STRING back to overview 
    31 Back to overview 
     30---STRING sort order 
     31Sort order 
    3232---STRINGEND 
    3333 
    34 ---STRING content 
    35 Content 
     34---STRING amount of items to display in navigation 
     35Amount of items to display in navigation 
    3636---STRINGEND 
    3737 
    38 ---STRING create article 
    39 Create Article 
     38---STRING question group created 
     39Question group created 
    4040---STRINGEND 
    4141 
    42 ---STRING default_schema 
    43 Default schema for new articles 
     42---STRING create a question group 
     43Create a question group 
    4444---STRINGEND 
    4545 
    46 ---STRING delete article 
    47 Delete Article 
     46---STRING create a new question group 
     47Create a new question group 
    4848---STRINGEND 
    49  
    50 ---STRING directory index for %s 
    51 Directory index for %s 
    52 ---STRINGEND 
    53  
    54 ---STRING display settings 
    55 Article display configuration 
    56 ---STRINGEND 
    57  
    58 ---STRING edit article 
    59 Edit Article 
    60 ---STRINGEND 
    61  
    62 ---STRING file lastmodified 
    63 Last modified date 
    64 ---STRINGEND 
    65  
    66 ---STRING filedescription 
    67 File Description 
    68 ---STRINGEND 
    69  
    70 ---STRING filename 
    71 File Name 
    72 ---STRINGEND 
    73  
    74 ---STRING filesize 
    75 File Size 
    76 ---STRINGEND 
    77  
    78 ---STRING filetype 
    79 File Type 
    80 ---STRINGEND 
    81  
    82 ---STRING indexinnav 
    83 Show the index article in navigation? 
    84 ---STRINGEND 
    85  
    86 ---STRING net.nehmer.static 
    87 Regular content 
    88 ---STRINGEND 
    89  
    90 ---STRING no files in this directory 
    91 There are no files in this directory 
    92 ---STRINGEND 
    93  
    94 ---STRING no index article 
    95 This folder does not have an <strong>index</strong> article. Please create an article with URL name <strong>index</strong> or activate the autoindex mode to get started. 
    96 ---STRINGEND 
    97  
    98 ---STRING no schemas available 
    99 No Schemas available 
    100 ---STRINGEND 
    101  
    102 ---STRING schema settings 
    103 Data schema settings 
    104 ---STRINGEND 
    105  
    106 ---STRING schemadb 
    107 Schema database to use for this topic 
    108 ---STRINGEND 
    109  
    110 ---STRING select schema 
    111 Select Schema 
    112 ---STRINGEND 
    113  
    114 ---STRING settings 
    115 Settings 
    116 ---STRINGEND 
    117  
    118 ---STRING symlink_topic 
    119 Get content from another topic ("symlink") 
    120 ---STRINGEND 
    121  
    122 ---STRING symlink_topic disabled 
    123 No topic selected 
    124 ---STRINGEND 
    125  
    126 ---STRING taviewer 
    127 Static Content 
    128 ---STRINGEND 
    129  
    130 ---STRING unapprove 
    131 Unapprove 
    132 ---STRINGEND 
    133  
    134 ---STRING view article 
    135 View Article 
    136 ---STRINGEND 
    137  
    138 ---STRING visible 
    139 Should the topic be visible 
    140 ---STRINGEND 
    141  
    142 ---STRING ajax_enable 
    143 Enable AJAX on-site editing 
    144 ---STRINGEND 
    145  
  • branches/branch-2_6/src/cc.kaktus.query/locale/default.fi.txt

    r11698 r11744  
    33---CVS $Id: default.fi.txt 3903 2006-08-28 09:51:25Z bergie $ 
    44---LANGUAGE fi 
    5  
    6 ---STRING Only show approved articles 
    7 NÀytÀ vain hyvÀksytyt artikkelit 
    8 ---STRINGEND 
    9  
    10 ---STRING activate autoindex 
    11 Luo automaattinen sisÀllysluettelo kansiolle? 
    12 ---STRINGEND 
    13  
    14 ---STRING approve 
    15 HyvÀksy 
    16 ---STRINGEND 
    17  
    18 ---STRING article 
    19 Artikkeli 
    20 ---STRINGEND 
    21  
    22 ---STRING auto_approved 
    23 HyvÀksy uudet artikkelit oletuksena 
    24 ---STRINGEND 
    25  
    26 ---STRING autoindex-notes 
    27 SisÀllysluettelo korvaa index-artikkelin ja sisÀltÀÀ listan kaikista kansiossa olevista artikkeleista ja liitteistÀ. 
    28 ---STRINGEND 
    29  
    30 ---STRING back to overview 
    31 Takaisin etusivulle 
    32 ---STRINGEND 
    33  
    34 ---STRING content 
    35 SisÀltö 
    36 ---STRINGEND 
    37  
    38 ---STRING create article 
    39 Luo artikkeli 
    40 ---STRINGEND 
    41  
    42 ---STRING default_schema 
    43 Oletus-tietokantakuvaus uusille artikkeleille 
    44 ---STRINGEND 
    45  
    46 ---STRING delete article 
    47 Poista artikkeli 
    48 ---STRINGEND 
    49  
    50 ---STRING directory index for %s 
    51 Kansion %s sisÀllysluettelo 
    52 ---STRINGEND 
    53  
    54 ---STRING display settings 
    55 Artikkelien nÀkyvyysasetukset 
    56 ---STRINGEND 
    57  
    58 ---STRING edit article 
    59 Muokkaa artikkelia 
    60 ---STRINGEND 
    61  
    62 ---STRING file lastmodified 
    63 Viimeksi muokattu 
    64 ---STRINGEND 
    65  
    66 ---STRING filedescription 
    67 Kuvaus 
    68 ---STRINGEND 
    69  
    70 ---STRING filename 
    71 Tiedostonimi 
    72 ---STRINGEND 
    73  
    74 ---STRING filesize 
    75 Koko 
    76 ---STRINGEND 
    77  
    78 ---STRING filetype 
    79 Tyyppi 
    80 ---STRINGEND 
    81  
    82 ---STRING indexinnav 
    83 NÀytetÀÀnkö index-artikkeli navigaatiossa? 
    84 ---STRINGEND 
    85  
    86 ---STRING net.nehmer.static 
    87 Normaali sisÀltö 
    88 ---STRINGEND 
    89  
    90 ---STRING no files in this directory 
    91 Ei tiedostoja kansiossa 
    92 ---STRINGEND 
    93  
    94 ---STRING no index article 
    95 Kansiosta puuttuu <strong>index</strong>-artikkeli. Luo artikkeli jonka tiedostonimenÀ on <strong>index</strong> tai laita automaattinen sisÀllysluettelo pÀÀlle. 
    96 ---STRINGEND 
    97  
    98 ---STRING no schemas available 
    99 Tietokantakuvausta (schema) ei löydy 
    100 ---STRINGEND 
    101  
    102 ---STRING schema settings 
    103 Tietokantakuvauksen asetukset 
    104 ---STRINGEND 
    105  
    106 ---STRING schemadb 
    107 TÀssÀ kansiossa kÀytettÀvÀ tietokantakuvaus 
    108 ---STRINGEND 
    109  
    110 ---STRING select schema 
    111 Valitse tyyppi 
    112 ---STRINGEND 
    113  
    114 ---STRING settings 
    115 Asetukset 
    116 ---STRINGEND 
    117  
    118 ---STRING symlink_topic 
    119 Hae sisÀllöt toisesta kansiosta ("symlink") 
    120 ---STRINGEND 
    121  
    122 ---STRING symlink_topic disabled 
    123 Ei kansiota 
    124 ---STRINGEND 
    125  
    126 ---STRING taviewer 
    127 Staattinen sisÀltö 
    128 ---STRINGEND 
    129  
    130 ---STRING unapprove 
    131 Poista hyvÀksyntÀ 
    132 ---STRINGEND 
    133  
    134 ---STRING view article 
    135 NÀytÀ artikkeli 
    136 ---STRINGEND 
    137  
    138 ---STRING visible 
    139 Onko kansio nÀkyvissÀ 
    140 ---STRINGEND 
    141  
    142 ---STRING ajax_enable 
    143 Salli sisÀllön muokkaaminen AJAXilla suoraan sivulla 
    144 ---STRINGEND 
    145  
  • branches/branch-2_6/src/cc.kaktus.query/navigation.php

    r11698 r11744  
    3232    function get_leaves() 
    3333    { 
    34         return array(); 
     34        // Return empty result set if configured 
     35        if ($this->_config->get('display_in_navigation') == 0) 
     36        { 
     37            return array(); 
     38        } 
    3539         
    36         /* 
    37         // Prepare everything 
    38         $leaves = array (); 
    39  
    40         foreach ($result as $article) 
     40        $qb = cc_kaktus_query_group_dba::new_query_builder(); 
     41        $qb->add_constraint('node', '=', $this->_topic->id); 
     42         
     43        $order = cc_kaktus_query_navigation::get_order($this->_config->get('sort_order')); 
     44         
     45        $qb->add_order($order['key'], $order['order']); 
     46        $qb->set_limit($this->_config->get('display_in_navigation')); 
     47         
     48        foreach ($qb->execute() as $group) 
    4149        { 
    42             $leaves[$article->id] = array 
     50            $leaves[$group->guid] = array 
    4351            ( 
    44                 MIDCOM_NAV_SITE => Array 
     52                MIDCOM_NAV_SITE => array 
    4553                ( 
    46                     MIDCOM_NAV_URL => "{$article->name}.html", 
    47                     MIDCOM_NAV_NAME => ($article->title != '') ? $article->title : $article->name 
     54                    MIDCOM_NAV_URL => "{$group->name}/", 
     55                    MIDCOM_NAV_NAME => $group->title, 
    4856                ), 
    4957                MIDCOM_NAV_ADMIN => null, 
    50                 MIDCOM_NAV_GUID => $article->guid, 
    51                 MIDCOM_NAV_OBJECT => $article
    52                 MIDCOM_META_CREATOR => $article->creator, 
    53                 MIDCOM_META_EDITOR => $article->revisor, 
    54                 MIDCOM_META_CREATED => $article->created, 
    55                 MIDCOM_META_EDITED => $article->revised 
     58                MIDCOM_NAV_GUID => $group->guid, 
     59                MIDCOM_NAV_OBJECT => $group
     60                MIDCOM_META_CREATOR => $group->creator, 
     61                MIDCOM_META_EDITOR => $group->revisor, 
     62                MIDCOM_META_CREATED => $group->created, 
     63                MIDCOM_META_EDITED => $group->revised, 
    5664            ); 
    57  
    5865        } 
     66         
    5967        return $leaves; 
    60         /* */ 
     68    } 
     69     
     70    /** 
     71     * Get the navigation order as an array 
     72     *  
     73     * @access static public 
     74     */ 
     75    function get_order($order) 
     76    { 
     77        $orders = array 
     78        ( 
     79            'key' => 'created', 
     80            'order' => 'ASC', 
     81        ); 
     82         
     83        if (preg_match('/\sDESC$/i', $order)) 
     84        { 
     85            $orders['order'] = 'DESC'; 
     86        } 
     87         
     88        if (preg_match('/([^\s])/', $order, $regs)) 
     89        { 
     90            switch (strtolower($regs[1])) 
     91            { 
     92                case 'score': 
     93                case 'start': 
     94                case 'created': 
     95                case 'revised': 
     96                case 'metadata.created': 
     97                case 'metadata.revised': 
     98                    $orders['key'] = $regs[1]; 
     99                    break; 
     100            } 
     101        } 
     102         
     103        return $orders; 
    61104    } 
    62105} 
  • branches/branch-2_6/src/cc.kaktus.query/style/query-footer.php

    r11698 r11744  
    11</div> 
     2<?php 
     3// TODO: tÀnne kerÀilijÀ, jolla haetaan kaikki edellisen divin sisÀllÀ olevat sortablet 
     4?> 
  • branches/branch-2_6/src/cc.kaktus.query/viewer.php

    r11698 r11744  
    3535         
    3636        // Show the latest configured amount of queries 
     37        // Match /latest/ 
    3738        $this->_request_switch['latest_list'] = array 
    3839        ( 
     
    4647            'handler' => array('cc_kaktus_query_handler_view', 'view'), 
    4748            'fixed_args' => array('latest'), 
     49            'variable_args' => 1, 
     50        ); 
     51         
     52        // AJAX creation wizard 
     53        // Match /ajax/create/<type> 
     54        $this->_request_switch['ajax_create'] = array 
     55        ( 
     56            'handler' => array('cc_kaktus_query_handler_ajax', 'create'), 
     57            'fixed_args' => array('ajax', 'create'), 
    4858            'variable_args' => 1, 
    4959        ); 
     
    7181            'handler' => array('cc_kaktus_query_handler_edit', 'edit'), 
    7282            'fixed_args' => array('edit'), 
     83            'variable_args' => 1, 
     84        ); 
     85         
     86        // View a question group 
     87        // Match /<question group guid>/ 
     88        $this->_request_switch['view_group'] = array 
     89        ( 
     90            'handler' => array('cc_kaktus_query_handler_view', 'view'), 
    7391            'variable_args' => 1, 
    7492        ); 
     
    98116                MIDCOM_TOOLBAR_URL => "create/", 
    99117                MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('new query'), 
    100                 MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock-new.png', 
     118                MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_new.png', 
    101119            ) 
    102120        ); 
     
    111129    { 
    112130        $this->_request_data['schemadb_group'] = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_group')); 
    113 //        $this->_request_data['schemadb_question'] = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_question')); 
     131        $this->_request_data['schemadb_question'] = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_question')); 
    114132         
    115133        // Not needed everywhere, only when answering 
     
    130148        return true; 
    131149    } 
     150     
     151    /** 
     152     * Get AJAXed HTML for miscellaneous purposes 
     153     *  
     154     * @param midcom_helper_configuration $config    Component configuration 
     155     * @param int $id                                ID of the question group root 
     156     * @access static public 
     157     * @return Array 
     158     */ 
     159    function get_ajax_html($config, $id, &$ajax_data) 
     160    { 
     161        if (!$config->get('enable_ajax_editing')) 
     162        { 
     163            $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 'Method <i>get_ajax_html</i> may be used only when AJAX editing is enabled'); 
     164            // This will exit 
     165        } 
     166         
     167        // Get the controllers if they haven't yet been defined 
     168        if (!isset($ajax_data['controller_group'])) 
     169        { 
     170            // Get the schemas 
     171            $schemadb_group = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_group')); 
     172             
     173            // Get the controller 
     174            $controller_group = midcom_helper_datamanager2_controller::create('ajax'); 
     175            $controller_group->schemadb =& $schemadb_group; 
     176             
     177            $ajax_data['controller_group'] =& $controller_group; 
     178        } 
     179         
     180        // Get the controllers if they haven't yet been defined 
     181        if (!isset($ajax_data['controller_question'])) 
     182        { 
     183            // Get the schemas 
     184