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


PHP arr::update方法代码示例

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


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

示例1: dropdown

 public static function dropdown($data, $selected = NULL, $extra = '')
 {
     // standardize the $data as an array, strings default to the class_type
     if (!is_array($data)) {
         $data = array('name' => $data);
     }
     // add in all the defaults if they are not provided
     $data += array('nullOption' => 'Account Default');
     $data = arr::update($data, 'class', ' callid_dropdown');
     // see if the module wants to allow null selections
     if (!empty($data['nullOption'])) {
         $options = array('0' => $data['nullOption']);
     } else {
         $options = array();
     }
     unset($data['nullOption']);
     // build an array of netlists sutable for the dropdown helper
     $numbers = Doctrine_Query::create()->from('Number n')->Where('LENGTH(n.number) >= 10 ')->execute(array(), Doctrine::HYDRATE_ARRAY);
     foreach ($numbers as $number) {
         $matches = array();
         preg_match('/^\\+?1?([2-9][0-8][0-9])([2-9][0-9][0-9])([0-9]{4})$/', $number['number'], $matches);
         if (count($matches) == 4) {
             $options[$number['number_id']] = '( ' . $matches[1] . ' ) ' . $matches[2] . ' - ' . $matches[3];
         } else {
             $options[$number['number_id']] = $number['number'];
         }
     }
     return form::dropdown($data, $options, $selected, $extra);
 }
开发者ID:swk,项目名称:bluebox,代码行数:29,代码来源:callid.php

示例2: dropdownUserType

 public static function dropdownUserType($data, $selected = NULL, $extra = '')
 {
     // standardize the $data as an array, strings default to the class_type
     if (!is_array($data)) {
         $data = array('name' => $data);
     }
     // add in all the defaults if they are not provided
     $data += array('nullOption' => FALSE);
     // append or insert the class
     $data = arr::update($data, 'class', 'user_type_dropdown');
     // render a null option if its been set in data
     if (!empty($data['nullOption'])) {
         $options = array(0 => $data['nullOption']);
     } else {
         $options = array();
     }
     unset($data['nullOption']);
     $userTypes = self::getUserTypes();
     foreach ($userTypes as $userType => $displayName) {
         if ($userType <= users::getAttr('user_type')) {
             $options[$userType] = $displayName;
         }
     }
     // use kohana helper to generate the markup
     return form::dropdown($data, $options, $selected, $extra);
 }
开发者ID:swk,项目名称:bluebox,代码行数:26,代码来源:usermanager.php

示例3: dropdownCIDFormat

 public static function dropdownCIDFormat($data, $selected = NULL, $extra = '')
 {
     // standardize the $data as an array, strings default to the class_type
     if (!is_array($data)) {
         $data = array('name' => $data);
     }
     // add in all the defaults if they are not provided
     $data += array('nullOption' => FALSE);
     // append or insert the class
     $data = arr::update($data, 'class', ' sip_invite_format_dropdown');
     // render a null option if its been set in data
     if (!empty($data['nullOption'])) {
         $options = array(0 => $data['nullOption']);
     } else {
         $options = array();
     }
     unset($data['nullOption']);
     $options = Sip_Plugin::getCIDFormats();
     // use kohana helper to generate the markup
     return form::dropdown($data, $options, $selected, $extra);
 }
开发者ID:swk,项目名称:bluebox,代码行数:21,代码来源:sip.php

示例4: dropdown

 public static function dropdown($data, $selected = NULL, $extra = '', $nullOption = 'None')
 {
     // standardize the $data as an array, strings default to the class_type
     if (!is_array($data)) {
         $data = array('name' => $data);
     }
     // add in all the defaults if they are not provided
     $data += array('nullOption' => 'None');
     arr::update($data, 'class', ' voicemail_dropdown');
     // see if the module wants to allow null selections
     if (!empty($data['nullOption'])) {
         $options = array('0' => __($data['nullOption']));
     } else {
         $options = array();
     }
     unset($data['nullOption']);
     $voicemails = Doctrine::getTable('Voicemail')->findAll(Doctrine::HYDRATE_ARRAY);
     foreach ($voicemails as $voicemail) {
         $options[$voicemail['voicemail_id']] = $voicemail['name'];
     }
     return form::dropdown($data, $options, $selected, $extra);
 }
