public function displaySiteTemplate($view = 'site_template')
 {
     ob_start();
     Display::displaySiteTemplate($view);
     $data = ob_get_clean();
     if ($this->ajaxResponse()) {
         echo $this->getAjaxResponse($view);
     } else {
         echo $data;
     }
     $view_cache = array();
     foreach ($this->views as $name => $view) {
         $view_cache[$name] = $view->toString();
     }
     $cache = ArrayUtility::merge($view_cache, $this->variables);
     $cache['chunks'] = $this->chunks;
     $cache['user'] = Application::user()->toString();
     $data = serialize($cache);
     file_put_contents($this->cachePath(), $data);
 }
예제 #2
0
 /**
  * Restrict what fields to select
  * 
  * It is always a good idea to get only what you need from a query, for memory and
  * speed purposes. This method uses a variable argument list, so you can ask for
  * fields like this:
  * 
  * <code>
  * $auth = new Author();
  * $auth->select('first_name','last_name');
  * </code>
  * 
  * @param variable argument list
  * @access public
  * @see limit,order,descending
  */
 function select()
 {
     $args = func_get_args();
     $this->select = ArrayUtility::merge($args, $this->select);
 }
 function generateInputObjects()
 {
     $ret = array();
     $tabindex_count = 0;
     foreach ($this->standard_options as $name => $values) {
         if (isset($values['value'])) {
             $value = $values['value'];
         } else {
             $value = '';
         }
         if (isset($values['label'])) {
             $label = $values['label'];
         } else {
             $label = '';
         }
         if ($this->item_link_class) {
             $secondary_get_vars = ArrayUtility::merge($this->secondary_get_vars, array($name => $value));
             $href = Display::hrefString($this->item_link_class, $secondary_get_vars);
             $label = new FormLink($href, $label);
         } else {
             $label = new FormLabel($label);
         }
         switch ($this->type) {
             case ButtonGroup::CHECK:
                 $obj = new Checkbox($name, $this->class, '', $value, $label, '');
                 break;
             case ButtonGroup::RADIO:
                 $obj = new RadioButton($name, $this->class, '', $value, $label, '');
                 break;
             case ButtonGroup::NONE:
                 $obj = $label;
                 break;
         }
         if ($obj instanceof FormInput) {
             $obj->setTabindex($this->tabindex + $tabindex_count);
         }
         $tabindex_count++;
     }
     $selected = $this->selected;
     $primary_get_string = '';
     $check_name = $this->name;
     if (!$this->options) {
         $this->options = array();
     }
     foreach ($this->options as $opt) {
         $cur_check_name = $opt->formOptionName($check_name);
         $cur_check_value = $opt->formOptionValue();
         $cur_check_label = $opt->toString();
         $opt->formLinkGetVars($this->secondary_get_vars);
         $check_selected = ArrayUtility::arrayFromString($cur_check_name, false);
         if ($this->type == ButtonGroup::CHECK || $this->type == ButtonGroup::NONE) {
             $cur_check_name .= '[]';
         }
         if ($this->item_link_class) {
             $href = Display::hrefString($this->item_link_class, $this->secondary_get_vars);
             $label = new FormLink($href, $cur_check_label);
         } else {
             $label = new FormLabel($cur_check_label);
         }
         switch ($this->type) {
             case ButtonGroup::CHECK:
                 if (count($check_selected) && is_array($check_selected)) {
                     $sel_array = ArrayUtility::getArrayValueMulti($selected, $check_selected);
                     if (!is_array($sel_array)) {
                         $sel_array = array();
                     }
                 } else {
                     $sel_array = $selected;
                 }
                 if (in_array($cur_check_value, $sel_array)) {
                     $is_selected = true;
                 } else {
                     $is_selected = false;
                 }
                 $obj = new Checkbox($cur_check_name, $this->class, '', $cur_check_value, $label, $is_selected);
                 break;
             case ButtonGroup::RADIO:
                 if ($cur_check_value == $selected) {
                     $is_selected = true;
                 } else {
                     $is_selected = false;
                 }
                 $obj = new RadioButton($cur_check_name, $this->class, '', $cur_check_value, $label, $is_selected);
                 break;
             case ButtonGroup::NONE:
                 $obj = new HiddenLabel($cur_check_name, $cur_check_value, $label, '');
                 break;
         }
         if ($obj instanceof FormInput) {
             $obj->setTabindex($this->tabindex + $tabindex_count);
         }
         $ret[] = $obj;
         $tabindex_count++;
     }
     return $ret;
 }
 /**
  * Return all parameters, $_POST,$_GET and user parameters
  * @return array - all parameters to the application
  * @access public
  * @static
  */
 public static function parameters()
 {
     $ret = Application::post();
     $ret = ArrayUtility::merge($ret, Application::get());
     $ret = ArrayUtility::merge($ret, Session::getRegistered('userParams'));
     return $ret;
 }
