Beispiel #1
0
 /**
  * Construct the Behavior, and attaches itself to the $blog object
  *
  * @param string $name 
  * @param string $settings 
  * @param string $blog 
  * @author Armando Sosa
  */
 function __construct($name, $settings, &$controller)
 {
     parent::__construct();
     $this->Controller =& $controller;
     $this->name = $name;
     $this->settings = set_merge($this->settings, $settings);
     $this->Controller->registerBehavior($this);
     $this->register($controller);
 }
Beispiel #2
0
 function please($task)
 {
     if (is_array($task)) {
         $this->tasks = set_merge($this->tasks, $task);
     } else {
         $this->tasks[] = $task;
     }
     return $this;
 }
Beispiel #3
0
 function breadcrumbs(&$blog, $options = array())
 {
     $options = set_merge(array('drop_first_category_node' => 1, 'search_label' => 'Search'), $options);
     $pageType = $blog->getCurrentPageType();
     $methodName = "_{$pageType}Breadcrumbs";
     if (method_exists($this, $methodName)) {
         echo $this->{$methodName}($options);
     }
 }
Beispiel #4
0
 /**
  * loads the settings for the current $id
  *
  * @param string $id 
  * @param string $settings 
  * @return void
  * @author Armando Sosa
  */
 function initSettings($id, &$settings)
 {
     // in case that just the id has been passed
     if (!is_string($id)) {
         $id = $settings;
         $settings = array();
     }
     // merge $settings with some default values
     $settings = set_merge(array('title' => phraseize($id), 'label' => false, 'field' => underscorize($id), 'default' => '', 'page' => 'post', 'context' => 'normal', 'priority' => 'high', 'hint' => '', 'unique' => true, 'type' => 'text', 'size' => 25, 'cols' => 40, 'selectNone' => 'None', 'beforeRender' => '', 'beforeSave' => ''), $settings);
 }
Beispiel #5
0
Datei: cms.php Projekt: soska/dte
 /**
  * Starts a loop with the child pages defined in ($options['post_parent'])
  *
  * @param string $blog 
  * @param string $options 
  * @return void
  * @author Armando Sosa
  */
 function pageChilds($options = null)
 {
     if ($options && !is_array($options)) {
         $options = array('post_parent' => $options);
     } else {
         $options = array('post_parent' => $this->parentPageId);
     }
     $options = set_merge(array('post_type' => 'page', 'orderby' => 'menu_order', 'order' => 'asc'), $options);
     return $this->Controller->loop($options)->have_posts();
 }
function add_action($arr)
{
    global $ACTIONS, $APAGES;
    $custom = array('code' => '', 'function' => '', 'rule' => 'admin', 'category' => 'public', 'priority' => 30, 'zone' => '', 'auto' => '');
    $custom = set_merge($custom, $arr);
    $key = $custom['code'] = canone_code($custom['code']);
    if (validate_code($key) && !isset($ACTIONS[$key]) && (isset($APAGES['index']) && $custom['category'] == $APAGES['index']->category || $custom['category'] == 'all')) {
        $ACTIONS[$key] = new actions_collector($custom);
    }
}
function add_script($arr)
{
    global $SCRIPTS, $APAGES;
    $custom = array('code' => '', 'type' => 'script', 'link' => '', 'function' => '', 'priority' => '30', 'auto' => '', 'category' => 'public', 'zone' => '');
    $custom = set_merge($custom, $arr);
    $key = $custom['code'] = canone_code($custom['code']);
    if (validate_code($key) && !isset($SCRIPTS[$key]) && (isset($APAGES['index']) && $custom['category'] == $APAGES['index']->category || $custom['category'] == 'all')) {
        $SCRIPTS[$key] = new scripts_collector($custom);
    }
}
Beispiel #8
0
 /**
  * set_merge, borrowed from he cakephp.org project. Is like array_merge, except it merges even deep arrays
  *
  * @param string $arr1 
  * @param string $arr2 
  * @return void
  * @author Armando Sosa
  */
 function set_merge($arr1, $arr2 = null)
 {
     $args = func_get_args();
     $r = (array) current($args);
     while (($arg = next($args)) !== false) {
         foreach ((array) $arg as $key => $val) {
             if (is_array($val) && isset($r[$key]) && is_array($r[$key])) {
                 $r[$key] = set_merge($r[$key], $val);
             } elseif (is_int($key)) {
                 $r[] = $val;
             } else {
                 $r[$key] = $val;
             }
         }
     }
     return $r;
 }