开发者ID:swk,项目名称:bluebox,代码行数:22,代码来源:vm.php

示例5: nextAvaliableLink

    public static function nextAvaliableLink($bindTo, $title = NULL, $attributes = array(), $javascript = TRUE)
    {
        if (empty($bindTo)) {
            return FALSE;
        }
        // standardize the $data as an array, strings default to the class_type
        if (!is_array($attributes)) {
            $attributes = array('id' => $attributes);
        }
        // add in all the defaults if they are not provided
        $attributes += array('id' => 'next' . $bindTo . 'Link', 'translate' => TRUE, 'jgrowl' => TRUE);
        // ensure we have our distint class
        $attributes = arr::update($attributes, 'class', ' nxt_aval_link');
        // if there is no title then use the default
        if (empty($title)) {
            $title = 'Next Avaliable Number';
        }
        // unless instructed otherwise translate this title
        if ($attributes['translate']) {
            $title = __($title);
        }
        // if the user is not going to roll their own js do it for them
        if ($javascript) {
            // if the user wants to use jgrowl make sure it will be avaliable
            if ($attributes['jgrowl']) {
                jquery::addPlugin('growl');
            }
            // generate a js script to select the next avaliable number
            $script = '    $("#' . $attributes['id'] . '").bind("click", function(e) {
                e.preventDefault();
                numberDrop = $("#' . $bindTo . '");

                selected = [];
                $(numberDrop).find("option:selected").each( function() {
                    selected[selected.length] = $(this).text();
                });

                success = false;
                $(numberDrop).find("option").each(function () {
                    text = $(this).text();
                    if (jQuery.inArray(text, selected) == -1) {
                        $(this).attr("selected", "selected");
                        $(numberDrop).trigger("change");
                        ';
            // if the user wants to use jgrowl add it to our js script
            if ($attributes['jgrowl']) {
                $script .= '$.jGrowl("' . __('Assigned number') . ' " + text, { theme: "success", life: 5000 });
                        ';
            }
            $script .= 'success = true;
                        return false;
                    }
                });
            ';
            // if the user wants to use jgrowl add it to our js script
            if ($attributes['jgrowl']) {
                $script .= 'if (!success) $.jGrowl("' . __('Unable to find an avaliable number!') . '", { theme: "error", life: 5000 });';
            }
            $script .= "\n" . '    });' . "\n";
            // put our script in the render stream
            javascript::codeBlock($script);
        }
        // dont inlcude the tranlaste in the html attributes
        unset($attributes['translate'], $attributes['jgrowl']);
        // Parsed URL
        return '<a href="#" ' . html::attributes($attributes) . '><span>' . $title . '</span></a>';
    }
开发者ID:Jaybee-,项目名称:bluebox,代码行数:67,代码来源:numbering.php

