예제 #1
0
/**
 * Smarty {attribution} function plugin
 *
 * Type:     function<br>
 * Name:     attribution<br>
 * Purpose:  create an attribution phrase
 *
 * @param         $params
 * @param \Smarty $smarty
 */
function smarty_function_attribution($params, &$smarty)
{
    if (isset($params['user_id'])) {
        $u = user::getUserById($params['user_id']);
    } elseif (isset($params['user'])) {
        $u = $params['user'];
    }
    if (!empty($u->id)) {
        $str = "";
        $display = isset($params['display']) ? $params['display'] : DISPLAY_ATTRIBUTION;
        switch ($display) {
            case "firstlast":
                $str = $u->firstname . " " . $u->lastname;
                break;
            case "lastfirst":
                $str = $u->lastname . ", " . $u->firstname;
                break;
            case "first":
                $str = $u->firstname;
                break;
            case "username":
            default:
                $str = $u->username;
                break;
        }
        echo $str;
    } else {
        echo gt('Anonymous User');
    }
}
예제 #2
0
 function update()
 {
     global $db;
     //$db->delete('modstate');
     $aMods = $db->selectObjects('modstate', 1);
     foreach ($aMods as $key => $value) {
         if (!empty($this->params['mods']) && array_key_exists($value->module, $this->params['mods'])) {
             $aMods[$key]->active = $this->params['mods'][$value->module];
             $db->updateObject($aMods[$key], 'modstate', "module='" . $value->module . "'");
         } else {
             $aMods[$key]->active = 0;
             $db->updateObject($aMods[$key], 'modstate', "module='" . $value->module . "'");
         }
         unset($this->params['mods'][$value->module]);
     }
     if (!empty($this->params['mods'])) {
         foreach ($this->params['mods'] as $key => $value) {
             $aMod->module = $key;
             $aMod->active = $value;
             $db->insertObject($aMod, 'modstate');
         }
     }
     flash("message", gt("Active Modules have been updated."));
     expHistory::returnTo('editable');
 }
/**
 * Smarty {optiondisplayer} function plugin
 *
 * Type:     function<br>
 * Name:     optiondisplayer<br>
 * Purpose:  display option dropdown list
 *
 * @param         $params
 * @param \Smarty $smarty
 * @return bool
 */
function smarty_function_optiondisplayer($params, &$smarty)
{
    global $db;
    $groupname = $params['options'];
    $product = $params['product'];
    $display_price_as = isset($params['display_price_as']) ? $params['display_price_as'] : 'diff';
    // get the option group
    $og = new optiongroup();
    //$group = $og->find('bytitle', $groupname);
    $group = $og->find('first', 'product_id=' . $product->id . ' AND title="' . $groupname . '"');
    //grab the options configured for this product
    $options = $product->optionDropdown($group->title, $display_price_as);
    // if there are no  options we can return now
    if (empty($options)) {
        return false;
    }
    // find the default option if there is one.
    $default = $db->selectValue('option', 'id', 'optiongroup_id=' . $group->id . ' AND is_default=1');
    $view = $params['view'];
    //if((isset() || $og->required == false) $includeblank = $params['includeblank'] ;
    //elseif((isset($params['includeblank']) && $params['includeblank'] == false) || $og->required == true) $includeblank = false;
    $includeblank = $og->required == false && !isset($params['includeblank']) ? gt('-- Please Select an Option --') : $params['includeblank'];
    $template = get_common_template($view, $smarty->getTemplateVars('__loc'), 'options');
    $template->assign('product', $product);
    $template->assign('options', $options);
    $template->assign('group', $group);
    $template->assign('params', $params);
    $template->assign('default', $default);
    $template->assign('includeblank', $includeblank);
    $template->assign('required', $params['required']);
    $template->assign('selected', $params['selected']);
    echo $template->render();
}
예제 #4
0
 /**
  * @role update
  */
 public function move()
 {
     $page = StaticPage::getInstanceById((int) $this->request->get('id'), StaticPage::LOAD_DATA);
     // update parent
     if ($this->request->get('parent')) {
         $parent = StaticPage::getInstanceById((int) $this->request->get('parent'), StaticPage::LOAD_DATA);
     } else {
         $parent = null;
     }
     $page->parent->set($parent);
     $page->save();
     // update order
     $f = new ARUpdateFilter();
     if ($parent) {
         $f->setCondition(eq(f('StaticPage.parentID'), $parent->getID()));
     } else {
         $f->setCondition(new IsNullCond(f('StaticPage.parentID')));
     }
     $f->addModifier('StaticPage.position', new ARExpressionHandle('position+2'));
     if ($this->request->get('previous')) {
         $previous = StaticPage::getInstanceById((int) $this->request->get('previous'), StaticPage::LOAD_DATA);
         $position = $previous->position->get();
         $f->mergeCondition(gt(f('StaticPage.position'), $position));
         $page->position->set($position + 1);
     } else {
         $previous = null;
         $page->position->set(1);
     }
     ActiveRecordModel::updateRecordSet('StaticPage', $f);
     $page->save();
     return new JSONResponse(array(), 'success', $this->translate('_pages_were_successfully_reordered'));
 }
