当前位置: 首页>>代码示例>>PHP>>正文


PHP content::update_campaign方法代码示例

本文整理汇总了PHP中content::update_campaign方法的典型用法代码示例。如果您正苦于以下问题:PHP content::update_campaign方法的具体用法?PHP content::update_campaign怎么用?PHP content::update_campaign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在content的用法示例。


在下文中一共展示了content::update_campaign方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: admin

    function admin($params)
    {
        $params = $this->clean_params($params);
        if (!$this->check_login_status($params)) {
            view::redirect('/' . $this->app->get_config('tweed.admin_path') . '/login');
        }
        if (!count($params)) {
            $params[0] = 'dash';
        }
        switch ($params[0]) {
            case 'dash':
                $campaigns = content::get_all_campaigns();
                $headers = '["ID #","Name","Start","End","Last Used","Search Params","Created By","Modified By","Status","Actions"]';
                $data = array();
                foreach ($campaigns as $campaign) {
                    $campaign_actions = array('edit');
                    if ($campaign['force_deactivated'] == 'no' && strtotime($campaign['end']) > time()) {
                        $campaign_actions[] = 'deactivate';
                    }
                    if ($campaign['force_deactivated'] == 'yes' && strtotime($campaign['end']) > time()) {
                        $campaign_actions[] = 'reactivate';
                    }
                    $data[] = array($campaign['id'], $campaign['name'], $campaign['start'], $campaign['end'], $campaign['last_used'], $campaign['query_params'], $campaign['created_by'], $campaign['modified_by'], $campaign['force_deactivated'] == 'yes' ? '<span class="deactivated">deactivated</span>' : (strtotime($campaign['end']) < time() ? '<span class="ended">ended</span>' : '<span class="active">active</span>'), content::generate_actions('campaign', $campaign['id'], $campaign_actions));
                }
                $campaigns_table = new \helpers\html\tables('forms', 'layout', $data, $headers);
                $campaigns_table->class = 'item_table';
                $view_params = array('campaigns' => $campaigns_table->render(), 'campaigns_buttons' => content::generate_actions('campaign', '', array('new campaign'), 'full', 'a'), 'scripts' => array('/js/cms/forms.js' => 10));
                $this->load_view($params[0], $view_params);
                break;
            case 'campaign':
                if (!isset($params[1])) {
                    return false;
                }
                switch ($params[1]) {
                    case 'edit':
                        $errors = false;
                        if (isset($params[2]) && intval($params[2])) {
                            if (count($_REQUEST)) {
                                // validate what we can
                                $rules = array('name' => array('required'), 'url' => 'url', 'start' => array('required', 'regex:/\\d{4}-\\d\\d-\\d\\d/'), 'end' => array('required', 'regex:/\\d{4}-\\d\\d-\\d\\d/'), 'force_deactivated' => array('required', 'in:yes:no'));
                                validator::make($rules);
                                if (validator::run()) {
                                    // update a campaign
                                    content::update_campaign($params[2]);
                                } else {
                                    $errors = $this->get_all_errors_as_string(null, array('<span class="error">', '</span>'));
                                }
                            }
                            $campaign_buttons = content::generate_actions($params[1], $params[2], array('save', 'add query'), 'full', 'button');
                            $campaign = content::get_campaign($params[2]);
                            $campaign_html = '';
                            foreach ($campaign as $q) {
                                $campaign_html .= $q['html'];
                            }
                            // build up the extra elements specifically for the campaign details - not the queries
                            $campaign_details = \helpers\html\html::load_snippet(MAVERICK_BASEDIR . 'vendor/helpers/html/snippets/label_wrap.php', array('label' => 'Campaign Name', 'element' => \helpers\html\html::load_snippet(MAVERICK_BASEDIR . 'vendor/helpers/html/snippets/input_text.php', array('value' => "value=\"{$campaign[0]['name']}\"", 'placeholder' => "placeholder=\"campaign name\"", 'name' => 'name'))));
                            $campaign_details .= \helpers\html\html::load_snippet(MAVERICK_BASEDIR . 'vendor/helpers/html/snippets/label_wrap.php', array('label' => 'URL', 'element' => \helpers\html\html::load_snippet(MAVERICK_BASEDIR . 'vendor/helpers/html/snippets/input_text.php', array('value' => "value=\"{$campaign[0]['url']}\"", 'placeholder' => "placeholder=\"campaign url\"", 'name' => 'url'))));
                            $campaign_details .= \helpers\html\html::load_snippet(MAVERICK_BASEDIR . 'vendor/helpers/html/snippets/label_wrap.php', array('label' => 'Start', 'element' => \helpers\html\html::load_snippet(MAVERICK_BASEDIR . 'vendor/helpers/html/snippets/input_date.php', array('value' => "value=\"{$campaign[0]['start']}\"", 'placeholder' => "placeholder=\"start date\"", 'name' => 'start'))));
                            $campaign_details .= \helpers\html\html::load_snippet(MAVERICK_BASEDIR . 'vendor/helpers/html/snippets/label_wrap.php', array('label' => 'End', 'element' => \helpers\html\html::load_snippet(MAVERICK_BASEDIR . 'vendor/helpers/html/snippets/input_date.php', array('value' => "value=\"{$campaign[0]['end']}\"", 'placeholder' => "placeholder=\"end date\"", 'name' => 'end'))));
                            $deactivated = array();
                            foreach (array('yes', 'no') as $d) {
                                $deactivated[] = \helpers\html\html::load_snippet(MAVERICK_BASEDIR . 'vendor/helpers/html/snippets/input_option.php', array('selected' => $d == $campaign[0]['force_deactivated'] ? 'selected="selected"' : '', 'value' => $d, 'display_value' => $d));
                            }
                            $campaign_details .= \helpers\html\html::load_snippet(MAVERICK_BASEDIR . 'vendor/helpers/html/snippets/label_wrap.php', array('label' => 'Force Deactivated?', 'element' => \helpers\html\html::load_snippet(MAVERICK_BASEDIR . 'vendor/helpers/html/snippets/input_select.php', array('values' => implode('', $deactivated), 'name' => 'force_deactivated'))));
                            $view_params = array('campaign_fields' => $campaign_html, 'campaign_buttons' => $campaign_buttons, 'campaign_details' => $campaign_details, 'scripts' => array('/js/campaigns.js' => 10, 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js' => 5));
                            if ($errors) {
                                $view_params['errors'] = $errors;
                            }
                            $this->load_view('campaign_edit', $view_params);
                        } else {
                            return false;
                        }
                        // just bomb out if people are fucking with the URL
                        break;
                    case 'new_campaign':
                        $campaign_id = content::create_new_campaign();
                        view::redirect('/' . $this->app->get_config('tweed.admin_path') . "/campaign/edit/{$campaign_id}");
                        break;
                    case 'deactivate':
                    case 'reactivate':
                        // just bomb out if people are fucking with the URL
                        if (empty($params[2]) || !intval($params[2])) {
                            return false;
                        }
                        content::set_campaign_status($params[2], $params[1]);
                        view::redirect('/' . $this->app->get_config('tweed.admin_path'));
                        break;
                }
                break;
            case 'tweets':
                $errors = false;
                // todo: generate fetch parameters based on the passed in filter options
                $pagination_filter = array();
                foreach (array('campaign', 'lang', 'user', 'after') as $filter) {
                    if (!empty($_REQUEST[$filter])) {
                        ${$filter} = $_REQUEST[$filter];
                        $pagination_filter[] = "{$filter}=" . filter_var($_REQUEST[$filter], FILTER_SANITIZE_SPECIAL_CHARS);
                    } else {
                        ${$filter} = null;
                    }
//.........这里部分代码省略.........
开发者ID:AshleyJSheridan,项目名称:tweed,代码行数:101,代码来源:admin_controller.php


注:本文中的content::update_campaign方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。