Exemplo n.º 1
0
 /**
  * Create or Edit a help document
  */
 public function edit()
 {
     global $db, $sectionObj;
     expHistory::set('editable', $this->params);
     $id = empty($this->params['id']) ? null : $this->params['id'];
     $help = new help($id);
     // get the id of the current version and use it if we need to.
     if (expSession::is_set('help-version')) {
         $version = expSession::get('help-version');
         // version the site is currently using
     } else {
         $version = $db->selectValue('help_version', 'id', 'is_current=1');
     }
     if (empty($help->help_version_id)) {
         $help->help_version_id = $version;
     }
     $sectionlist = array();
     $sections = $db->selectObjectsIndexedArray('section', 1);
     $helpsections = $db->selectObjects('help', 1);
     foreach ($helpsections as $helpsection) {
         if ($helpsection->location_data != null) {
             $helpsrc = expUnserialize($helpsection->location_data);
             if (!array_key_exists($helpsrc->src, $sectionlist) && $helpsection->section != 0) {
                 $sectionlist[$helpsrc->src] = $sections[$helpsection->section]->name;
                 if ($helpsection->section == $sectionObj->id) {
                     $sectionlist[$helpsrc->src] .= " (current section)";
                 }
             }
         }
     }
     $sectionlist[$this->loc->src] = $sectionObj->name . " (current section)";
     //	    assign_to_template(array('record'=>$help,"cursec"=>$sectionObj->id,"sections"=>$sectionlist));
     assign_to_template(array('record' => $help, "cursec" => $this->loc->src, "sections" => $sectionlist));
 }
Exemplo n.º 2
0
 function show($view, $loc = null, $title = '')
 {
     if (empty($view)) {
         $view = "Default";
     }
     $source_select = array();
     $clickable_mods = null;
     // Show all
     $dest = null;
     $singleview = '_container';
     $singlemodule = 'containermodule';
     if (expSession::is_set('source_select') && defined('SELECTOR')) {
         $source_select = expSession::get('source_select');
         $singleview = $source_select['view'];
         $singlemodule = $source_select['module'];
         $clickable_mods = $source_select['showmodules'];
         if (!is_array($clickable_mods)) {
             $clickable_mods = null;
         }
         $dest = $source_select['dest'];
     }
     global $db, $user;
     $container = null;
     $container_key = serialize($loc);
     $cache = expSession::getCacheValue('containermodule');
     if (!isset($this) || !isset($this->_hasParent) || $this->_hasParent == 0) {
         // Top level container.
         if (!isset($cache['top'][$container_key])) {
             $container = $db->selectObject('container', "external='" . serialize(null) . "' AND internal='" . $container_key . "'");
             //if container isn't here already, then create it.
             if ($container == null) {
                 $container->external = serialize(null);
                 $container->internal = serialize($loc);
                 $container->view = $view;
                 $container->title = $title;
                 $container->id = $db->insertObject($container, 'container');
             }
             $cache['top'][$container_key] = $container;
             expSession::setCacheValue('containermodule', $cache);
         } else {
             $container = $cache['top'][$container_key];
         }
         if (!defined('PREVIEW_READONLY') || defined('SELECTOR')) {
             $view = empty($container->view) ? $view : $container->view;
         }
         $title = $container->title;
     }
     $template = new template('containermodule', $view, $loc, $cache);
     if ($dest) {
         $template->assign('dest', $dest);
     }
     $template->assign('singleview', $singleview);
     $template->assign('singlemodule', $singlemodule);
     $template->assign('top', $container);
     $containers = array();
     if (!isset($cache[$container_key])) {
         foreach ($db->selectObjects('container', "external='" . $container_key . "'") as $c) {
             if ($c->is_private == 0 || expPermissions::check('view', expCore::makeLocation($loc->mod, $loc->src, $c->id))) {
                 $containers[$c->rank] = $c;
             }
         }
         $cache[$container_key] = $containers;
         expSession::setCacheValue('containermodule', $cache);
     } else {
         $containers = $cache[$container_key];
     }
     ksort($containers);
     foreach (array_keys($containers) as $i) {
         $location = unserialize($containers[$i]->internal);
         // check to see if this is a controller or module
         $iscontroller = expModules::controllerExists($location->mod);
         $modclass = $iscontroller ? expModules::getControllerClassName($location->mod) : $location->mod;
         if (class_exists($modclass)) {
             $mod = new $modclass();
             ob_start();
             $mod->_hasParent = 1;
             if ($iscontroller) {
                 renderAction(array('controller' => $location->mod, 'action' => $containers[$i]->action, 'src' => $location->src, 'view' => $containers[$i]->view, 'moduletitle' => $containers[$i]->title));
             } else {
                 $mod->show($containers[$i]->view, $location, $containers[$i]->title);
             }
             $containers[$i]->output = trim(ob_get_contents());
             ob_end_clean();
             $containers[$i]->info = array('module' => $mod->name(), 'source' => $location->src, 'hasContent' => $mod->hasContent(), 'hasSources' => $mod->hasSources(), 'hasViews' => $mod->hasViews(), 'class' => $modclass, 'supportsWorkflow' => $mod->supportsWorkflow() ? 1 : 0, 'workflowPolicy' => '', 'workflowUsesDefault' => 0, 'clickable' => $clickable_mods == null || in_array($modclass, $clickable_mods), 'hasConfig' => $db->tableExists($modclass . "_config"));
         } else {
             $containers[$i]->output = sprintf(gt('The module "%s" was not found in the system'), $location->mod);
             $containers[$i]->info = array('module' => sprintf(gt('Unknown: %s'), $location->mod), 'source' => $location->src, 'hasContent' => 0, 'hasSources' => 0, 'hasViews' => 0, 'class' => $modclass, 'supportsWorkflow' => 0, 'workflowPolicy' => '', 'workflowUsesDefault' => 0, 'hasConfig' => $db->tableExists($modclass . "_config"), 'clickable' => 0);
         }
         $containers[$i]->moduleLocation = $location;
         $cloc = null;
         $cloc->mod = $loc->mod;
         $cloc->src = $loc->src;
         $cloc->int = $containers[$i]->id;
         $location->mod = str_replace('Controller', '', $location->mod);
         $containers[$i]->permissions = array('administrate' => expPermissions::check('administrate', $location) ? 1 : 0, 'configure' => expPermissions::check('configure', $location) ? 1 : 0);
     }
     $template->assign('user', $user);
     $template->assign('containers', $containers);
     $template->assign('hasParent', isset($this) && isset($this->_hasParent) ? 1 : 0);
     $template->register_permissions(array('administrate', 'add_module', 'edit_module', 'delete_module', 'order_modules'), $loc);
     $template->output();
 }