Beispiel #9
0
function action_settings_main($pre = null)
{
    $custom = array('site_name' => '', 'current_template' => '', 'default_group' => '', 'login_agent' => false, 'login_ip' => false, 'cookie_login_live' => null);
    if (!isset($_POST['site_name'])) {
        $custom['site_name'] = get_option('site_name');
        $custom['current_template'] = get_option('current_template');
        $custom['default_group'] = get_option('default_group');
        $login = get_option('admin_check_login');
        $custom['login_ip'] = $login['login_ip'];
        $custom['login_agent'] = $login['login_agent'];
        $custom['cookie_login_live'] = get_option('cookie_login_live') / 60;
        set_glob_content(array('body' => $custom));
    }
    if (isset($_POST['site_name'])) {
        $data = $pre ? $pre : $_POST;
        $custom_new = set_merge($custom, $data, false, true);
        set_glob_content(array('body' => $custom_new));
        if ($custom_new['site_name'] && $custom_new['current_template'] && $custom_new['default_group']) {
            $checker = array();
            if ($custom['site_name'] != $custom_new['site_name']) {
                $checker[] = update_option('site_name', $custom_new['site_name']);
            }
            if ($custom['current_template'] != $custom_new['current_template']) {
                $checker[] = update_option('current_template', $custom_new['current_template']);
            }
            if ($custom['default_group'] != $custom_new['default_group']) {
                $checker[] = update_option('default_group', $custom_new['default_group']);
            }
            if ($custom['login_agent'] !== $custom_new['login_agent'] || $custom['login_ip'] !== $custom_new['login_ip']) {
                $checker[] = update_option('admin_check_login', array('login_ip' => $custom_new['login_ip'] != false, 'login_agent' => $custom_new['login_agent'] != false));
            }
            if ($custom['cookie_login_live'] != $custom_new['cookie_login_live']) {
                $checker[] = update_option('cookie_login_live', $custom_new['cookie_login_live'] * 60);
            }
            $checker = array_merge($checker, actions_zone('settings_checking', $data));
            if (!in_array(false, $checker, true)) {
                push_output_message(array('title' => 'Обновлено!', 'text' => 'Поля успешно обновлены', 'class' => 'alert alert-success'));
            } else {
                push_output_message(array('title' => 'Ошибка!', 'text' => 'Поля заполнены некорректно', 'class' => 'alert alert-danger', 'type' => 'error'));
            }
        } else {
            push_output_message(array('text' => 'Поля не заполнены', 'title' => 'Ошибка!', 'class' => 'alert alert-warning', 'type' => 'warning'));
        }
    }
}
Beispiel #10
0
function action_edit_user()
{
    global $PAGE;
    $current = isset($_GET['user_id']) && is_numeric($_GET['user_id']) ? $_GET['user_id'] : null;
    if (!$current) {
        $PAGE->title = 'Добавить пользователя';
    }
    if (isset($_POST['action']) && $_POST['action'] == 'save') {
        $temp = $res = array('login' => '', 'code' => '', 'display_name' => '', 'mail' => '', 'groups_ID' => array(), 'rules' => array());
        $res = set_merge($res, $_POST);
        if ($password = $_POST['password']) {
            $salt = random_salt();
            $password = crypt(md5($password), $salt);
            $res['password'] = $password;
            $res['salt'] = $salt;
        }
        if ($res['login'] && $res['display_name'] && $res['mail'] && $res['code'] && count($res['groups_ID']) && (isset($res['password']) || $current)) {
            if ($current) {
                if (update_users($res, "WHERE ID='{$current}'")) {
                    push_output_message(array('title' => 'Обновлено!', 'text' => 'Пользователь успешно обновлён', 'class' => 'alert alert-success'));
                } else {
                    push_output_message(array('title' => 'Ошибка!', 'text' => 'Произошла неизвестная ошибка', 'class' => 'alert alert-danger'));
                }
                $res['ID'] = $current;
                set_glob_content(array('body' => (object) $res));
            } else {
                if (add_user($res)) {
                    push_output_message(array('title' => 'Добавлено!', 'text' => 'Пользователь успешно добавлен', 'class' => 'alert alert-success'));
                } else {
                    push_output_message(array('title' => 'Ошибка!', 'text' => 'Произошла неизвестная ошибка', 'class' => 'alert alert-danger'));
                }
            }
        } else {
            push_output_message(array('title' => 'Ошибка!', 'text' => 'Заполните все обязательные поля', 'class' => 'alert alert-danger'));
            set_glob_content(array('body' => (object) $res));
        }
    } elseif (isset($_POST['action']) && $_POST['action'] == 'delete' && $current && delete_user($current)) {
        push_output_message(array('title' => 'Удалено!', 'text' => 'Пользователь успешно удалён', 'class' => 'alert alert-success'));
        set_glob_content(array('body' => (object) $temp));
    } elseif ($current && ($user = get_user($current, 'ID, login, code, display_name, mail, groups_ID, rules', true))) {
        set_glob_content(array('body' => $user));
    }
}
Beispiel #11
0
function add_detblock($par)
{
    global $DETDB;
    $custom = array('code' => '', 'name' => '', 'description' => '');
    $custom = set_merge($custom, $par);
    $custom['code'] = canone_code($custom['code']);
    if (validate_code($custom['code'])) {
        if ($DETDB->insert('detblocks_types', $custom)) {
            $ID = $DETDB->select('detblocks_types', 'ID', true, "WHERE code='{$custom['code']}'");
            if (isset($ID->ID)) {
                $ID = $ID->ID;
                if ($DETDB->create_table("detblocks_content_{$ID}", array('ID' => 'BIGINT UNSIGNED NOT NULL AUTO_INCREMENT', 'code' => 'VARCHAR(60) NOT NULL', 'block_ID' => 'BIGINT UNSIGNED NOT NULL', 'category_ID' => 'BIGINT UNSIGNED NULL', 'PRIMARY KEY' => '(ID)', "INDEX entry" => '(code)', "INDEX category" => '(category_ID)'))) {
                    return $ID;
                }
            }
        }
    }
    return false;
}
Beispiel #12
0
function update_modules($params)
{
    $active = get_option('active_modules');
    $params = (array) $params;
    $modules = scandir(ABSPATH . '/' . MODULES);
    $res = array();
    if (count($params) > 0) {
        foreach ($params as $dir) {
            $dir = set_merge(array(null, false), $dir);
            $path = ABSPATH . '/' . MODULES . '/' . $dir[0];
            if (is_dir($path) && file_exists($path . '/main.php')) {
                $res[] = $dir;
                if (array_multi_search($dir[0], $active, 0) === null && file_exists($path . '/install.php')) {
                    require_once $path . '/install.php';
                }
            }
        }
    }
    return update_option('active_modules', json_val_encode($res));
}
Beispiel #13
0
function action_detblocks_type()
{
    global $DETDB, $PAGE;
    $current = isset($_GET['block_id']) && is_numeric($_GET['block_id']) ? $_GET['block_id'] : null;
    $temp = $block = (object) array('code' => '', 'name' => '', 'description' => '');
    if ($current && ($res = get_detblock_type($current))) {
        $block = set_merge($block, $res);
        $PAGE->title = 'Обновить DET-блок';
    } else {
        $current = null;
    }
    if (isset($_POST['action']) && $_POST['action'] == 'save') {
        $block = set_merge($block, $_POST);
        if ($current) {
            if (update_detblock($current, $block)) {
                push_output_message(array('text' => "DET-блок успешно обновлён", 'title' => 'Успех!', 'class' => 'alert alert-success', 'type' => 'success'));
                $block->ID = $current;
                set_glob_content(array('body' => $block));
                return true;
            }
        } elseif ($ID = add_detblock($block)) {
            push_output_message(array('text' => "DET-блок {$block->code} успешно добавлен!<br />Создана таблица {$DETDB->prefix}detblocks_content_{$ID}", 'title' => 'Успех!', 'class' => 'alert alert-success', 'type' => 'success'));
            set_glob_content(array('body' => $temp));
            return true;
        } else {
            set_glob_content(array('body' => $block));
            return false;
        }
    } elseif (isset($_POST['action']) && $_POST['action'] == 'delete') {
        if (delete_detblock($current)) {
            push_output_message(array('text' => "DET-блок {$block->code} и все его связи успешно удалены!", 'title' => 'Успех!', 'class' => 'alert alert-success', 'type' => 'success'));
            set_glob_content(array('body' => $temp));
            return true;
        }
    }
    if ($current) {
        $block->ID = $current;
    }
    set_glob_content(array('body' => $block));
    return true;
}
Beispiel #14
0
function set_glob_content($par)
{
    global $PAGE, $DETDB;
    $par = take_good_array($par);
    $custom =& $PAGE->content;
    $custom = set_merge($custom, $par);
    if ($custom['pagi']) {
        if ($custom['current'] === null) {
            $custom['current'] = get_pagination_number();
        }
        if ($custom['offset'] === null) {
            $custom['offset'] = $custom['limit'] * ($custom['current'] - 1);
        }
    }
    if ($custom['handler']) {
        $pre = null;
        if (is_string($custom['handler'])) {
            $pre = make_action($custom['handler'], $custom);
        } elseif (is_callable($custom['handler'])) {
            $pre = call_user_func($custom['handler'], $custom);
        }
        if ($pre && (is_object($pre) || is_array($pre))) {
            $custom = set_merge($custom, $pre, true);
        }
    }
    if ($custom['pagi'] && $custom['all'] === null) {
        $custom['all'] = isset($par['table']) ? $DETDB->count($par['table']) : 1;
    }
    if ($custom['body'] == '' && isset($par['table'])) {
        if ($custom['pagi']) {
            $par['offset'] = $custom['offset'];
            $par['limit'] = $custom['limit'];
        }
        $custom['body'] = $DETDB->select($par);
    }
    if ($custom['pagi'] && $custom['all'] && $custom['limit'] && ceil($custom['all'] / $custom['limit']) < $custom['current']) {
        redirect(get_current_key(), true);
    }
}
Beispiel #15
0
function action_remote_keys_edit()
{
    global $PAGE;
    $current = isset($_GET['key_id']) && is_numeric($_GET['key_id']) ? $_GET['key_id'] : null;
    $temp = $key = (object) array('name' => '', 'key_value' => generate_remote_key(), 'rules' => array());
    if ($current && ($res = get_remote_key($current))) {
        $key = set_merge($key, $res);
        $PAGE->title = 'Обновить ключ';
    } else {
        $current = null;
    }
    if (isset($_POST['save'])) {
        $key = set_merge($key, $_POST);
        if ($key->name && $key->key_value && is_array($key->rules) && count($key->rules) > 0) {
            if ($current) {
                if (update_remote_key($current, $key)) {
                    push_output_message(array('text' => 'Ключ успешно обновлён', 'title' => 'Успех!', 'class' => 'alert alert-success', 'type' => 'success'));
                    $key->ID = $current;
                    set_glob_content(array('body' => $key));
                    return true;
                }
            } elseif (add_remote_key($key)) {
                push_output_message(array('text' => 'Ключ успешно добавлен', 'title' => 'Успех!', 'class' => 'alert alert-success', 'type' => 'success'));
                set_glob_content(array('body' => $temp));
                return true;
            } else {
                set_glob_content(array('body' => $key));
                return false;
            }
        } else {
            push_output_message(array('title' => 'Ошибка!', 'text' => 'Заполните все поля (имя, ключ, хотя одно право)', 'class' => 'alert alert-danger'));
        }
    }
    set_glob_content(array('body' => $key));
    return true;
}
Beispiel #16
0
function show_calendar_events($params = array())
{
    global $DETDB;
    $custom = array('links' => false, 'type' => 'month', 'month' => isset($_GET['month']) && is_numeric($_GET['month']) ? $_GET['month'] : date('m'), 'year' => isset($_GET['year']) && is_numeric($_GET['year']) ? $_GET['year'] : date('Y'), 'start' => '', 'end' => '', 'show' => 'table', 'exclude_ID' => null, 'limit' => 100);
    $query = null;
    if (is_merged($params)) {
        $custom = set_merge($custom, $params);
        if ($custom['start']) {
            $custom['start'] = date('Y-m-d H:i', strtotime($custom['start']));
        }
        if ($custom['end']) {
            $custom['end'] = date('Y-m-d H:i', strtotime($custom['end']));
        }
        $custom['year'] = is_numeric($custom['year']) && checkdate('01', '01', $custom['year']) ? $custom['year'] : date('Y');
        $custom['month'] = is_numeric($custom['month']) && checkdate($custom['month'], '01', $custom['year']) ? $custom['month'] : date('m');
        if ($custom['type'] == 'month') {
            $query = array(array('param' => 'MONTH(date_start)', 'value' => $custom['month']), array('param' => 'YEAR(date_start)', 'value' => $custom['year']));
        } else {
            $query = array(array('param' => 'date_end', 'value' => $custom['start'], 'relation' => '>='), array('param' => 'date_start', 'value' => $custom['end'], 'relation' => '<='));
        }
        if ($custom['exclude_ID'] && !is_array($custom['exclude_ID'])) {
            $custom['exclude_ID'] = array($custom['exclude_ID']);
        }
        if ($custom['exclude_ID']) {
            foreach ($custom['exclude_ID'] as $item) {
                $query[] = array('param' => 'ID', 'value' => $item, 'relation' => '!=');
            }
        }
    }
    $events = $query ? $DETDB->select(array('table' => 'calendar_events', 'cols' => '*', 'cond' => $query, 'order_by' => 'date_start', 'order_type' => 'ASC', 'limit' => $custom['limit'])) : null;
    ?>
        <?php 
    if ($events && count($events) > 0 && $custom['show'] == 'table') {
        ?>
            <table class="table table-striped table-hover table-bordered" width="100%">
                <thead>
                    <tr>
                        <th width="7%">Дата</th>
                        <th width="7%">Время</th>
                        <th>Наименование  мероприятия</th>
                        <th width="18%">Место проведения</th>
                        <th width="14%">Ответственный</th>
                    </tr>
                </thead>
                <tbody>
                    <?php 
        foreach ($events as $item) {
            ?>
                        <?php 
            $start = strtotime($item->date_start);
            $end = strtotime($item->date_end);
            ?>
                        <tr class="field">
                            <td>
                                <?php 
            echo date('d', $start);
            if ($end && $end > 0 && date('d', $start) != date('d', $end)) {
                echo ' - ' . date('d', $end);
            }
            ?>
                            </td>
                            <td>
                                <?php 
            if ($item->date_params && check_json($item->date_params)) {
                $item->date_params = json_decode($item->date_params, true);
                if (count($item->date_params) == 2) {
                    $item->date_params = !$item->date_params[0];
                }
            } else {
                $item->date_params = true;
            }
            if ($start && $item->date_params) {
                echo date('G.i', $start);
                if ($end && $end > 0 && $start && $end != $start) {
                    echo ' - ' . date('G.i', $end);
                }
            }
            ?>
                            </td>
                            <td><?php 
            echo $item->name;
            ?>
                            <?php 
            if ($custom['links']) {
                ?>
                                <p class="controls">
                                    <a href="<?php 
                echo get_page_link('calendar_event_add') . '&event_id=' . $item->ID;
                ?>
">Редактировать</a> |
                                    <a class="table-delete button-control" data-set-action="delete_calendar_event" data-id="<?php 
                echo $item->ID;
                ?>
">Удалить</a>
                                </p>
                            <?php 
            }
            ?>
                            </td>
                            <td><?php 
            echo $item->place;
            ?>
</td>
                            <td><?php 
            echo $item->worker;
            ?>
</td>
                        </tr>
                    <?php 
        }
        ?>
                </tbody>
                <tfoot>
                    <tr>
                        <th>Дата</th>
                        <th>Время</th>
                        <th>Наименование  мероприятия</th>
                        <th>Место проведения</th>
                        <th>Ответственный</th>
                    </tr>
                </tfoot>
            </table>
        <?php 
    } elseif ($custom['show'] == 'json') {
        ?>
            <?php 
        echo json_val_encode($events);
        ?>
        <?php 
    } else {
        ?>
            <p>Нет событий, выбранных за данный период.</p>
        <?php 
    }
    ?>
    <?php 
}
Beispiel #17
0
 /**
  * Image Radio Control
  *
  * Enhanced Javascript Control, that allows an array of images, to act as radio
  *
  * @param string $name 
  * @param string $options 
  * @return void
  * @author Armando Sosa
  */
 function _imageRadio($name, $options)
 {
     $options = set_merge(array('baseDir' => ''), (array) $options);
     $input = HtmlHelper::tag('div.image-radio-group');
     foreach ($options['options'] as $value => $image) {
         $selected = $value == $options['value'] ? '.selected' : '';
         $atts = HtmlHelper::attr(array('title' => $value, 'src' => $options['baseDir'] . $image));
         $input .= HtmlHelper::tag('img.radio' . $selected, $atts);
     }
     $input .= $this->input($name, array('type' => 'hidden', 'value' => $value), false);
     $input .= HtmlHelper::tag('/div.image-radio-group');
     return $input;
 }
