/**
  * @param string $module
  * @param array $fields
  * @return string
  */
 public static function requireTableForExternalModule($module = P, $fields = [])
 {
     $data = new CustomSettingRepository();
     $data->setWhereModule($module);
     $data->getAsArrayOfObjectData();
     foreach ($data->getAsArrayOfObjectData() as $key => $field) {
         // Any existing data
         if (isset($fields[$field['key']])) {
             $field = array_merge($fields[$field['key']], $field);
         }
         // Supplied data
         if (!isset($field['module'])) {
             $field['module'] = P;
         }
         $field['title'] = Converter::symb2Ttl($field['key']);
         $field['type'] = $field['input_type'];
         $options_array = [];
         if ($field['input_options'] && is_string($field['input_options'])) {
             $options_array = json_decode($field['input_options'], JSON_OBJECT_AS_ARRAY);
         }
         // Validators and editors
         if (isset($options_array['editor_wysiwyg'])) {
             $field['edit'] = 'wysiwyg';
         }
         if (isset($options_array['editor_files'])) {
             $field['edit'] = 'files';
         }
         if (isset($options_array['editor_pages'])) {
             $field['edit'] = 'pages';
         }
         if (isset($options_array['require'])) {
             $field['required'] = true;
             $field['validate']['require'] = true;
         }
         if (isset($options_array['is_digit'])) {
             $field['validate']['is_digit'] = true;
         }
         if (isset($options_array['alphanum'])) {
             $field['validate']['alphanum'] = true;
         }
         if (isset($options_array['url'])) {
             $field['validate']['url'] = true;
         }
         if (isset($options_array['email'])) {
             $field['validate']['email'] = true;
         }
         // Input Type
         if ($field['input_type'] == 'select') {
             $field['options'] = ModuleSettings::getSelectTypeSettingOption(P, $field['key']);
         }
         $fields[$field['key']] = $field;
     }
     if (!$fields) {
         return false;
     }
     $form_array = ['action' => '?p=' . P . '&do=_settings', 'button' => __('Update'), 'fields' => $fields];
     return CmsFormHelper::outputForm(self::$tables['settings'], $form_array)->enableAjax();
 }
 public function edit()
 {
     $id = abs((int) $_GET['id']);
     if (!$id) {
         return;
     }
     $subscriber = new EmailSubscriberEntity($id);
     echo BreadCrumbs::getInstance()->addCrumb(Converter::symb2Ttl(P), '?p=' . P)->addCrumb('Edit Email Subscriber')->addCrumb($subscriber->getEmail());
     echo self::__subscribers_form($subscriber)->setAction('?p=' . P . '&do=_edit&id=' . $id);
 }
 /** View one */
 public function view()
 {
     if (!isset($_GET['id']) || !ctype_digit((string) $_GET['id'])) {
         return;
     }
     $feedback_id = $_GET['id'];
     $feedback = new Feedback($feedback_id);
     if (!$feedback) {
         return;
     }
     $feedback_data = $feedback->getAsArray();
     $form = CmsForm::getInstance()->outputTagForm(false);
     $feedback_data['date_created'] = date(CFG_CMS_DATETIME_FORMAT, $feedback_data['date_created']);
     unset($feedback_data['id']);
     unset($feedback_data['client_id']);
     foreach ($feedback_data as $k => $item) {
         if (!is_string($item)) {
             continue;
         }
         $form->addField(Converter::symb2Ttl($k), CmsHtml::getInstance($k)->value(htmlspecialchars($item, ENT_QUOTES)));
     }
     echo $form;
 }