Exemplo n.º 3
0
 /** exdoc
  * Checks to see if the page is currently in an action.  Useful only if the theme does not use the self::main() function
  * Returns whether or not an action should be run.
  * @node Subsystems:Theme
  * @return bool
  */
 public static function inPreview()
 {
     $level = 99;
     if (expSession::is_set('uilevel')) {
         $level = expSession::get('uilevel');
     }
     return $level == UILEVEL_PREVIEW;
 }
Exemplo n.º 4
0
 /**
  * Routine to check for installation or upgrade
  */
 public static function checkVersion()
 {
     global $db, $user;
     $swversion->major = EXPONENT_VERSION_MAJOR;
     $swversion->minor = EXPONENT_VERSION_MINOR;
     $swversion->revision = EXPONENT_VERSION_REVISION;
     $swversion->type = EXPONENT_VERSION_TYPE;
     $swversion->iteration = EXPONENT_VERSION_ITERATION;
     $swversion->builddate = EXPONENT_VERSION_BUILDDATE;
     // check database version against installed software version
     if ($db->havedb) {
         if ($user->isAdmin()) {
             $dbversion = $db->selectObject('version', 1);
             if (empty($dbversion)) {
                 $dbversion->major = 0;
                 $dbversion->minor = 0;
                 $dbversion->revision = 0;
                 $dbversion->type = '';
                 $dbversion->iteration = '';
             }
             // check if software version is newer than database version
             if (self::compareVersion($dbversion, $swversion)) {
                 $oldvers = $dbversion->major . '.' . $dbversion->minor . '.' . $dbversion->revision . ($dbversion->type ? $dbversion->type : '') . ($dbversion->iteration ? $dbversion->iteration : '');
                 $newvers = $swversion->major . '.' . $swversion->minor . '.' . $swversion->revision . ($swversion->type ? $swversion->type : '') . ($swversion->iteration ? $swversion->iteration : '');
                 flash('message', gt('The database requires upgrading from') . ' v' . $oldvers . ' ' . gt('to') . ' v' . $newvers . '<br><a href="' . makelink(array("controller" => "administration", "action" => "install_exponent")) . '">' . gt('Click here to Upgrade your website') . '</a>');
             }
         }
     } else {
         // database is unavailable, so show us as being offline
         $template = new standalonetemplate('_maintenance');
         $template->assign("db_down", true);
         $template->output();
         exit;
     }
     // check if online version is newer than installed software version, but only once per session
     if ($user->isAdmin()) {
         if (!expSession::is_set('update-check')) {
             $onlineVer = self::getOnlineVersion();
             expSession::set('update-check', '1');
             if (self::compareVersion($swversion, $onlineVer)) {
                 $newvers = $onlineVer->major . '.' . $onlineVer->minor . '.' . $onlineVer->revision . ($onlineVer->type ? $onlineVer->type : '') . ($onlineVer->iteration ? $onlineVer->iteration : '');
                 flash('message', gt('A newer version of Exponent is available') . ': v' . $newvers . ' ' . gt('was released') . ' ' . expDateTime::format_date($onlineVer->builddate) . '<br><a href="https://github.com/exponentcms/exponent-cms/downloads" target="_blank">' . gt('Click here to see available Downloads') . '</a>');
             }
         }
     }
 }