예제 #5
0
/**
 * Smarty {script} block plugin
 *
 * Type:     block<br>
 * Name:     script<br>
 * Purpose:  Set up a script block
 *
 * @param $params
 * @param $content
 * @param \Smarty $smarty
 * @param $repeat
 */
function smarty_block_script($params, $content, &$smarty, &$repeat)
{
    if ($content) {
        global $userjsfiles;
        if (empty($params['unique'])) {
            die("<strong style='color:red'>" . gt("The 'unique' parameter is required for the {script} plugin.") . "</strong>");
        }
        if ((isset($params['yui2mods']) || isset($params['yuimodules'])) && !strstr($content, "YUI(")) {
            $params['yui3mods'] = 1;
            $yui2mods = $params['yui2mods'] ? $params['yui2mods'] : $params['yuimodules'];
            $toreplace = array('"', "'", " ");
            $stripmodquotes = str_replace($toreplace, "", $yui2mods);
            $splitmods = explode(",", $stripmodquotes);
            $y3wrap = "YUI(EXPONENT.YUI3_CONFIG).use(";
            $y3wrap .= "'yui2-yahoo-dom-event', ";
            foreach ($splitmods as $key => $mod) {
                if ($mod == "menu") {
                    $y3wrap .= "'yui2-container', ";
                }
                $y3wrap .= "'yui2-" . $mod . "', ";
            }
            $y3wrap .= "function(Y) {\r\n";
            $y3wrap .= "var YAHOO=Y.YUI2;";
            $y3wrap .= $content;
            $y3wrap .= "});";
            $content = $y3wrap;
        }
        expJavascript::pushToFoot(array("unique" => $params['unique'], "yui3mods" => $params['yui3mods'], "content" => $content, "src" => $params['src']));
    }
}
예제 #6
0
파일: Token.php 프로젝트: nicbon/LimeSurvey
 public function attributeLabels()
 {
     $labels = array('tid' => gT('Token ID'), 'partcipant' => gt('Participant ID'), 'firstname' => gT('First name'), 'lastname' => gT('Last name'), 'email' => gT('Email address'), 'emailstatus' => gT('Email status'), 'token' => gT('Token'), 'language' => gT('Language code'), 'blacklisted' => gT('Blacklisted'), 'sent' => gT('Invitation sent date'), 'remindersent' => gT('Last reminder sent date'), 'remindercount' => gT('Total numbers of sent reminders'), 'completed' => gT('Completed'), 'usesleft' => gT('Uses left'), 'validfrom' => gT('Valid from'), 'validuntil' => gT('Valid until'));
     foreach (decodeTokenAttributes($this->survey->attributedescriptions) as $key => $info) {
         $labels[$key] = $info['description'];
     }
     return $labels;
 }
예제 #7
0
function echoFailure($msg = "")
{
    echo '<span class="failed">' . gt('Failed') . '</span>';
    if ($msg != "") {
        echo ' : ' . $msg;
    }
    echo '</td></tr>';
}
 /**
  * Sorts the array of comparable objects.
  */
 protected function doSort()
 {
     for ($i = 1; $i < $this->n; ++$i) {
         for ($j = $i; $j > 0 && gt($this->array[$j - 1], $this->array[$j]); --$j) {
             $this->swap($j, $j - 1);
         }
     }
 }