Beispiel #18
0
 private function custom_where($param)
 {
     $cond = '';
     if (is_array($param)) {
         $i = 0;
         if (is_assoc_array($param)) {
             $param = array($param);
         }
         $custom = array('log' => 'AND', 'relation' => '=', 'param' => '', 'value' => '');
         foreach ($param as $sub_cond) {
             if (isset($sub_cond['param'])) {
                 $temp = set_merge($custom, $sub_cond);
                 $temp['value'] = $this->escape_string($temp['value']);
                 if ($i == 0) {
                     $cond = ' WHERE ';
                 }
                 if ($i > 0 && $temp['log']) {
                     $cond .= " {$temp['log']} ";
                 }
                 if ($i == 0 || $temp['log']) {
                     $cond .= "{$temp['param']} {$temp['relation']} '{$temp['value']}'";
                 }
                 $i++;
             }
         }
     } else {
         if ($param) {
             $cond = preg_match('/^(WHERE)/i', $param) ? $param : "WHERE {$param}";
         }
     }
     return $cond;
 }
Beispiel #19
0
 function input($name, $options = array())
 {
     $fieldName = $this->panel['name'] . "_opts" . "[{$name}]";
     $fieldAdjacentFileName = $this->panel['name'] . "_opts" . "[{$name}__file]";
     $options = set_merge(array('label' => $name, 'hint' => '', 'type' => 'text', 'options' => false, 'attributes' => array('id' => $name, 'name' => $fieldName, 'class' => false), 'row' => true, 'preview' => false, 'enclosing_tag' => "div.input"), $options);
     if (isset($this->values[$name])) {
         $options['attributes']['value'] = $this->values[$name];
     } else {
         $options['attributes']['value'] = '';
     }
     $options['attributes']['type'] = $options['type'];
     switch ($options['type']) {
         case 'text':
         case 'input':
         case 'hidden':
             $input = csml::tag("input/", $options['attributes']);
             break;
         case 'file':
             $input = csml::tag("input/", array('type' => 'hidden', 'value' => $options['attributes']['value'], 'name' => $options['attributes']['name'])) . "<br/>";
             $input .= csml::tag("input/", array('type' => 'file', 'name' => $fieldAdjacentFileName));
             break;
         case 'textarea':
             $value = $options['attributes']['value'];
             $options['attributes']['value'] = false;
             $input = csml::entag($value, 'textarea', $options['attributes']);
             break;
         case 'select':
             $value = $options['attributes']['value'];
             $options['attributes']['value'] = false;
             $input = csml::tag('select', $options['attributes']);
             $options['options'] = (array) $options['options'];
             foreach ($options['options'] as $v => $l) {
                 $opattr = array('value' => $v);
                 if ($value == $v) {
                     $opattr['selected'] = 'selected';
                 }
                 $input .= csml::entag($l, 'option', $opattr);
             }
             $input .= csml::tag('/select');
             break;
         case 'checkbox':
             $options['attributes']['checked'] = $options['attributes']['value'] === "on" ? 'checked' : false;
             $options['attributes']['value'] = false;
             $options['legend'] = isset($options['legend']) ? $options['legend'] : $options['label'];
             $input = csml::tag("input/", $options['attributes']);
             if ($options['legend']) {
                 $input = csml::entag($input . " " . $options['legend'], 'label');
             }
             break;
         default:
             $input = csml::tag("input/", $options['attributes']);
             break;
     }
     // image preview
     if ($options['type'] == 'file') {
         if ($options['preview'] && !empty($options['attributes']['value'])) {
             $img = csml::tag('img/', array('src' => $options['attributes']['value'], 'max-height' => '120'));
             $input .= csml::entag($img, 'p.image_preview');
         }
         $options['hint'] .= "<br/>" . $options['attributes']['value'];
     }
     if ($options['row']) {
         $input = $this->row($options, $input, $options['hint']);
     } else {
         if ($options['label']) {
             $input = "<label>{$options['label']} {$input} </label>";
         }
         if (is_string($options['enclosing_tag'])) {
             $input = csml::entag($input, $options['enclosing_tag']);
         }
     }
     echo $input;
 }