示例6: _addDefaults

 protected static function _addDefaults()
 {
     $args = func_get_args();
     $formElement = array_shift($args);
     // create a string of all default classes, with special cases
     if ($formElement == 'open_fieldset') {
         $defaultClasses = "fieldset";
     } else {
         $defaultClasses = "{$formElement}";
     }
     // all skins and other things to append custom classes
     if (array_key_exists($formElement, self::$customClasses)) {
         $custom = (array) self::$customClasses[$formElement];
         $defaultClasses .= ' ' . implode(' ', $custom);
     } else {
         if (array_key_exists('all', self::$customClasses)) {
             $custom = (array) self::$customClasses['all'];
             $defaultClasses .= ' ' . implode(' ', $custom);
         }
     }
     $defaultClasses = ' ' . strtolower($defaultClasses);
     // run the appopriate logic based on the form element
     switch ($formElement) {
         case 'open':
         case 'open_multipart':
             // create pointers to the parameters
             $action =& $args[0];
             $attr =& $args[1];
             $hidden =& $args[2];
             // if attr is not an array then make it one!
             if (!is_array($attr) || empty($attr)) {
                 // this may confuse people who are loosing the stuff so log
                 if (is_string($attr)) {
                     kohana::log('error', 'The second argument to form::' . $formElement . ' must be an array! OVERWRITING!');
                 }
                 $attr = array();
             }
             if (empty($attr['id'])) {
                 $attr['id'] = trim(preg_replace('/[^a-zA-Z_{}]+/imx', '_', url::current()), '_');
             }
             // set a default hidden field with the forms name
             if (!is_array($hidden)) {
                 $hidden = array();
             }
             $hidden += array('bluebox_form_name' => $attr['id']);
             // special cases for the forms
             if ($formElement == 'open') {
                 $defaultClasses = " form";
             } else {
                 if ($formElement == 'open_multipart') {
                     $defaultClasses = " form multipart";
                 }
             }
             // Append the classes
             $attr = arr::update($attr, 'class', $defaultClasses);
             break;
         case 'close':
             // create pointers to the parameters
             $extra =& $args[0];
             break;
         case 'label':
             // create pointers to the parameters
             $data =& $args[0];
             $text =& $args[1];
             $extra =& $args[2];
             // standardize the $data var
             if (!is_array($data)) {
                 if (is_string($data)) {
                     // Specify the input this label is for
                     $data = array('for' => $data);
                 } else {
                     // No input specified
                     $data = array();
                 }
             }
             if (!isset($data['for'])) {
                 break;
             }
             // If the element does not have an id then generate one for it
             if (!empty($data['for']) && empty($data['id'])) {
                 $data['id'] = 'label_' . trim(preg_replace('/[^a-zA-Z0-9_{}]+/imx', '_', $data['for']), '_');
             }
             // If the element this label belongs to has an error append a
             // has_error class to it
             if (!empty($data['for']) && self::_getError($data['for'])) {
                 $defaultClasses .= ' has_error';
             }
             $text = self::_i18n($text);
             // Append the classes
             $data = arr::update($data, 'class', $defaultClasses);
             break;
         case 'legend':
             // create pointers to the parameters
             $text =& $args[0];
             $data =& $args[1];
             $extra =& $args[2];
             // standardize the $data var
             $data = (array) $data;
             // if we have enough info to make an id and there is none do so
             if (!empty($text) && empty($data['id'])) {
//.........这里部分代码省略.........
开发者ID:swk,项目名称:bluebox,代码行数:101,代码来源:Bluebox_form.php

示例7: dropdown

 /**
  * Render a dropdown of users
  * 
  * Additional Data Options:
  *  nullOption = If this is a string then it is used as  the '0' option, or
  *                   if false then no such option will exist
  *
  * @param   string|array  input name or an array of HTML attributes
  * @param   string        option key that should be selected by default
  * @param   string        a string to be attached to the end of the attributes
  * @return  string
  */
 public static function dropdown($data, $selected = NULL, $extra = '')
 {
     $users = Doctrine::getTable('User')->findAll(Doctrine::HYDRATE_ARRAY);
     // standardize the $data as an array, strings default to the class_type
     if (!is_array($data)) {
         $data = array('name' => $data);
     }
     // add in all the defaults if they are not provided
     $data += array('nullOption' => FALSE);
     // see if the module wants to allow null selections
     if (!empty($data['nullOption'])) {
         $options = array('0' => $nullOption);
     } else {
         $options = array();
     }
     foreach ($users as $user) {
         $options[$user['user_id']] = $user['first_name'] . ' ' . $user['last_name'];
     }
     // set a class name to define the user dropdown
     $data = arr::update($data, 'class', ' users_dropdown');
     // unset any keys that are options for this method
     unset($data['nullOption']);
     // Render a dropdown using the form helper
     return form::dropdown($data, $options, $selected, $extra);
 }
开发者ID:swk,项目名称:bluebox,代码行数:37,代码来源:users.php


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