예제 #9
0
 function update()
 {
     $timestamp = mktime(0, 0, 0, $this->params['month'], 1);
     $endday = expDateTime::endOfMonthDay($timestamp);
     if ($this->params['day'] > $endday) {
         expValidator::failAndReturnToForm(gt('There are only') . ' ' . $endday . ' ' . gt('days in') . ' ' . $this->motd->months[$this->params['month']], $this->params);
     }
     parent::update();
 }
예제 #10
0
/**
 * Smarty {getchromemenu} function plugin
 *
 * Type:     function<br>
 * Name:     getchromemenu<br>
 * Purpose:  display the chrome menu
 *
 * @param         $params
 * @param \Smarty $smarty
 * @return bool
 */
function smarty_function_getchromemenu($params, &$smarty)
{
    global $router, $user;
    $cloc = $smarty->getTemplateVars('__loc');
    $module = $params['module'];
    $list = '<ul class="container-menu">';
    $list .= '<li class="container-info">' . $module->action . ' / ' . str_replace($module->action . '_', '', $module->view) . '</li>';
    if (!empty($params['rank']) && expPermissions::check('order_modules', $cloc)) {
        $uplink = $router->makeLink(array('module' => 'containermodule', 'src' => $cloc->src, 'action' => 'order', 'a' => $params['rank'] - 2, 'b' => $params['rank'] - 1));
        $downlink = $router->makeLink(array('module' => 'containermodule', 'src' => $cloc->src, 'action' => 'order', 'a' => $params['rank'] - 1, 'b' => $params['rank']));
        if ($params['rank'] != 1) {
            //dont show this up arrow if it's the first module in a container
            $list .= '<li><a href="' . $uplink . '" class="mod-up">' . gt("Move Module Up") . '</a></li>';
        }
        if (!$params['last']) {
            //if this is the last module in a container don't show down arrow.
            $list .= '<li><a href="' . $downlink . '" class="mod-down">' . gt("Move Module Down") . '</a></li>';
        }
    }
    $rerank = $params['rerank'];
    if ($rerank == 'false') {
        $rerank = 0;
    } else {
        $rerank = 1;
    }
    if ($user->isAdmin()) {
        $userlink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'userperms', '_common' => 1));
        $grouplink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'groupperms', '_common' => 1));
        $list .= '<li><a href="' . $userlink . '" class="user">' . gt("User Permissions") . '</a></li>';
        $list .= '<li><a href="' . $grouplink . '" class="group">' . gt("Group Permissions") . '</a></li>';
    }
    if (!empty($module->id) && expPermissions::check('edit_module', $cloc) && $module->permissions['administrate'] == 1) {
        $editlink = $router->makeLink(array('module' => 'containermodule', 'id' => $module->id, 'action' => 'edit', 'src' => $module->info['source']));
        $list .= '<li><a href="' . $editlink . '" class="config-view">' . gt("Configure Action") . " &amp; " . gt("View") . '</a></li>';
    }
    if ($module->permissions['configure'] == 1) {
        if (expModules::controllerExists($module->info['class'])) {
            $configlink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'configure', 'hcview' => $module->view));
            $list .= '<li><a href="' . $configlink . '" class="config-mod">' . gt("Configure Settings") . '</a></li>';
        } elseif ($module->info['hasConfig']) {
            $configlink = $router->makeLink(array('module' => $module->info['class'], 'src' => $module->info['source'], 'action' => 'configure', '_common' => 1));
            $list .= '<li><a href="' . $configlink . '" class="config-mod">' . gt("Configure Settings") . '</a></li>';
        }
    }
    if (!empty($module->id) && expPermissions::check('delete_module', $cloc)) {
        $deletelink = $router->makeLink(array('module' => 'containermodule', 'id' => $module->id, 'action' => 'delete', 'rerank' => $rerank));
        $list .= '<li><a href="' . $deletelink . '" class="delete" onclick="alert(\'' . gt("This content is being sent to the Recycle Bin to be recovered later if you wish.") . '\')">' . gt("Remove Module") . '</a></li>';
    }
    if (HELP_ACTIVE) {
        $helplink = help::makeHelpLink(expModules::getControllerName($module->info['class']));
        $list .= '<li><a href="' . $helplink . '" class="helplink" target="_blank">' . gt("Get Help") . '</a></li>';
    }
    $list .= '</ul>';
    expCSS::pushToHead(array("unique" => "container-chrome", "link" => PATH_RELATIVE . "framework/modules/container/assets/css/admin-container.css"));
    expJavascript::pushToFoot(array("unique" => 'container-chrome', "yui3mods" => 'node', "src" => PATH_RELATIVE . "framework/core/assets/js/exp-container.js"));
    echo $list;
}
예제 #11
0
 function addToCart($params)
 {
     global $order;
     expSession::set('params', $params);
     //get the configuration
     $cfg->mod = "ecomconfig";
     $cfg->src = "@globalstoresettings";
     $cfg->int = "";
     $config = new expConfig($cfg);
     $this->config = empty($catConfig->config) || @$catConfig->config['use_global'] == 1 ? $config->config : $catConfig->config;
     $min_amount = $this->config['minimum_gift_card_purchase'];
     $custom_message_product = $this->config['custom_message_product'];
     if (empty($params['product_id'])) {
         flash('error', gt("Please specify the style of the gift card you want to purchase."));
         expHistory::back();
     }
     if (empty($params['card_amount']) && empty($params['card_amount_txt'])) {
         flash('error', gt("You need to specify the card amount for the gift card."));
         expHistory::back();
     } else {
         // eDebug($params, true);
         $item = new orderitem($params);
         $sm = $order->getCurrentShippingMethod();
         $item->shippingmethods_id = $sm->id;
         if (isset($params['card_amount_txt'])) {
             $params['card_amount_txt'] = preg_replace("/[^0-9.]/", "", $params['card_amount_txt']);
         }
         if (!empty($params['card_amount_txt']) && $params['card_amount_txt'] > 0) {
             $item->products_price = preg_replace("/[^0-9.]/", "", $params['card_amount_txt']);
         } else {
             $item->products_price = preg_replace("/[^0-9.]/", "", $params['card_amount']);
         }
         if ($item->products_price < $min_amount) {
             flash('error', gt("The minimum amount of gift card is") . " " . $min_amount);
             expHistory::back();
         }
         $item->products_name = expCore::getCurrencySymbol() . $params['card_amount'] . ' ' . $this->title . " Style Gift Card";
         if (!empty($params['toname'])) {
             $ed['To'] = isset($params['toname']) ? $params['toname'] : '';
         }
         if (!empty($params['fromname'])) {
             $ed['From'] = isset($params['fromname']) ? $params['fromname'] : '';
         }
         if (!empty($params['msg'])) {
             $ed['Message'] = isset($params['msg']) ? $params['msg'] : '';
             $item->products_price += $custom_message_product;
             $item->products_name = $item->products_name . " (with message)";
         }
         $item->extra_data = serialize($ed);
         // we need to unset the orderitem's ID to force a new entry..other wise we will overwrite any
         // other giftcards in the cart already
         $item->id = null;
         $item->quantity = $this->getDefaultQuantity();
         $item->save();
         return true;
     }
 }