Beispiel #20
0
function ajax_make_res($param = 'success', $body = '', $title = '', $data = '', $error = false)
{
    $custom = array('status' => '', 'body' => $body, 'title' => $title, 'data' => $data, 'error' => $error);
    if (is_merged($param)) {
        $custom = set_merge($custom, $param);
    } else {
        $custom['status'] = $param;
    }
    if ($custom['error']) {
        $custom['body'] .= get_output_result_messages('error', true);
    }
    unset($custom['error']);
    return json_val_encode($custom);
}
Beispiel #21
0
function update_remote_key($ID, $key)
{
    global $DETDB;
    if (is_object($key)) {
        $key = (array) $key;
    }
    if (is_merged($key) && isset($key['key_value'])) {
        $L = strlen($key['key_value']);
        $custom = set_merge(array('name' => '', 'key_value' => '', 'rules' => ''), $key);
        if ($L >= 16 && $L <= 20) {
            if (preg_match('/^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPRQSTUVWXYZ0123456789!@#$%^*()]{16,20}$/i', $custom['key_value'])) {
                if ($DETDB->update('remote_keys', $custom, "WHERE ID={$ID}")) {
                    return true;
                } else {
                    push_output_message(array('title' => 'Ошибка!', 'text' => 'Произошла неизвестная ошибка, возможно, ключ повторяется', 'class' => 'alert alert-danger'));
                }
            } else {
                push_output_message(array('title' => 'Ошибка ключа!', 'text' => 'Воспользуйтесь генератором ключей', 'class' => 'alert alert-danger'));
            }
        } else {
            push_output_message(array('title' => 'Ошибка!', 'text' => 'Ключ должен иметь длину от 16 до 20 символов', 'class' => 'alert alert-danger'));
        }
    }
    return false;
}
Beispiel #22
0
 /**
  * Construct the component, and attaches itself to the $blog object
  *
  * @param string $name 
  * @param string $settings 
  * @param string $blog 
  * @author Armando Sosa
  */
 function __construct($settings, &$controller)
 {
     $this->settings = set_merge($this->settings, $settings);
 }