Exemplo n.º 5
0
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
if (!defined('EXPONENT')) {
    exit('');
}
// PERM CHECK
$source_select = array();
$module = "containermodule";
$view = "_sourcePicker";
$clickable_mods = null;
// Show all
$dest = null;
if (expSession::is_set("source_select") && defined('SOURCE_SELECTOR')) {
    $source_select = expSession::get("source_select");
    $view = $source_select["view"];
    $module = $source_select["module"];
    $clickable_mods = $source_select["showmodules"];
    $dest = $source_select['dest'];
}
expSession::clearAllUsersSessionCache('containermodule');
$orphans = array();
foreach ($db->selectObjects("sectionref", "module='" . preg_replace('/[^A-Za-z0-9_]/', '', $_GET['module']) . "' AND refcount=0") as $orphan) {
    $obj = null;
    $loc = expCore::makeLocation($orphan->module, $orphan->source, $orphan->internal);
    if (class_exists($orphan->module)) {
        $modclass = $orphan->module;
        $mod = new $modclass();
        if (class_exists($modclass)) {
Exemplo n.º 6
0
    //return $buffer; // uncomment if you're messing with output buffering so errors show. ~pb
    return expProcessBuffer($buffer);
}
ob_start('epb');
$microtime_str = explode(' ', microtime());
$i_start = $microtime_str[0] + $microtime_str[1];
$section = expSession::is_set('last_section') ? expSession::get('last_section') : SITE_DEFAULT_SECTION;
$section = $db->selectObject('section', 'id=' . $section);
// Handle sub themes
$page = $section && $section->subtheme != '' && is_readable('themes/' . DISPLAY_THEME . '/subthemes/' . $section->subtheme . '.php') ? 'themes/' . DISPLAY_THEME . '/subthemes/' . $section->subtheme . '.php' : 'themes/' . DISPLAY_THEME . '/index.php';
if (is_readable(BASE . $page)) {
    define('PREVIEW_READONLY', 1);
    // for mods
    define('SELECTOR', 1);
    $source_select = array();
    if (expSession::is_set('source_select')) {
        $source_select = expSession::get('source_select');
    }
    $count_orig = count($source_select);
    if (isset($_REQUEST['vview'])) {
        $source_select['view'] = $_REQUEST['vview'];
    } else {
        if (!isset($source_select['view'])) {
            $source_select['view'] = '_sourcePicker';
        }
    }
    if (isset($_REQUEST['vmod'])) {
        $source_select['module'] = $_REQUEST['vmod'];
    } else {
        if (!isset($source_select['module'])) {
            $source_select['module'] = 'containermodule';
Exemplo n.º 7
0
/**
 * Smarty {control} function plugin
 *
 * Type:     function<br>
 * Name:     control<br>
 * Purpose:  create a form control
 *
 * @param         $params
 * @param \Smarty $smarty
 */
function smarty_function_control($params, &$smarty)
{
    global $db, $user;
    if (isset($params['type']) && isset($params['name']) || $params['type'] == 'buttongroup' || $params['type'] == 'antispam') {
        //    || $params['type'] == 'captcha' || $params['type'] == 'recaptcha' || $params['type'] == 'antispam') {
        //	  || $params['type'] == 'recaptcha' || $params['type'] == 'antispam') {
        // if a label wasn't passed in then we need to set one.
        //if (empty($params['label'])) $params['label'] = $params['name'];
        //Figure out which type of control to use. Also, some controls need some special setup.  We handle that here.
        if ($params['type'] == 'popupdatetimecontrol') {
            //FIXME this control does not exist due ot missing library files
            $control = new popupdatetimecontrol(null, "", false);
        } elseif ($params['type'] == 'yuidatetimecontrol') {
            $edittext = isset($params['edit_text']) ? $params['edit_text'] : 'Change Date/Time';
            $showdate = true;
            if (isset($params['show_date']) && $params['show_date'] == false) {
                $showdate = false;
            }
            $showtime = true;
            if (isset($params['show_time']) && $params['show_time'] == false) {
                $showtime = false;
            }
            $control = new yuidatetimecontrol($params['value'], $edittext, $showdate, $showtime);
            if (empty($params['value'])) {
                $params['value'] = time();
            }
        } elseif ($params['type'] == 'yuicalendarcontrol') {
            $control = new yuicalendarcontrol($params['value']);
            if (empty($params['value'])) {
                $params['value'] = time();
            }
        } elseif ($params['type'] == 'datetimecontrol' || $params['type'] == 'datetime') {
            if (empty($params['value'])) {
                $params['value'] = time();
            }
            $showdate = isset($params['showdate']) ? $params['showdate'] : true;
            $showtime = isset($params['showtime']) ? $params['showtime'] : true;
            $control = new datetimecontrol($params['value'], $showdate, $showtime);
        } elseif ($params['type'] == 'monthyear') {
            $control = new monthyearcontrol($params['month'], $params['year']);
        } elseif ($params['type'] == 'buttongroup') {
            $submit = isset($params['submit']) ? $params['submit'] : null;
            $reset = isset($params['reset']) ? $params['reset'] : null;
            $cancel = isset($params['cancel']) ? $params['cancel'] : null;
            $returntype = isset($params['returntype']) ? $params['returntype'] : null;
            $control = new buttongroupcontrol($submit, $reset, $cancel, null, $returntype);
        } elseif ($params['type'] == 'files') {
            if (!empty($params['olduploader'])) {
                $control = new uploadcontrol();
            } else {
                $subtype = isset($params['subtype']) ? $params['subtype'] : null;
                $control = new filemanagercontrol($subtype);
                $control->limit = isset($params['limit']) ? $params['limit'] : 10;
                $control->value = $params['value'];
            }
        } elseif ($params['type'] == 'tags') {
            $collections = isset($params['collections']) ? $params['collections'] : array();
            $subtype = isset($params['subtype']) ? $params['subtype'] : null;
            $control = new tagpickercontrol($collections, $subtype);
        } elseif ($params['type'] == 'dropdown') {
            $control = new dropdowncontrol($params['default']);
            $control->type = "select";
            $control->default = $params['default'];
            $control->include_blank = isset($params['includeblank']) ? $params['includeblank'] : false;
            $control->multiple = isset($params['multiple']) ? true : false;
            if (isset($params['from']) && isset($params['to'])) {
                for ($i = $params['from']; $i <= $params['to']; $i++) {
                    $control->items[$i] = isset($params['zeropad']) ? sprintf("%02d", $i) : $i;
                }
            } elseif (isset($params['frommodel']) || isset($params['items']) && isset($params['key'])) {
                $key = isset($params['key']) ? $params['key'] : 'id';
                $display = isset($params['display']) ? $params['display'] : 'title';
                $order = isset($params['orderby']) ? $params['orderby'] : $display;
                $dir = isset($params['dir']) ? $params['dir'] : 'ASC';
                if (isset($params['frommodel'])) {
                    $model = new $params['frommodel']();
                    $where = empty($params['where']) ? null : $params['where'];
                    $params['items'] = $db->selectObjects($model->tablename, $where, $order . ' ' . $dir);
                }
                foreach ($params['items'] as $item) {
                    $control->items[$item->{$key}] = $item->{$display};
                }
                $noitems = gt("-- No items found --");
                if (count($control->items) < 1) {
                    $control->items = array(0 => $noitems);
                }
            } else {
                if (is_array($params['items'])) {
                    $control->items = $params['items'];
                    if (!empty($params['values'])) {
                        $control->items = array_combine($params['values'], $control->items);
                    }
                } elseif (is_string($params['items'])) {
                    $delimiter = isset($params['delimiter']) ? $params['delimiter'] : ',';
                    $items = explode($delimiter, $params['items']);
                    if (!empty($params['values'])) {
                        $values = is_array($params['values']) ? $params['values'] : explode($delimiter, $params['values']);
                    } else {
                        $values = $items;
                    }
                    $control->items = array_combine($values, $items);
                } else {
                    $control->items = array();
                }
            }
        } elseif ($params['type'] == 'radiogroup') {
            $control = new radiogroupcontrol();
            // differentiate it from the old school forms
            $control->newschool = true;
            $control->default = $params['default'];
            $control->cols = $params['columns'];
            // get the items to use as the radio button labels
            $items = is_array($params['items']) ? $params['items'] : explode(',', $params['items']);
            // check if we have a list of values.  if not we can assume they are passed in via the items
            // array as the keys.
            if (isset($params['values'])) {
                $values = is_array($params['values']) ? $params['values'] : explode(',', $params['values']);
                $control->items = array_combine($values, $items);
            } else {
                $control->items = $items;
                //array_combine($items, $items);
            }
        } elseif ($params['type'] == 'radio') {
            $control = new radiocontrol();
            $control->value = $params['value'];
            $control->newschool = true;
        } elseif ($params['type'] == 'textarea') {
            $control = new texteditorcontrol();
            if (isset($params['module'])) {
                $control->module = $params['module'];
            }
            if (isset($params['rows'])) {
                $control->rows = $params['rows'];
            }
            if (isset($params['cols'])) {
                $control->cols = $params['cols'];
            }
            //if (isset($params['toolbar'])) $control->toolbar = $params['toolbar'];
        } elseif ($params['type'] == 'editor' || $params['type'] == 'html') {
            if (SITE_WYSIWYG_EDITOR == "ckeditor") {
                $control = new ckeditorcontrol();
                $control->toolbar = empty($params['toolbar']) ? '' : $params['toolbar'];
            } else {
                $control = new htmleditorcontrol();
                if (isset($params['module'])) {
                    $control->module = $params['module'];
                }
                if (isset($params['rows'])) {
                    $control->rows = $params['rows'];
                }
                if (isset($params['cols'])) {
                    $control->cols = $params['cols'];
                }
                $control->height = $params['height'] ? $params['height'] : "600px";
                if (isset($params['toolbar'])) {
                    $control->toolbar = $params['toolbar'];
                }
            }
        } elseif ($params['type'] == 'listbuilder') {
            $default = isset($params['default']) ? $params['default'] : array();
            $source = isset($params['source']) ? $params['source'] : array();
            $control = new listbuildercontrol($default, $source);
            echo $control->controlToHTML($params['name']);
            return;
        } elseif ($params['type'] == 'list') {
            $control = new listcontrol();
        } elseif ($params['type'] == 'antispam') {
            //eDebug(ANTI_SPAM_CONTROL, true);
            if (SITE_USE_ANTI_SPAM && ANTI_SPAM_CONTROL == 'recaptcha') {
                // make sure we have the proper config.
                if (!defined('RECAPTCHA_PUB_KEY')) {
                    echo '<h2 style="color:red">' . gt('reCaptcha configuration is missing the public key.') . '</h2>';
                    return;
                }
                if ($user->isLoggedIn() && ANTI_SPAM_USERS_SKIP == 1) {
                    // skip it for logged on users based on config
                } else {
                    // include the library and show the form control
                    require_once BASE . 'external/recaptchalib.php';
                    echo recaptcha_get_html(RECAPTCHA_PUB_KEY, $error);
                    echo '<p>' . gt('Fill out the above security question to submit your form.') . '</p>';
                }
                return;
            } elseif (ANTI_SPAM_CONTROL == 0) {
                return;
            }
        } elseif ($params['type'] == 'user') {
            $control = new dropdowncontrol();
            $control->include_blank = isset($params['includeblank']) ? $params['includeblank'] : false;
            $control->items = $db->selectDropdown('user', 'username');
        } elseif ($params['type'] == 'state') {
            //old use:  if (empty($params['all_us_territories'])) {
            /*$regions = $db->select
                  $not_states = array(3,6,7,8,9,10,11,17,20,30,46,50,52,60);
              } else {
                  $not_states = array();
              }*/
            //if(!empty($params['exclude'])) $not_states = array_merge($not_states,explode(',',$params['exclude']));
            if ($db->tableExists('geo_region')) {
                $c = $db->selectObject('geo_country', 'is_default=1');
                if (empty($c->id)) {
                    $country = 223;
                } else {
                    $country = $c->id;
                }
                $control = new dropdowncontrol();
                if (isset($params['multiple'])) {
                    $control->multiple = true;
                    $control->items[-1] = 'ALL United States';
                }
                /*if (isset($params['add_other'])) {                   
                      $control->items[-2] = '-- Specify State Below --';
                  }*/
                $states = $db->selectObjects('geo_region', 'country_id=' . $country . ' AND active=1 ORDER BY rank, name ASC');
                foreach ($states as $state) {
                    // only show the US states unless the theme says to show all us territories
                    //if (!in_array($state->id, $not_states)) {
                    $control->items[$state->id] = isset($params['abbv']) ? $state->code : $state->name;
                    //}
                }
                //if(!count($states)) $control->items[-2] = '-- Specify State Below --';
                if (isset($params['add_other'])) {
                    $control->items[-2] = '-- Specify State Below --';
                } else {
                    $control->include_blank = isset($params['includeblank']) ? $params['includeblank'] : false;
                }
                // sanitize the default value. can accept as id, code abbrv or full name,
                if (!empty($params['value']) && !is_numeric($params['value']) && !is_array($params['value'])) {
                    $params['value'] = $db->selectValue('geo_region', 'id', 'name="' . $params['value'] . '" OR code="' . $params['value'] . '"');
                }
            } else {
                echo "NO TABLE";
                exit;
            }
        } elseif ($params['type'] == 'country') {
            //old - pre address configuration
            //if(!empty($params['exclude'])) $not_countries = explode(',',$params['exclude']);
            //else $not_countries = array();
            if ($db->tableExists('geo_country')) {
                $control = new dropdowncontrol();
                $control->include_blank = isset($params['includeblank']) ? $params['includeblank'] : false;
                if (isset($params['multiple'])) {
                    $control->multiple = true;
                    //$control->items[-1] = 'ALL United States';
                }
                if ($params['show_all']) {
                    $countries = $db->selectObjects('geo_country', null, 'name ASC');
                } else {
                    $countries = $db->selectObjects('geo_country', 'active=1', 'name ASC');
                }
                foreach ($countries as $country) {
                    //if (!in_array($country->id, $not_countries)) {
                    $control->items[$country->id] = isset($params['abbv']) ? $country->iso_code_3letter : $country->name;
                    //}
                }
                // sanitize the default value. can accept as id, code abbrv or full name,
                if (!empty($params['value']) && !is_numeric($params['value']) && !is_array($params['value'])) {
                    $params['value'] = $db->selectValue('geo_country', 'id', 'name="' . $params['value'] . '" OR code="' . $params['value'] . '"');
                }
            } else {
                echo "NO TABLE";
                exit;
            }
        } elseif ($params['type'] == 'quantity') {
            $value = isset($params['value']) ? $params['value'] : null;
            $min = isset($params['min']) ? $params['min'] : 0;
            $max = isset($params['max']) ? $params['max'] : 99999;
            $control = new quantitycontrol($value, $min, $max);
        } elseif ($params['type'] == 'checkbox') {
            $value = isset($params['value']) ? $params['value'] : null;
            $control = new checkboxcontrol($value);
            $control->postfalse = isset($params['postfalse']) ? 1 : 0;
            $control->newschool = true;
            $control->value = isset($params['value']) ? $params['value'] : 1;
        } elseif ($params['type'] == 'tagtree') {
            $control = new tagtreecontrol($params);
        } elseif ($params['type'] == 'filedisplay-types') {
            $control = new dropdowncontrol();
            $control->include_blank = '-- This modules does not use files --';
            $control->items = get_filedisplay_views();
        } elseif ($params['type'] == 'calendar') {
            $control = new calendarcontrol();
        } elseif ($params['type'] == 'text') {
            $control = new genericcontrol($params['type']);
            $control->size = $params['size'] ? $params['size'] : "40";
        } elseif ($params['type'] == 'autocomplete') {
            $control = new autocompletecontrol();
            $control->schema = "'" . str_replace(",", "','", $params['schema']) . "'";
            $control->value = $params['value'];
            $control->controller = empty($params['controller']) ? "search" : $params['controller'];
            $control->action = empty($params['action']) ? "autocomplete" : $params['action'];
            $control->searchmodel = empty($params['searchmodel']) ? "text" : $params['searchmodel'];
            $control->searchoncol = empty($params['searchoncol']) ? "title" : $params['searchoncol'];
            $control->jsinject = empty($params['jsinject']) ? "" : $params['jsinject'];
        } else {
            $control = new genericcontrol($params['type']);
        }
        //eDebug($smarty->getTemplateVars('formError'));
        //Add the optional params in specified
        if (isset($params['class'])) {
            $control->class = $params['class'];
        }
        if (isset($params['required'])) {
            $control->required = true;
        }
        // Let see if this control should be checked
        if (isset($params['checked'])) {
            // if we have a control group the values will probably be coming in an array
            if (is_array($params['checked'])) {
                // check if its in the array
                if (in_array($params['value'], $params['checked'])) {
                    $control->checked = true;
                } elseif (is_object(current($params['checked']))) {
                    foreach ($params['checked'] as $obj) {
                        if ($obj->id == $params['value']) {
                            $control->checked = true;
                        }
                    }
                }
            } elseif ($params['value'] == $params['checked']) {
                $control->checked = true;
            } elseif (is_bool($params['checked'])) {
                $control->checked = $params['checked'];
            } elseif ($params['checked'] == 1) {
                $control->checked = 1;
            }
        }
        if (expSession::is_set('last_POST')) {
            $post = expSession::get('last_POST');
            $post_errors = expSession::get('last_post_errors');
            // flag this field as having errors if it failed validation
            if (is_array($post_errors) && in_array($params['name'], $post_errors)) {
                $control->class .= ' field-error';
            }
            if ($params['type'] == 'checkbox') {
                $realname = str_replace('[]', '', $params['name']);
                $control->default = $params['value'];
                if (!empty($post[$realname])) {
                    if (is_array($post[$realname])) {
                        if (in_array($params['value'], $post[$realname])) {
                            $control->checked = true;
                        }
                    } else {
                        $control->checked = true;
                    }
                }
            } elseif (isset($params['multiple'])) {
                $realname = str_replace('[]', '', $params['name']);
                if (!empty($post[$realname])) {
                    $control->default = $post[$realname];
                }
            } else {
                if (!empty($post[$params['name']])) {
                    $control->default = $post[$params['name']];
                }
            }
        } elseif (isset($params['value'])) {
            // if this field is filtered than lets go ahead and format the data before we stick it in the field.
            if ($params['filter'] == 'money') {
                $params['value'] = expCore::getCurrencySymbol('USD') . number_format($params['value'], 2, '.', ',');
            } elseif ($params['filter'] == 'integer') {
                $params['value'] = number_format($params['value'], 0, '.', ',');
            }
            $control->default = $params['value'];
        }
        //if (isset($params['value'])) $control->default = $params['value'];
        if (isset($params['caption'])) {
            $control->caption = $params['caption'];
        }
        if (isset($params['size'])) {
            $control->size = $params['size'];
        }
        if (isset($params['nowrap'])) {
            $control->nowrap = "nowrap";
        }
        if (isset($params['flip'])) {
            $control->flip = $params['flip'];
        }
        if (isset($params['disabled']) && $params['disabled'] != false) {
            $control->disabled = true;
        }
        if (isset($params['maxlength'])) {
            $control->maxlength = $params['maxlength'];
        }
        if (isset($params['tabindex'])) {
            $control->tabindex = $params['tabindex'];
        }
        if (isset($params['accesskey'])) {
            $control->accesskey = $params['accesskey'];
        }
        if (isset($params['filter'])) {
            $control->filter = $params['filter'];
        }
        if (isset($params['onclick'])) {
            $control->onclick = $params['onclick'];
        }
        if (isset($params['onchange'])) {
            $control->onchange = $params['onchange'];
        }
        if (isset($params['readonly']) && $params['readonly'] != false) {
            $control->readonly = true;
        }
        if (isset($params['ajaxaction'])) {
            $control->ajaxaction = $params['ajaxaction'];
        }
        if (isset($params['loadjsfile'])) {
            $control->loadjsfile = $params['loadjsfile'];
        }
        if (isset($params['default_date'])) {
            $control->default_date = $params['default_date'];
        }
        if (isset($params['default_hour'])) {
            $control->default_hour = $params['default_hour'];
        }
        if (isset($params['default_min'])) {
            $control->default_min = $params['default_min'];
        }
        if (isset($params['default_ampm'])) {
            $control->default_ampm = $params['default_ampm'];
        }
        $control->name = $params['name'];
        $badvals = array("[", "]", ",", " ", "'", "\"", "&", "#", "%", "@", "!", "\$", "(", ")", "{", "}");
        //$newid = str_replace($badvals, "", $params['name']);
        $control->id = isset($params['id']) && $params['id'] != "" ? $params['id'] : "";
        //echo $control->id;
        /*$labelclass = isset($params['labelclass']) ? ' '.$params['labelclass'] : '';
                
                //container for the controll set, including labelSpan and input
                if($params['type']!='hidden') echo '<label id="'.$control->id.'Control" class="control">'; 
        
        
                //Write out the label for this control if the user specified a label and there is no label position or position is set to left
                if ( (isset($params['label'])) && (!isset($params['labelpos']) || $params['labelpos'] == 'left') ) {
                    echo '<span class="label'.$labelclass.'">'.$params['label'].'</span>';
                }
                */
        // attempt to translate the label
        if (!empty($params['label'])) {
            $params['label'] = gt($params['label']);
        }
        //write out the control itself...and then we're done.
        if (isset($params['model'])) {
            echo $control->toHTML($params['label'], $params['model'] . '[' . $params['name'] . ']');
        } else {
            echo $control->toHTML($params['label'], $params['name']);
        }
        /*
        //Write out the label for this control if the user specified a label and position is set to right
        if (isset($params['label']) && $params['labelpos'] == 'right') {
            echo '<span class="label'.$labelclass.'">'.$params['label'].'</span>';
        }
        
        //close the control container div
        if($params['type']!='hidden'){ echo '</label>'; }
        */
    } else {
        echo "Both the 'type' and 'name' parameters are required for the control plugin to function";
    }
}
 public function toggle_mobile()
 {
     if (!expSession::is_set('mobile')) {
         // account for FORCE_MOBILE initial state
         expSession::set('mobile', MOBILE);
     }
     expSession::set('mobile', !expSession::get('mobile'));
     expTheme::removeSmartyCache();
     expHistory::back();
 }
Exemplo n.º 9
0
 function myOrder()
 {
     global $user, $db;
     $order = new order($this->params['id']);
     if ($order->purchased == 0) {
         flashAndFlow('error', 'You do not have permission to view this order.');
     }
     $this->loc->src = "@globalstoresettings";
     // We're forcing the location. Global store setting will always have this loc
     $cfg->mod = "ecomconfig";
     $cfg->src = "@globalstoresettings";
     $cfg->int = "";
     $storeConfig = new expConfig($cfg);
     //check here for the hash in the params, or session set w/ perms to view...shs = xaf7y0s87d7elshd70 etc
     //if present, promt user for the order number and email address on the order
     //and if they pass, show the order to them. Need to maybe set something in the session then for subsequent
     //viewing of the order?
     if ($user->id != $order->user_id) {
         if ($user->isAdmin()) {
             redirect_to(array('controller' => 'order', 'action' => 'show', 'id' => $this->params['id']));
         } else {
             flashAndFlow('error', 'You do not have permission to view this order.');
         }
     }
     expHistory::set('viewable', $this->params);
     $billing = new billing($this->params['id']);
     $status_messages = $db->selectObjects('order_status_messages');
     $order_type = $order->getOrderType();
     $order->total_items = 0;
     foreach ($order->orderitem as $item) {
         $order->total_items += $item->quantity;
         $order->shipping_city = $item->shippingmethod->city;
         $order->shipping_state = $item->shippingmethod->state;
     }
     $state = new geoRegion($order->shipping_state);
     $country = new geoCountry($state->country_id);
     $order->shipping_country = $country->iso_code_3letter;
     $order->shipping_state = $state->name;
     //eDebug($order,true);
     $order->billingmethod[0]->billingtransaction = array_reverse($order->billingmethod[0]->billingtransaction);
     if (isset($this->params['printerfriendly'])) {
         $pf = $this->params['printerfriendly'];
     } else {
         $pf = 0;
     }
     $trackMe = false;
     if (isset($this->params['tc']) && $this->params['tc'] == 1) {
         if (expSession::is_set('orders_tracked')) {
             $trackingArray = expSession::get('orders_tracked');
             if (in_array($order->invoice_id, $trackingArray)) {
                 $trackMe = false;
             } else {
                 $trackMe = true;
                 $trackingArray[] = $order->invoice_id;
                 expSession::set('orders_tracked', $trackingArray);
             }
         } else {
             $trackMe = true;
             $trackingArray[] = $order->invoice_id;
             expSession::set('orders_tracked', $trackingArray);
         }
     }
     if (DEVELOPMENT != 0) {
         $trackMe = false;
     }
     assign_to_template(array('printerfriendly' => $pf, 'order' => $order, 'shipping' => $order->orderitem[0], 'billing' => $billing, 'order_type' => $order_type, 'storeConfig' => $storeConfig->config, 'tc' => $trackMe));
 }
Exemplo n.º 10
0
 /**
  * main login method
  */
 public static function login()
 {
     user::login($_POST['username'], $_POST['password']);
     if (!isset($_SESSION[SYS_SESSION_KEY]['user'])) {
         flash('error', gt('Invalid Username / Password'));
         if (expSession::is_set('redirecturl_error')) {
             $url = expSession::get('redirecturl_error');
             expSession::un_set('redirecturl_error');
             header("Location: " . $url);
         } else {
             expHistory::back();
         }
     } else {
         global $user;
         if (!empty($_POST['username'])) {
             flash('message', gt('Welcome back') . ' ' . $_POST['username']);
         }
         foreach ($user->groups as $g) {
             if (!empty($g->redirect)) {
                 $url = URL_FULL . $g->redirect;
                 break;
             }
         }
         if (isset($url)) {
             header("Location: " . $url);
         } else {
             expHistory::back();
         }
     }
 }
Exemplo n.º 11
0
 function toHTML($form_id, $module = "formbuilder")
 {
     // Form validation script
     if ($this->validationScript != "") {
         $this->scripts[] = $this->validationScript;
         $this->controls["submit"]->validateJS = "validate(this.form)";
     }
     // Persistent Form Data extension
     $formError = "";
     if (expSession::is_set("last_POST")) {
         // We have cached POST data.  Use it to update defaults.
         $last_POST = expSession::get("last_POST");
         foreach (array_keys($this->controls) as $name) {
             // may need to look to control a la parseData
             $this->controls[$name]->default = @$last_POST[$name];
         }
         $formError = @$last_POST['_formError'];
         //expSession::un_set("last_POST");
     }
     global $router;
     $html = "<!-- Form Object '" . $this->name . "' -->\r\n";
     $html .= "<script type=\"text/javascript\" src=\"" . PATH_RELATIVE . "framework/core/subsystems/forms/js/inputfilters.js.php\"></script>\r\n";
     foreach ($this->scripts as $name => $script) {
         $html .= "<script type=\"text/javascript\" src=\"{$script}\"></script>\r\n";
     }
     $html .= $formError;
     $html .= "<form name=\"" . $this->name . "\" method=\"" . $this->method . "\" action=\"" . $this->action . "\" enctype=\"" . $this->enctype . "\">\r\n";
     foreach ($this->meta as $name => $value) {
         $html .= "<input type=\"hidden\" name=\"{$name}\" id=\"{$name}\" value=\"{$value}\" />\r\n";
     }
     $rank = 0;
     $even = "odd";
     foreach ($this->controlIdx as $name) {
         $even = $even == "odd" ? "even" : "odd";
         $html .= "<div class=\"formmoduleedit " . $even . " control\">";
         $html .= "<div class=\"label\">" . $this->controlLbl[$name] . "</div>";
         $html .= "<div class=\"formmoduleeditactions\">";
         if ($rank != count($this->controlIdx) - 1) {
             //$html .= '<a href="?module='.$module.'&action=order_controls&p='.$form_id.'&a='.$rank.'&b='.($rank+1).'">';
             $html .= '<a href="' . $router->makeLink(array('module' => $module, 'action' => 'order_controls', 'p' => $form_id, 'a' => $rank, 'b' => $rank + 1)) . '">';
             $html .= "<img border='0' src='" . ICON_RELATIVE . "down.png' />";
             $html .= '</a>';
         } else {
             $html .= "<img src='" . ICON_RELATIVE . "down.disabled.png' />";
         }
         $html .= "&nbsp;";
         if ($rank != 0) {
             //$html .= '<a href="?module='.$module.'&action=order_controls&p='.$form_id.'&a='.$rank.'&b='.($rank-1).'">';
             $html .= '<a href="' . $router->makeLink(array('module' => $module, 'action' => 'order_controls', 'p' => $form_id, 'a' => $rank, 'b' => $rank - 1)) . '">';
             $html .= "<img border='0' src='" . ICON_RELATIVE . "up.png' />";
             $html .= '</a>';
         } else {
             $html .= "<img src='" . ICON_RELATIVE . "up.disabled.png' />";
         }
         $html .= "&nbsp;&nbsp;";
         if (!$this->controls[$name]->_readonly) {
             //$html .= '<a href="?module='.$module.'&action=edit_control&id='.$this->controls[$name]->_id.'&form_id='.$form_id.'">';
             $html .= '<a href="' . $router->makeLink(array('module' => $module, 'action' => 'edit_control', 'id' => $this->controls[$name]->_id, 'form_id' => $form_id)) . '">';
             $html .= '<img style="border:none;" src="' . ICON_RELATIVE . 'edit.png" />';
             $html .= '</a>';
         } else {
             $html .= '<img style="border:none;" src="' . ICON_RELATIVE . 'edit.disabled.png" />';
         }
         $html .= '&nbsp;';
         if (!$this->controls[$name]->_readonly && $this->controls[$name]->_controltype != 'htmlcontrol') {
             //$html .= '<a href="?module='.$module.'&action=delete_control&id='.$this->controls[$name]->_id.'" onclick="return confirm(\'Are you sure you want to delete this control? All data associated with it will be removed from the database!\');">';
             $html .= '<a href="' . $router->makeLink(array('module' => $module, 'action' => 'delete_control', 'id' => $this->controls[$name]->_id)) . '" onclick="return confirm(\'Are you sure you want to delete this control? All data associated with it will be removed from the database!\');">';
         } else {
             $html .= '<a href="' . $router->makeLink(array('module' => $module, 'action' => 'delete_control', 'id' => $this->controls[$name]->_id)) . '" onclick="return confirm(\'Are you sure you want to delete this?\');">';
         }
         $html .= '<img style="border:none;" src="' . ICON_RELATIVE . 'delete.png" />';
         $html .= '</a>';
         $html .= "</div>";
         $html .= $this->controls[$name]->controlToHTML($name, $this->controlLbl[$name]) . "\r\n";
         $html .= "</div>";
         $rank++;
     }
     //	$html .= "<tr><td width='5%'></td><td wdith='90%'><td></td width='5%'></tr>\r\n";
     //	$html .= "</table>\r\n";
     $html .= "</form>\r\n";
     return $html;
 }
Exemplo n.º 12
0
 public function getSection()
 {
     if (expTheme::inAction()) {
         if (isset($_REQUEST['section'])) {
             $section = $this->url_type == "sef" ? $this->getPageByName($_REQUEST['section']) : $_REQUEST['section'];
         } else {
             $section = expSession::is_set('last_section') ? expSession::get('last_section') : SITE_DEFAULT_SECTION;
         }
     } else {
         $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : SITE_DEFAULT_SECTION;
     }
     return $section;
 }
Exemplo n.º 13
0
# Exponent is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
if (!defined('EXPONENT')) {
    exit('');
}
global $user;
/////////////////////////////////////////////////////////////////////////
// FIGURE OUT IF WE"RE IN PREVIEW MODE OR NOT
/////////////////////////////////////////////////////////////////////////
$level = 99;
if (expSession::is_set('uilevel')) {
    $level = expSession::get('uilevel');
}
//if ($level == UILEVEL_PREVIEW) {
//    $preview_url = makeLink(array('module'=>'previewmodule','action'=>'normal'));
//    $preview_class = 'preview_on';
//} else {
//    $preview_url = makeLink(array('module'=>'previewmodule','action'=>'preview'));
//    $preview_class = 'preview_off';
//}
/////////////////////////////////////////////////////////////////////////
// BUILD THE MENU
/////////////////////////////////////////////////////////////////////////
return array('text' => $user->firstname . ' ' . $user->lastname, 'classname' => 'quicklink user', 'submenu' => array('id' => 'user', 'itemdata' => array(array('text' => gt("Edit My Profile"), 'url' => makeLink(array('controller' => 'users', 'action' => 'edituser', 'id' => $user->id)), 'classname' => 'edit'), array('text' => gt("Change My Password"), 'url' => makeLink(array('controller' => 'users', 'action' => 'change_password', 'ud' => $user->id)), 'classname' => 'password'), array('text' => gt("Log Out"), 'url' => makeLink(array('controller' => 'login', 'action' => 'logout')), 'classname' => 'logout'), array('text' => gt('Preview Mode'), 'text' => $level == UILEVEL_PREVIEW ? gt('Turn Preview Mode off') : gt('Turn Preview Mode on'), 'classname' => $level == UILEVEL_PREVIEW ? 'preview_on' : 'preview_off', 'url' => makeLink(array('controller' => 'administration', 'action' => 'toggle_preview'))))));
Exemplo n.º 14
0
 /**
  * Convert the form to HTML output.
  *
  * @return The HTML code use to display the form to the browser.
  */
 function toHTML()
 {
     // Form validation script
     if ($this->validationScript != "") {
         $this->scripts[] = $this->validationScript;
         $this->controls["submit"]->validateJS = "validate(this.form)";
     }
     // Persistent Form Data extension
     $formError = "";
     if (expSession::is_set("last_POST")) {
         // We have cached POST data.  Use it to update defaults.
         $last_POST = expSession::get("last_POST");
         foreach (array_keys($this->controls) as $name) {
             // may need to look to control a la parseData
             $this->controls[$name]->default = @$last_POST[$name];
             $this->controls[$name]->inError = 1;
             // Status flag for controls that need to do some funky stuff.
         }
         $formError = @$last_POST['_formError'];
         //expSession::un_set("last_POST");
     }
     $html = "<!-- Form Object '" . $this->name . "' -->\r\n";
     $html .= '<script type="text/javascript" src="' . PATH_RELATIVE . 'framework/core/subsystems/forms/js/required.js"></script>' . "\r\n";
     $html .= "<script type=\"text/javascript\" src=\"" . PATH_RELATIVE . "framework/core/subsystems/forms/js/inputfilters.js.php\"></script>\r\n";
     foreach ($this->scripts as $name => $script) {
         $html .= "<script type=\"text/javascript\" src=\"{$script}\"></script>\r\n";
     }
     $html .= '<div class="error">' . $formError . '</div>';
     if (isset($this->ajax_updater)) {
         $html .= "<form name=\"" . $this->name . "\" method=\"";
         $html .= $this->method . "\" action=\"" . $this->action . "\" ";
         $html .= " onsubmit=\"new Ajax.Updater('" . $this->div_to_update . "', '" . $this->action . "', ";
         $html .= "{asynchronous:true, parameters:Form.serialize(this)}); return false;\">\r\n";
     } else {
         $html .= "<form name=\"" . $this->name . "\" method=\"" . $this->method . "\" action=\"" . $this->action . "\" enctype=\"" . $this->enctype . "\">\r\n";
     }
     //$html .= "<form name=\"" . $this->name . "\" method=\"" . $this->method . "\" action=\"" . $this->action . "\" enctype=\"".$this->enctype."\">\r\n";
     foreach ($this->meta as $name => $value) {
         $html .= "<input type=\"hidden\" name=\"{$name}\" id=\"{$name}\" value=\"{$value}\" />\r\n";
     }
     $html .= "<div class=\"form_wrapper\">\r\n";
     foreach ($this->controlIdx as $name) {
         $html .= $this->controls[$name]->toHTML($this->controlLbl[$name], $name) . "\r\n";
     }
     $html .= "</div>\r\n";
     $html .= "</form>\r\n";
     return $html;
 }