예제 #12
0
/**
 * Smarty {css} block plugin
 *
 * Type:     block<br>
 * Name:     css<br>
 * Purpose:  Set up a css block
 *
 * @param $params
 * @param $content
 * @param \Smarty $smarty
 * @param $repeat
 */
function smarty_block_css($params, $content, &$smarty, &$repeat)
{
    if ($content) {
        if (empty($params['unique'])) {
            die("<strong style='color:red'>" . gt("The 'unique' parameter is required for the {css} plugin.") . "</strong>");
        }
        expCSS::pushToHead(array("unique" => $params['unique'], "css" => $content, "link" => $params['link'], "corecss" => $params['corecss']));
    }
}
예제 #13
0
 function userFormUpdate($params)
 {
     global $order;
     if ($order->grand_total > $params["cash_amount"]) {
         expValidator::failAndReturnToForm(gt("The total amount of your order is greater than what the amount you have input.") . "<br />" . gt("Please enter exact or greater amount of your total."));
     }
     $this->opts = null;
     $this->opts->cash_amount = $params["cash_amount"];
     return $this->opts;
 }
예제 #14
0
 /**
  * Sorts the array of comparable objects.
  */
 protected function doSort()
 {
     for ($i = $this->n; $i > 1; --$i) {
         for ($j = 0; $j < $i - 1; ++$j) {
             if (gt($this->array[$j], $this->array[$j + 1])) {
                 $this->swap($j, $j + 1);
             }
         }
     }
 }