예제 #5
0
 function getWidgets($view)
 {
     foreach ($view->widgets() as $widg) {
         $widg->registerJavascript("");
     }
     $this->widgets = ArrayUtility::merge($this->widgets, $view->widgets());
 }
 public function appendArgument($script, $name, $data)
 {
     if (isset($this->register[$script])) {
         $params = $this->register[$script];
         if (isset($params['args'])) {
             $args = $params['args'];
         } else {
             $args = array();
         }
         //WHEN APPENDING THE ARGUMENT, CHECK IF IT EXISTS FIRST
         //IF IT DOESN'T, THEN SIMPLY ADD IT TO THE ARRAY. IF
         //IT DOES, THEN COMBINE IT WITH OTHER ARGUMENTS OF THE
         //SAME NAME AS AN ARRAY
         if (!isset($args[$name])) {
             $args[$name] = $data;
         } else {
             if (!is_array($args[$name])) {
                 $new_array = array($args[$name]);
                 if (is_array($data)) {
                     $args[$name] = ArrayUtility::merge($new_array, $data);
                 } else {
                     $new_array[] = $data;
                     $args[$name] = $new_array;
                 }
             } else {
                 $args[$name] = ArrayUtility::merge($args[$name], $data);
             }
         }
         $this->register[$script]['args'] = $args;
         if ($this->name) {
             $this->toString();
         }
     } else {
         throw new Exception('Cannot append arguments for ' . $script . ' because it is not in the register');
     }
 }
 /**
  * Add options as an associative array
  */
 function addOptions($array)
 {
     $new_options = ArrayUtility::merge($this->options, $array);
     $this->setOptions($new_options);
 }
 /**
  * This function allows the easy conversion of a string in the form:
  * string1[string2][string3]...
  * into an array:
  * array('string1','string2','string3');
  * So far it's only used once (in form.class.inc) to split up the name
  * of a form element, but I thought I'd chuck it in here just in case...
  */
 function arrayFromString($string, $return_array = true)
 {
     $arr1 = '';
     if ($string) {
         /*check that it's the type of string we are looking for*/
         if (preg_match('/.*\\[.+\\]*/', $string)) {
             /*start by splitting the bulk of the string up*/
             $arr1 = explode('][', $string);
             //StringUtility::split($string,'][');
             /*check that this was a valid string*/
             if (is_array($arr1)) {
                 /*then catch the first ']'*/
                 $first = $arr1[0];
                 unset($arr1[0]);
                 $arr2 = explode('[', $first);
                 /*and put the arrays together*/
                 $arr1 = ArrayUtility::merge($arr2, $arr1);
                 /*now get rid of a trailing ']'*/
                 if (ArrayUtility::lastElement($arr1) == ']') {
                     unset($arr1[(int) (count($arr1) - 1)]);
                 }
                 /*and a trailing ']' if there is one*/
                 $arr1[count($arr1) - 1] = str_replace(']', '', ArrayUtility::lastElement($arr1));
             }
         } else {
             if ($return_array) {
                 $arr1 = array($string);
             }
         }
     }
     return $arr1;
 }
 /**
  * Add a number of fields to insert
  *
  * Calling this method has the identical result to calling 
  * insertField multiple times without passing in a value. This is
  * used when constructing an insert query that will insert multiple
  * values for each field in combination with the addValue method
  * @param fields    - array of field names that you wish to insert
  *                    using this query.
  * @access public
  */
 function insertFields($fields)
 {
     $this->fields = ArrayUtility::merge($this->fields, $fields);
 }