Beispiel #23
0
 function dependency($type, $handle, $options = array())
 {
     $subdir = $type == 'style' ? '/styles/' : '/js/';
     $options = set_merge(array('src' => false, 'root' => get_bloginfo('template_directory') . $subdir, 'deps' => array(), 'ver' => false, 'media' => false, 'conditions' => false), $options);
     $options['deps'] = (array) $options['deps'];
     if ($options['root']) {
         $src = $options['root'] . $options['src'];
     } else {
         $src = $options['src'];
     }
     $function = "wp_enqueue_{$type}";
     $function($handle, $src, $options['deps'], $options['ver'], $options['media']);
     if ($type = "style") {
         if ($options['conditions']) {
             global $wp_styles;
             foreach ((array) $options['conditions'] as $condition) {
                 $wp_styles->add_data($handle, 'conditional', $condition);
             }
         }
     }
 }
Beispiel #24
0
 /**
  * outputs a link
  *
  * @param string $label 
  * @param string $url 
  * @param string $options 
  * @return void
  * @author Armando Sosa
  */
 function link($label, $url, $options = null)
 {
     $options = set_merge(array('class' => null, 'id' => null, 'title' => null, 'attributes' => null), $options);
     $class = $options['class'] ? "class='{$options['class']}'" : '';
     $id = $options['id'] ? "id='{$options['id']}'" : '';
     $title = $options['title'] ? "title='{$options['title']}'" : '';
     $attributes = '';
     if ($options['attributes']) {
         $attributes = $options['attributes'];
         if (is_array($attributes)) {
             $attibutes = $this->attributes($attributes);
         }
     }
     return "<a href='{$url}' {$class} {$id} {$title} {$attributes}>{$label}</a>";
 }
function apage_navigation($params = array())
{
    $custom = array('parent' => '', 'depth' => 3, 'current' => 0, 'class' => '', 'double_max' => null);
    if (is_array($params)) {
        $custom = set_merge($custom, $params);
    }
    apage_navigation_child($custom);
}
Beispiel #26
0
 /**
  * grab options from database if they exist, otherwise we'll use the defaults
  *
  * @return void
  * @author Armando Sosa
  */
 function initOptions($instance)
 {
     $this->options = set_merge($this->options, $instance);
 }