예제 #15
0
 function form($object)
 {
     $form = new form();
     if (!isset($object->html)) {
         $object->html = "";
     }
     $form->register("html", '', new htmleditorcontrol($object->html));
     $form->register("submit", "", new buttongroupcontrol(gt('Save'), '', gt('Cancel'), "", 'editable'));
     return $form;
 }
/**
 * Smarty {printer_friendly_link} function plugin
 *
 * Type:     function<br>
 * Name:     printer_friendly_link<br>
 * Purpose:  format a link for displaying a printer friendly version of the page
 *
 * @param         $params
 * @param \Smarty $smarty
 * @return bool
 */
function smarty_function_printer_friendly_link($params, &$smarty)
{
    global $router;
    // initialize a couple of variables
    $text = isset($params['text']) ? $params['text'] : gt('View Printer Friendly');
    $view = isset($params['view']) ? $params['view'] : null;
    // spit out the link
    $class = isset($params['class']) ? $params['class'] : 'printer-friendly-link';
    echo $router->printerFriendlyLink($text, $class, 800, 600, $view);
}
 function manage()
 {
     global $db;
     if (SITE_WYSIWYG_EDITOR == "FCKeditor") {
         flash('error', gt('FCKeditor is deprecated!'));
         redirect_to(array("module" => "administration", "action" => "configure_site"));
     }
     // otherwise, on to cke
     $configs = $db->selectObjects('htmleditor_ckeditor', 1);
     assign_to_template(array('configs' => $configs));
 }
 public function beforeActivate()
 {
     $oEvent = $this->getEvent();
     if (class_exists('exportCodeAndText', false)) {
         $test = get_class_vars('exportCodeAndText');
         if (!isset($test['version']) || $test['version'] < 2.2) {
             $oEvent->set('success', false);
             $oEvent->set('message', gt('This plugin can not be activated if exportCodeAndText plugin less than 2.2 version.') . "<pre>" . print_r($test, 1) . "</pre>");
         }
     }
 }
예제 #19
0
 /**
  * Adds the specified binomial tree to this binomial tree.
  * The specified binomial tree and this binomial tree
  * must have the same order.
  * @param object BinomialTree $tree
  * The binomial tree to add to this binomial tree.
  * @exception IllegalArgumentException
  * If the orders of the trees differ.
  **/
 public function add(BinomialTree $tree)
 {
     if ($this->degree != $tree->degree) {
         throw new ArgumentError();
     }
     if (gt($this->key, $tree->key)) {
         $this->swapContentsWith($tree);
     }
     $this->attachSubtree($tree);
     return $this;
 }
예제 #20
0
function smarty_function_list_object($params, &$smarty)
{
    if (isset($params['object'])) {
        echo "<ul>";
        foreach ($params['object'] as $key => $val) {
            echo "<li><strong>{$key}: </strong>{$val}</li>";
        }
        echo "</ul>";
    } else {
        echo '<span class="error">' . gt('No Object Found') . '</span><br />';
    }
}
예제 #21
0
 /**
  * Sorts the array of comparable objects.
  */
 protected function doSort()
 {
     for ($i = $this->n; $i > 1; --$i) {
         $max = 0;
         for ($j = 1; $j < $i; ++$j) {
             if (gt($this->array[$j], $this->array[$max])) {
                 $max = $j;
             }
         }
         $this->swap($i - 1, $max);
     }
 }
예제 #22
0
 public function activate()
 {
     if (isset($this->params['id'])) {
         $calc = new billingcalculator($this->params['id']);
         $calc->update($this->params);
         if ($calc->calculator->hasConfig() && empty($calc->config)) {
             flash('message', $calc->calculator->name() . ' ' . gt('requires configuration. Please do so now.'));
             redirect_to(array('controller' => 'billing', 'action' => 'configure', 'id' => $calc->id));
         }
     }
     expHistory::back();
 }