Exemplo n.º 4
0
 /**
  * Data for HTML <head> generation
  */
 private function prepareHead()
 {
     $config = Configuration::getInstance();
     // Favicon url
     $favicon = !empty($config->get('cms')['favicon']) ? $config->get('cms')['favicon'] : DIR_CMS_IMAGES_URL . 'logo_square.png';
     // Prepare page HTML for head
     PageHead::getInstance()->addHtmlTagAttributes('lang="en" class="no-js"')->setTitle((P_DO !== '_default' ? Converter::symb2Ttl(P_DO) : 'Main') . ' / ' . Converter::symb2Ttl(P) . ' / ' . $config->get('site')['name'] . ' / ' . CMS_NAME . ' v. ' . CMS_VERSION)->setFavicon($favicon)->addMeta('name=' . CMS_NAME . ' - ' . $config->get('site')['name'] . '; action-uri=http://' . CFG_DOMAIN . '/cms/; icon-uri=http://' . DIR_CMS_IMAGES_URL . 'logo_square.png', 'msapplication-task')->addMeta('width=device-width, initial-scale=1', 'viewport')->addMeta('IE=edge', '', 'X-UA-Compatible')->addClassToBody('page-header-fixed')->addClassToBody('page-quick-sidebar-over-content')->addCssUrl('cms/fonts/open-sans.css')->addCssUrl('cms/plugins/font-awesome/font-awesome.css')->addCssUrl('cms/plugins/simple-line-icons/simple-line-icons.css')->addCssUrl('cms/plugins/bootstrap/css/bootstrap.css')->addCssUrl('cms/plugins/uniform/css/uniform.default.css')->addCssUrl('cms/plugins/bootstrap-switch/css/bootstrap-switch.css')->addCssUrl('cms/plugins/pace/pace-theme-minimal.css')->addCssUrl('cms/plugins/select2/select2.css')->addCssUrl('cms/css/components.css')->addCssUrl('cms/css/plugins.css')->addCssUrl('cms/layout/css/layout.css')->addCssUrl('cms/layout/css/themes/default.css')->addCssUrl('cms/layout/css/custom.css')->addCssUrl('plugins/toastr/toastr.min.css')->addJsUrl('cms/jquery-1.11.0.min.js')->addJsUrl(DIR_CMS_SCRIPTS_URL . 'jquery.form.min.js')->addJs('var cms_data = {};')->addJs('cms_data.cfg_domain="' . CFG_DOMAIN . '"')->addJs('cms_data.site_name="' . $config->get('site')['name'] . '"')->addJsUrl('cms_js.js')->addJsUrl('plupload/plupload.full.min.js');
     // Script for sending JS errors
     if (CFG_MAIL_ERRORS && Settings::isProductionState() && !Settings::get('do_not_send_js_errors')) {
         PageHead::getInstance()->addJsUrl('send_error.js')->addJs('register_js_error.ini(\'' . DIR_CMS_URL . '\');');
     }
     PageTail::getInstance()->addJsUrl('cms/jquery-migrate-1.2.1.min.js')->addJsUrl('cms/plugins/jquery-ui/jquery-ui-1.10.3.custom.min.js')->addJsUrl('cms/plugins/bootstrap/js/bootstrap.min.js')->addJsUrl('cms/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js')->addJsUrl('cms/plugins/jquery-slimscroll/jquery.slimscroll.min.js')->addJsUrl('cms/jquery.blockui.min.js')->addJsUrl('cms/jquery.cokie.min.js')->addJsUrl('cms/plugins/uniform/jquery.uniform.min.js')->addJsUrl('cms/plugins/bootstrap-switch/js/bootstrap-switch.min.js')->addCssUrl('cms/plugins/jquery-contextmenu/jquery.contextMenu.css')->addJsUrl('cms/plugins/jquery-contextmenu/jquery.contextMenu.js')->addJsUrl('cms/plugins/jquery-validation/js/jquery.validate.min.js')->addJsUrl('cms/plugins/backstretch/jquery.backstretch.min.js')->addJsUrl('cms/plugins/select2/select2.min.js')->addJsUrl('cms/metronic.js')->addJsUrl('cms/layout/scripts/layout.js')->addJsUrl('cms/layout/scripts/quick-sidebar.js')->addJsUrl('cms/plugins/pace/pace.js')->addCssUrl('cms/cms_css.css')->addJsUrl('plugins/toastr/toastr.min.js')->addJsUrl('plugins/parsley.min.js')->addJsUrl('cms/respond.min.js')->addJsUrl('cms/excanvas.min.js')->addJs('$(function() {
            $(".chosen").select2();
            Metronic.init();
            Layout.init();
            QuickSidebar.init();
         });');
     // Search for custom css
     $custom_css_url = DIR_ASSETS_URL . 'cms.css';
     if (file_exists(DIR_BASE . $custom_css_url)) {
         PageHead::getInstance()->addCssUrl($custom_css_url);
     } else {
         PageHead::getInstance()->addCustomString('<!--Create file "' . $custom_css_url . '" if you wish to use custom css file-->');
     }
     // Set head for page
     Page::setHead(PageHead::getInstance());
 }
Exemplo n.º 5
0
 /**
  * Get values avaiable for column in table
  * @param string $table
  * @param string $column
  * @return array
  */
 public static function getEnumPairs($table, $column)
 {
     $result = self::q_assoc_row('SHOW COLUMNS FROM `' . self::sql_prepare($table) . '` WHERE `field` = "' . self::sql_prepare($column) . '"');
     $result = str_replace(["enum('", "')", "''"], ['', '', "'"], $result['Type']);
     $result = explode("','", $result);
     $res = [];
     foreach ($result as $v) {
         $res[$v] = Converter::symb2Ttl($v);
     }
     return $res;
 }
