Exemple #1
0
    public function external_hook($hook)
    {
        switch ($hook) {
            case 'public':
                $faq_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false;
                $hash = isset($_REQUEST['hash']) ? trim($_REQUEST['hash']) : false;
                if ($faq_id && $hash) {
                    $correct_hash = $this->link_open_public($faq_id, true);
                    if ($correct_hash == $hash) {
                        $faq = array();
                        if ($faq_id > 0) {
                            $faq = $this->get_faq($faq_id);
                        }
                        if ($faq) {
                            $template = module_template::get_template_by_key('faq_item');
                            $faq['answer'] = self::html_faq($faq['answer']);
                            $faq['faq_back'] = $this->link_open_public(-1) . (isset($_REQUEST['faq_product_id']) ? '&faq_product_id=' . (int) $_REQUEST['faq_product_id'] : '');
                            $template->assign_values($faq);
                            $template->page_title = $faq['question'];
                            echo $template->render('pretty_html');
                        } else {
                            $template = module_template::get_template_by_key('faq_list');
                            $data = array();
                            ob_start();
                            include 'public/faq_listing.php';
                            $data['listing'] = ob_get_clean();
                            $template->assign_values($data);
                            $template->page_title = _l('FAQ');
                            echo $template->render('pretty_html');
                        }
                    }
                }
                break;
            case 'faq_list_json':
                @ob_end_clean();
                header("Content-type: text/javascript");
                $faq_id = isset($_REQUEST['faq_id']) ? (int) $_REQUEST['faq_id'] : false;
                if ($faq_id > 0) {
                    $faq = $this->get_faq($faq_id);
                    if ($faq) {
                        $faq['url'] = module_faq::link_open_public($faq_id, false);
                        echo json_encode($faq);
                        /*$template = module_template::get_template_by_key('faq_item');
                          $faq['answer'] = forum_text($faq['answer']);
                          $faq['faq_back'] = $this->link_open_public(-1).(isset($_REQUEST['faq_product_id']) ? '&faq_product_id='.(int)$_REQUEST['faq_product_id'] : '');
                          $template->assign_values($faq);
                          $template->page_title = $faq['question'];
                          echo $template->replace_content();*/
                    }
                    exit;
                }
                $faq_product_id = isset($_REQUEST['faq_product_id']) ? (int) $_REQUEST['faq_product_id'] : false;
                $faq_search = isset($_REQUEST['faq_search']) ? $_REQUEST['faq_search'] : false;
                $faqs = $this->get_faqs(array('faq_product_id' => $faq_product_id, 'question' => $faq_search));
                $faqs_json = array();
                $all_products = module_faq::get_faq_products_rel();
                foreach ($faqs as $faq) {
                    $faq = module_faq::get_faq($faq['faq_id']);
                    $faq_products = array();
                    foreach ($faq['faq_product_ids'] as $faq_product_id) {
                        $faq_products[$faq_product_id] = $all_products[$faq_product_id];
                    }
                    $faqs_json[$faq['faq_id']] = array('question' => $faq['question'], 'url' => module_faq::link_open_public($faq['faq_id'], false), 'products' => $faq_products);
                }
                echo json_encode($faqs_json);
                exit;
                break;
            case 'ticket_list':
                $faq_product_id = isset($_REQUEST['faq_product_id']) ? (int) $_REQUEST['faq_product_id'] : false;
                @ob_end_clean();
                header("Content-type: text/javascript");
                if ($faq_product_id) {
                    $product = $this->get_faq_product($faq_product_id);
                    // find the faq items that match this product id.
                    if ($product && $product['faq_product_id'] == $faq_product_id) {
                        $faqs = $this->get_faqs(array('faq_product_id' => $faq_product_id));
                        ob_start();
                        $x = 0;
                        $half = ceil(count($faqs) / 2);
                        ?>

                        <tr>
                            <th>
                                <?php 
                        _e('FAQ');
                        ?>

                            </th>
                            <td>
                                <?php 
                        _e('Please read through the below FAQ to see if the question has already been answered');
                        ?>

                        </tr>
                        <tr>
                            <td colspan="2">
                                <table width="100%" class="tableclass tableclass_full table_faq_class">
                                    <tbody>
                                    <tr>
                                        <td width="50%" valign="top">
                                            <ul><?php 
                        for (true; $x < $half; $x++) {
                            $data = array_shift($faqs);
                            $faq = module_faq::get_faq($data['faq_id']);
                            ?>

                                                    <li>
                                                        <a href="<?php 
                            echo module_faq::link_open_public($data['faq_id'], false);
                            ?>
" target="_blank"><?php 
                            echo htmlspecialchars($faq['question']);
                            ?>
</a>
                                                    </li>
                                                    <?php 
                        }
                        ?>

                                            </ul>
                                        </td>
                                        <td width="50%" valign="top">
                                            <ul><?php 
                        foreach ($faqs as $data) {
                            $faq = module_faq::get_faq($data['faq_id']);
                            ?>

                                                    <li>
                                                        <a href="<?php 
                            echo module_faq::link_open_public($data['faq_id'], false);
                            ?>
" target="_blank"><?php 
                            echo htmlspecialchars($faq['question']);
                            ?>
</a>
                                                    </li>
                                                    <?php 
                        }
                        ?>

                                            </ul>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>

                            </td>
                        </tr>
                        <?php 
                        $html = preg_replace('#\\s+#', ' ', ob_get_clean());
                        ?>

                        $('#faq_product_area').html('<?php 
                        echo addcslashes($html, "'");
                        ?>
');
                        <?php 
                        if ($product['default_type_id']) {
                            ?>

                            $('#ticket_type_id').val(<?php 
                            echo (int) $product['default_type_id'];
                            ?>
);
                        <?php 
                        }
                        // and now we have to set the ticket position.
                        if (module_config::c('ticket_show_position', 1)) {
                            $new_position = module_ticket::ticket_position(false, $faq_product_id);
                            ?>

                            $('#ticket_position_field').html('<?php 
                            echo addcslashes(_l('%s out of %s other support tickets', ordinal($new_position['current'] + 1), $new_position['total'] + 1), "'");
                            ?>
');
                            <?php 
                            if (module_config::c('ticket_allow_priority', 0)) {
                                $c = module_ticket::get_ticket_count($faq_product_id);
                                ?>

                                $('#priority_ticket_position').html('<?php 
                                _e('%s out of %s', ordinal($c['priority'] + 1), $new_position['total'] + 1);
                                ?>
');
                                <?php 
                            }
                        }
                        exit;
                    }
                }
                ?>
  $('#faq_product_area').html(''); <?php 
                if (module_config::c('ticket_show_position', 1)) {
                    $new_position = module_ticket::ticket_position();
                    ?>

                    $('#ticket_position_field').html('<?php 
                    echo addcslashes(_l('%s out of %s other support tickets', ordinal($new_position['current'] + 1), $new_position['total'] + 1), "'");
                    ?>
');
                    <?php 
                    if (module_config::c('ticket_allow_priority', 0)) {
                        ?>

                        $('#priority_ticket_position').html('<?php 
                        _e('%s out of %s', ordinal(module_ticket::ticket_count('priority') + 1), $new_position['total'] + 1);
                        ?>
');
                        <?php 
                    }
                }
                break;
        }
    }
Exemple #2
0
    ?>
            <th><?php 
    echo _l('Action');
    ?>
</th>
            <?php 
    //}
    ?>
        </tr>
        </thead>
        <tbody>
            <?php 
    $c = 0;
    $products = module_faq::get_faq_products_rel();
    foreach ($faqs as $faq_id => $data) {
        $faq = module_faq::get_faq($faq_id);
        ?>
            <tr class="<?php 
        echo $c++ % 2 ? "odd" : "even";
        ?>
">
                <td nowrap="">
                    <?php 
        if (module_faq::can_i('edit', 'FAQ')) {
            echo module_faq::link_open($faq_id, true);
        } else {
            ?>
 <a href="<?php 
            echo str_replace('display_mode=iframe', '', module_faq::link_open_public($faq_id));
            ?>
" target="_blank"><?php 
Exemple #3
0
        ?>
</th>
            <?php 
    }
    ?>
        </tr>
        </thead>
        <?php 
}
?>
        <tbody>
        <?php 
$c = 0;
$products = module_faq::get_faq_products_rel();
foreach ($faqs as $data) {
    $faq = module_faq::get_faq($data['faq_id']);
    ?>
        <tr class="<?php 
    echo $c++ % 2 ? "odd" : "even";
    ?>
">
            <td nowrap="">
                <a href="<?php 
    echo module_faq::link_open_public($data['faq_id'], false);
    ?>
&faq_product_id=<?php 
    echo isset($search['faq_product_id']) ? (int) $search['faq_product_id'] : '';
    ?>
"><?php 
    echo htmlspecialchars($faq['question']);
    ?>
Exemple #4
0

	</form>

	<?php 
} else {
    $header = array('title' => _l('FAQs'), 'type' => 'h2', 'main' => true, 'button' => array());
    if (module_faq::can_i('create', 'FAQ')) {
        $header['button'] = array('url' => module_faq::link_open('new'), 'title' => _l('Add New FAQ'), 'type' => 'add');
    }
    print_heading($header);
    $products = module_faq::get_faq_products_rel();
    /** START TABLE LAYOUT **/
    $table_manager = module_theme::new_table_manager();
    $columns = array();
    $columns['question'] = array('title' => _l('Question'), 'callback' => function ($faq) {
        echo module_faq::link_open($faq['faq_id'], true);
    }, 'cell_class' => 'row_action');
    $columns['linked_products'] = array('title' => _l('Linked FAQ Products'), 'callback' => function ($faq) {
        $faq = module_faq::get_faq($faq['faq_id']);
        foreach ($faq['faq_product_ids'] as $faq_product_id) {
            echo module_faq::link_open_faq_product($faq_product_id, true) . " ";
        }
    });
    $table_manager->set_id('faq_list');
    $table_manager->set_columns($columns);
    $table_manager->set_rows($faqs);
    $table_manager->pagination = true;
    $table_manager->print_table();
    /** END TABLE LAYOUT **/
}