예제 #23
0
 static function form($object)
 {
     global $db;
     $form = new form();
     if (!isset($object->id)) {
         $object->name = '';
         $object->description = '';
         $object->text = '';
         $object->column_names = '';
     }
     $form->register('name', gt('Name'), new textcontrol($object->name));
     $form->register('description', gt('Description'), new texteditorcontrol($object->description));
     $form->register(null, '', new htmlcontrol(gt('Leave the below custom definition blank to use the default "all fields" e-mail report and record view.')));
     $form->register('text', gt('Custom E-Mail Report and View Record Definition'), new htmleditorcontrol($object->text));
     $fields = array();
     $column_names = array();
     $cols = array();
     if ($object->column_names != '') {
         $cols = explode('|!|', $object->column_names);
     }
     if (isset($object->form_id)) {
         foreach ($db->selectObjects('formbuilder_control', 'form_id=' . $object->form_id . ' and is_readonly=0') as $control) {
             $ctl = unserialize($control->data);
             $control_type = get_class($ctl);
             $def = call_user_func(array($control_type, 'getFieldDefinition'));
             if ($def != null) {
                 $fields[$control->name] = $control->caption;
                 if (in_array($control->name, $cols)) {
                     $column_names[$control->name] = $control->caption;
                 }
             }
         }
         $fields['ip'] = gt('IP Address');
         if (in_array('ip', $cols)) {
             $column_names['ip'] = gt('IP Address');
         }
         if (isset($field['field_user_id'])) {
             $fields['user_id'] = $field['field_user_id'];
         }
         if (in_array('user_id', $cols)) {
             $column_names['user_id'] = gt('Username');
         }
         $fields['timestamp'] = gt('Timestamp');
         if (in_array('timestamp', $cols)) {
             $column_names['timestamp'] = gt('Timestamp');
         }
     }
     $form->register('column_names', gt('Columns shown in View Data/Export CSV'), new listbuildercontrol($column_names, $fields));
     $form->register(null, '', new htmlcontrol(gt('Selecting NO columns is equal to selecting all columns')));
     //		$form->register(null,'', new htmlcontrol('<br /><br /><br />'));
     $form->register('submit', '', new buttongroupcontrol(gt('Save'), '', gt('Cancel')));
     return $form;
 }
예제 #24
0
 static function form($object)
 {
     $form = new form();
     if (!isset($object->id)) {
         $object->answer = '';
     } else {
         $form->meta('id', $object->id);
     }
     $form->register('answer', gt('Answer'), new textcontrol($object->answer));
     $form->register('submit', '', new buttongroupcontrol(gt('Save'), '', gt('Cancel')));
     return $form;
 }
예제 #25
0
 /**
  * @param iPlugin $plugin The plugin to which this question belongs.
  * @param int $questionId
  * @param int $responseId Pass a response id to load results.
  */
 public function __construct(iPlugin $plugin, LimesurveyApi $api, $questionId = null, $responseId = null)
 {
     $this->plugin = $plugin;
     $this->api = $api;
     $this->responseId = $responseId;
     $this->questionId = $questionId;
     if (isset($questionId)) {
         $this->loadSubQuestions($questionId);
     }
     $this->defaultAttributes = array('questiontype' => array('type' => 'select', 'localized' => false, 'advanced' => false, 'label' => gt('Question type:'), 'options' => CHtml::listData(App()->getPluginManager()->loadQuestionObjects(), 'guid', 'name')), 'code' => array('type' => 'string', 'localized' => false, 'advanced' => false, 'label' => gT('Question code:')), 'gid' => array('type' => 'select', 'localized' => false, 'advanced' => false, 'label' => gT('Question group:'), 'options' => function ($this) {
         return $this->api->getGroupList($this->get('sid'));
     }), 'relevance' => array('type' => 'relevance', 'localized' => false, 'advanced' => false, 'label' => gT('Relevance equation:')), 'randomization' => array('type' => 'string', 'localized' => false, 'advanced' => false, 'label' => gT("Randomization group:")));
 }
예제 #26
0
 function editor()
 {
     global $user;
     $file = new expFile($this->params['id']);
     $canSaveOg = $user->id == $file->poster || $user->is_admin ? 1 : 0;
     if (file_exists(BASE . $file->directory . $file->filename)) {
         $file->copyToDirectory(BASE . $this->cacheDir);
         assign_to_template(array('image' => $file, 'update' => $_GET['update'], 'saveog' => $canSaveOg));
     } else {
         flash('error', gt('The file') . ' "' . BASE . $file->directory . $file->filename . '" ' . gt('does not exist on the server.'));
         redirect_to(array("controller" => 'file', "action" => 'picker', "ajax_action" => 1, "update" => $this->params['update'], "fck" => $this->params['fck']));
     }
 }