Exemplo n.º 6
0
 private static function combineParamsFromDB($table, array $order_keys)
 {
     // Fields from DB
     $fields = $types = SQL::getFieldsWithAllData($table);
     unset($fields['id']);
     // Sort to match defined order for form
     $sorted = $not_sorted = [];
     foreach ($fields as $k => $v) {
         if (($key = array_search($k, $order_keys)) !== false) {
             $sorted[$key] = $k;
         } else {
             $not_sorted[] = $k;
         }
     }
     ksort($sorted);
     $fields = array_merge($sorted, $not_sorted);
     $params = [];
     foreach ($fields as $v) {
         $field = [];
         $type = $types[$v]['Type'];
         if (strpos($type, 'text') !== false) {
             $field['type'] = 'textarea';
         }
         if (strpos($type, 'enum') !== false) {
             $field['type'] = 'select';
             $field['options'] = SQL::getEnumPairs($table, $types[$v]['Field']);
         }
         $field['name'] = Converter::symb2Ttl($v);
         $params[$v] = $field;
     }
     return $params;
 }
Exemplo n.º 7
0
    /**
     * @return string
     */
    public function __toString()
    {
        ob_start();
        ?>
        <script>
            function search_in_main_menu() {
                var $el = $('#menu_search_input');
                var text = $el.val();
                <?php 
        // TODO hide element in menu that are not found by indexOf
        ?>
            }
        </script>
        <div class="page-sidebar-wrapper">
            <div class="page-sidebar navbar-collapse collapse">
                <ul class="page-sidebar-menu" data-auto-scroll="true" data-slide-speed="200">
                    <li class="sidebar-search-wrapper hidden-xs">
                        <div class="sidebar-search sidebar-search-bordered sidebar-search-solid">
<!--                            <div class="input-group">-->
<!--                                <input type="text" id="menu_search_input" autofocus class="form-control" placeholder="Search..." onkeyup="search_in_main_menu();">-->
<!--                                <span class="input-group-btn">-->
<!--                                    <a href="javascript:;" class="btn submit"><i class="icon-magnifier"></i></a>-->
<!--                                </span>-->
<!--                            </div>-->
                        </div>
                    </li>
                    <?php 
        foreach ($this->_menu as $k => $v) {
            ?>
                    <li class="<?php 
            echo P == $k ? 'active open' : '';
            ?>
">
                        <a href="#">
                            <?php 
            // TODO set icons in pages or menu file
            ?>
<!--                            <i class="icon-basket"></i>-->
                            <span class="title"><?php 
            echo __($v['title']);
            ?>
</span>
                            <span class="arrow "></span>
                        </a>
                        <?php 
            if (isset($this->_menu[$k]['items']) && is_array($this->_menu[$k]['items'])) {
                ?>
                            <ul class="sub-menu">
                                <?php 
                foreach ($this->_menu[$k]['items'] as $k_in => $v_in) {
                    ?>
                                <li class="<?php 
                    echo P == $k && P_DO == $k_in ? 'active' : '';
                    ?>
">
                                    <a href="?p=<?php 
                    echo $k . '&do=' . $k_in;
                    ?>
">
                                        <?php 
                    // TODO set icons in pages or menu file
                    ?>
<!--                                        <i class="icon-home"></i>-->
                                        <?php 
                    echo __($v_in['title']);
                    ?>
                                        <?php 
                    if (isset($this->menu_labels[$k][$k_in])) {
                        // TODO badges
                        ?>
                                            <span class="badge badge-roundless badge-warning">
                                                <?php 
                        echo __($this->menu_labels[$k][$k_in]);
                        ?>
                                            </span>
                                        <?php 
                    }
                    ?>
                                    </a>
                                </li>
                                <?php 
                }
                ?>
                            </ul>
                        <?php 
            }
            ?>
                    </li>
                    <?php 
        }
        ?>

                    <?php 
        // TODO multilevel menu items
        ?>
<!--                    <li>-->
<!--                        <a href="javascript:;">-->
<!--                            <i class="icon-folder"></i>-->
<!--                            <span class="title">Multi Level Menu</span>-->
<!--                            <span class="arrow "></span>-->
<!--                        </a>-->
<!--                        <ul class="sub-menu">-->
<!--                            <li>-->
<!--                                <a href="javascript:;">-->
<!--                                    <i class="icon-settings"></i> Item 1 <span class="arrow"></span>-->
<!--                                </a>-->
<!--                                <ul class="sub-menu">-->
<!--                                    <li>-->
<!--                                        <a href="javascript:;">-->
<!--                                            <i class="icon-user"></i>-->
<!--                                            Sample Link 1 <span class="arrow"></span>-->
<!--                                        </a>-->
<!--                                        <ul class="sub-menu">-->
<!--                                            <li>-->
<!--                                                <a href="#"><i class="icon-power"></i> Sample Link 1</a>-->
<!--                                            </li>-->
<!--                                            <li>-->
<!--                                                <a href="#"><i class="icon-paper-plane"></i> Sample Link 1</a>-->
<!--                                            </li>-->
<!--                                            <li>-->
<!--                                                <a href="#"><i class="icon-star"></i> Sample Link 1</a>-->
<!--                                            </li>-->
<!--                                        </ul>-->
<!--                                    </li>-->
<!--                                    <li>-->
<!--                                        <a href="#"><i class="icon-camera"></i> Sample Link 1</a>-->
<!--                                    </li>-->
<!--                                    <li>-->
<!--                                        <a href="#"><i class="icon-link"></i> Sample Link 2</a>-->
<!--                                    </li>-->
<!--                                    <li>-->
<!--                                        <a href="#"><i class="icon-pointer"></i> Sample Link 3</a>-->
<!--                                    </li>-->
<!--                                </ul>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <a href="javascript:;">-->
<!--                                    <i class="icon-globe"></i> Item 2 <span class="arrow"></span>-->
<!--                                </a>-->
<!--                                <ul class="sub-menu">-->
<!--                                    <li>-->
<!--                                        <a href="#"><i class="icon-tag"></i> Sample Link 1</a>-->
<!--                                    </li>-->
<!--                                    <li>-->
<!--                                        <a href="#"><i class="icon-pencil"></i> Sample Link 1</a>-->
<!--                                    </li>-->
<!--                                    <li>-->
<!--                                        <a href="#"><i class="icon-graph"></i> Sample Link 1</a>-->
<!--                                    </li>-->
<!--                                </ul>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <a href="#">-->
<!--                                    <i class="icon-bar-chart"></i>-->
<!--                                    Item 3 </a>-->
<!--                            </li>-->
<!--                        </ul>-->
<!--                    </li>-->

                </ul>
            </div>
        </div>
        <?php 
        return ob_get_clean();
        ?>



        <aside class="sidebar offscreen-left">
            <p class="nav-top-overlay"></p>
            <nav class="main-navigation custom_scrollbar" data-height="auto" data-size="6px" data-distance="0" data-rail-visible="true" data-wheel-step="10">
                <ul class="nav">
                    <?php 
        foreach ($this->_menu as $k => $v) {
            // Current module - rebder all submenu items
            if (P == $k) {
                ?>
                            <li class="open">
                                <a href="">
                                    <i class="ti-home"></i>
                                    <span><?php 
                echo __(Converter::symb2Ttl(is_array($v) ? $v[$k] : $v));
                ?>
</span>
                                </a>
                                <ul class="sub-menu" style="display: block;">
                                    <li class="<?php 
                echo P_DO == '_default' ? ' active' : '';
                ?>
">
                                        <a href="/cms?p=<?php 
                echo P;
                ?>
">
                                            <i class="ti-arrow-right"></i>
                                            <span><?php 
                echo __('Main');
                ?>
</span>
                                            <?php 
                if (isset($this->menu_labels[P]['_default'])) {
                    ?>
                                                <span class="pull-right small label label-info animated flash">
                                                    <?php 
                    echo __($this->menu_labels[P]['_default']);
                    ?>
                                                </span>
                                            <?php 
                }
                ?>
                                        </a>
                                    </li>
                                    <?php 
                if (isset($this->_menu[P]) && is_array($this->_menu[P])) {
                    // Have subitems
                    ?>
                                        <?php 
                    foreach ($this->_menu[P] as $k_in => $v_in) {
                        if (!isset($first)) {
                            $first = true;
                            // Skip main menu item
                            continue;
                        }
                        ?>
                                            <li class="<?php 
                        echo P_DO == $k_in ? ' active' : '';
                        ?>
">
                                                <a href="/cms?p=<?php 
                        echo P . '&do=' . $k_in;
                        ?>
">
                                                    <i class="ti-arrow-right"></i>
                                                    <span><?php 
                        echo __(Converter::symb2Ttl($v_in));
                        ?>
</span>
                                                    <?php 
                        if (isset($this->menu_labels[P][$k_in])) {
                            ?>
                                                        <span class="pull-right small label label-danger animated flash">
                                                            <?php 
                            echo __($this->menu_labels[P][$k_in]);
                            ?>
                                                        </span>
                                                    <?php 
                        }
                        ?>
                                                </a>
                                            </li>
                                        <?php 
                    }
                    ?>
                                    <?php 
                }
                ?>
                                </ul>
                            </li>
                        <?php 
            } else {
                ?>
                            <li>
                                <a href="/cms?p=<?php 
                echo $k;
                ?>
">
                                    <span><?php 
                echo __(Converter::symb2Ttl(is_array($v) ? $v[$k] : $v));
                ?>
</span>
                                </a>
                            </li>
                        <?php 
            }
            ?>
                    <?php 
        }
        ?>
                </ul>
            </nav>
        </aside>
        <?php 
        return ob_get_clean();
    }