예제 #27
0
 static function form($object = null)
 {
     $form = new form();
     if (!isset($object->id)) {
         $object->name = '';
         $object->active = 1;
         $object->public = 1;
         $object->subtheme = '';
         $object->page_title = SITE_TITLE;
         $object->keywords = SITE_KEYWORDS;
         $object->description = SITE_DESCRIPTION;
         if (!isset($object->parent)) {
             $object->parent = 0;
         }
         // NOT IMPLEMENTED YET
         //$object->subtheme='';
     } else {
         $form->meta('id', $object->id);
     }
     $form->meta('parent', $object->parent);
     $form->register('name', gt('Name'), new textcontrol($object->name));
     if (!isset($object->id) && $object->parent != 0) {
         // Add the 'Add' drop down if not a top level
         global $db;
         $sections = $db->selectObjects('section_template', 'parent=' . $object->parent);
         if (count($sections)) {
             $sections = expSorter::sort(array('array' => $sections, 'sortby' => 'rank', 'order' => 'ASC'));
             $dd = array(gt('At the Top'));
             foreach ($sections as $s) {
                 $dd[] = sprintf(gt('After') . " %s", $s->name);
             }
             $form->register('rank', gt('Position'), new dropdowncontrol(count($dd) - 1, $dd));
         } else {
             $form->meta('rank', 0);
         }
     } else {
         $form->meta('rank', 0);
     }
     if (is_readable(THEME_ABSOLUTE . 'subthemes')) {
         // grab sub themes
         $form->register('subtheme', gt('Theme Variation'), new dropdowncontrol($object->subtheme, expTheme::getSubThemes()));
     }
     $form->register('active', gt('Active'), new checkboxcontrol($object->active));
     $form->register('public', gt('Public'), new checkboxcontrol($object->public));
     // Register the Page Meta Data controls.
     $form->register('page_title', gt('Page Title'), new textcontrol($object->page_title));
     $form->register('keywords', gt('keywords'), new texteditorcontrol($object->keywords, 5, 25));
     $form->register('description', gt('Page Description'), new texteditorcontrol($object->keywords, 5, 25));
     $form->register('submit', '', new buttongroupcontrol(gt('Save'), '', gt('Cancel')));
     return $form;
 }
 /**
  * Selects an element in the specified range of the array
  * to serve as the pivot.
  *
  * @param integer $left The leftmost element of the range to consider.
  * @param integer $right The rightmost element of the range to consider.
  * @return The position of the pivot.
  */
 protected function selectPivot($left, $right)
 {
     $middle = intval(($left + $right) / 2);
     if (gt($this->array[$left], $this->array[$middle])) {
         $this->swap($left, $middle);
     }
     if (gt($this->array[$left], $this->array[$right])) {
         $this->swap($left, $right);
     }
     if (gt($this->array[$middle], $this->array[$right])) {
         $this->swap($middle, $right);
     }
     return $middle;
 }
예제 #29
0
 /**
  * Percolates the object at position <empy>i</code>
  * in this heap down into the correct position.
  *
  * @param integer $i The position of the object to be percolated down.
  * @param integer $length The length of the heap.
  */
 protected function percolateDown($i, $length)
 {
     while (2 * $i <= $length) {
         $j = 2 * $i;
         if ($j < $length && gt($this->array[$j + 1], $this->array[$j])) {
             $j = $j + 1;
         }
         if (ge($this->array[$i], $this->array[$j])) {
             break;
         }
         $this->swap($i, $j);
         $i = $j;
     }
 }
예제 #30
0
 function update($values, $object)
 {
     if ($object == null) {
         $object = new uploadcontrol();
     }
     if ($values['identifier'] == "") {
         $post = $_POST;
         $post['_formError'] = gt('Identifier is required.');
         expSession::set("last_POST", $post);
         return null;
     }
     $object->identifier = $values['identifier'];
     $object->caption = $values['caption'];
     $object->default = $values['default'];
     return $object;
 }