Beispiel #1
0
function pie_before_tool_render($params, &$result)
{
    static $prefix_was_rendered = array();
    static $temp_id = 0;
    $tool_name = $params['tool_name'];
    $pie_options = $params['pie_options'];
    $prefix = implode('_', explode('/', $tool_name)) . '_';
    $id = isset($pie_options['id']) ? $pie_options['id'] : '';
    if (!empty($id)) {
        $prefix = 'id' . $id . '_' . $prefix;
    }
    if (isset($pie_options['prefix'])) {
        $cur_prefix = $pie_options['prefix'];
    } else {
        $cur_prefix = Pie_Html::getIdPrefix();
    }
    $tool_prefix = $cur_prefix . $prefix;
    if (isset($prefix_was_rendered[$tool_prefix])) {
        trigger_error("A tool with prefix \"{$tool_prefix}\" was already rendered.", E_USER_NOTICE);
    }
    $prefix_was_rendered[$tool_prefix] = true;
    $prev_prefix = Pie_Html::pushIdPrefix($tool_prefix);
    // other parameters:
    // script, notReady, id
    $pie_prefix = $prefix;
    $result = compact('pie_prefix');
}
Beispiel #2
0
/**
 * Ticker that scrolls its contents with various speeds and pauses
 * 
 * @param $fields
 *  An associative array of fields, possibly including:
 *
 * "content_fbml" => string
 *  The FBML content of the ticker. The first top-level element
 *  should contain sub-elements, and their sizes determine where
 *  the ticker would pause between automatically scrolling.
 *  The ticker animates by scrolling its inner contents.
 * 
 * "vertical" => bool
 *  Defaults to true. If false, the ticker scrolls horizontally. 
 * 
 * "speed" => bool
 *  The scrolling speed. 
 *  This is the number of items that would scroll by in 1 second,
 *  if there were no pauses.
 *  When the speed is positive, vertical tickers scroll down, and
 *  horizontal tickers scroll to the right. New content seems to come in
 *  from the bottom (for vertical tickers) or right (for horizontal tickers)
 *  as the ticker scrolls. The element inside the ticker will start out
 *  aligned with the top side of the ticker (for vertical tickers),
 *  or the left side of the ticker (for horizontal tickers).
 *  When the speed is negative, all this faces the other way.
 * 
 * "pause_ms" => int
 *  Defaults to 2000. This is the number of milliseconds to wait
 *  after each second-level element of $content_fbml is automatically
 *  scrolled completely into view.
 *
 * "pause_ms_min" => int
 *  If set, then the number of milliseconds to pause is a random
 *  integer between $pause_ms_min and $pause_ms.
 * 
 * "scrollbars" => bool
 *  Defaults to true. If true, shows scrollbars, otherwise doesn't.
 *  (Note: this will let the user know how much content is left,
 *   and be able to see it before it would automatically scroll into view.)
 * 
 * "scrollbars_pause_ms" => int
 *  Defaults to 500. The ticker pauses its automatic scrolling when the user
 *  starts using the scrollbars. This is the number of milliseconds to wait
 *  until resuming the automatic scrolling. 
 *
 * "anim_ms" => int
 *  Defaults to 100. This is the number of milliseconds between calls to 
 *  autoScroll.
 *
 * "initial_scroll_mode" => int
 *  Defaults to 'auto'. This is the mode that scrolling starts out in.
 *  Possible values are 'auto' and 'paused'.
 * 
 * "ease" => string
 *  Optional. If set, specifies the name of the ease function
 */
function pie_tool_ticker($fields = array())
{
    $defaults = array('vertical' => true, 'speed' => 1, 'pause_ms' => 2000, 'scrollbars' => true, 'scrollbars_pause_ms' => 500, 'anim_ms' => 100);
    $fields2 = array_merge($defaults, $fields);
    if (!isset($fields2['pause_ms_min'])) {
        $fields2['pause_ms_min'] = $fields2['pause_ms'];
    }
    if (!isset($fields2['content_fbml'])) {
        $li_array = array();
        for ($i = 0; $i < 1000; ++$i) {
            $li_array[] = "<li>Missing \$content_fbml parameter. This is just example {$i}...</li>";
        }
        $default_content = implode("\n", $li_array);
        if ($fields2['vertical']) {
            $fields2['content_fbml'] = "<ul class='error'>{$default_content}</ul>";
        } else {
            $fields2['content_fbml'] = "<ul class='error'>{$default_content}</ul>";
        }
    }
    // TODO: develop one for just HTML,
    // and then check for FBML environment, instead of assuming it.
    Pie_Response::addScript('plugins/pie/fbjs/Pie.fb.js');
    Pie_Response::addScript('plugins/pie/fbjs/Ticker.fb.js');
    Pie_Response::addStylesheet('plugins/pie/css/Ticker.css');
    $direction_class = $fields2['vertical'] ? 'vertical' : 'horizontal';
    $scrollbars_class = $fields2['scrollbars'] ? 'scrollbars' : '';
    return Pie_Html::tag('div', array('id' => 'ticker', 'class' => "ticker {$direction_class} {$scrollbars_class}"), $fields2['content_fbml']);
}
Beispiel #3
0
/**
 * This is a tool for selecting photos (to possibly add)
 * @param $facebook
 *  Optional. You can provide instance of the Facebook class.
 * @param $upload
 *  Defaults to false. If true, shows an option to upload, as well.
 * @param $action_uri
 *  Defaults to 'items/addPhoto'. The URI to submit the form to.
 * @param $filter_visible
 *  Optional string. Set to 'everyone' to only display albums visible to everyone.
 * @param $on_success
 *  Optional string. The url to redirect to after a photo is added or uploaded.
 */
function items_addPhoto_tool($params)
{
    if (isset(Users::$facebook)) {
        $facebook = Users::$facebook;
    } else {
        $app = Pie_Config::expect('pie', 'app');
        if (!isset(Users::$facebooks[$app])) {
            throw new Pie_Exception_MissingObject(array('name' => 'Users::$facebooks[' . $app . ']'));
        }
        $facebook = Users::$facebooks[$app];
    }
    $defaults = array('facebook' => $facebook, 'upload' => false, 'action_uri' => 'items/addPhoto', 'on_success' => Pie_Request::url());
    extract(array_merge($defaults, $params));
    if (!$facebook instanceof Facebook) {
        throw new Pie_Exception_WrongType(array('field' => '$facebook', 'type' => 'Facebook'));
    }
    if (isset($_REQUEST['_pie']['onSuccess'])) {
        $on_success = $_REQUEST['_pie']['onSuccess'];
    }
    $sn = Pie_Session::name();
    $sid = Pie_Session::id();
    $photos = array();
    if (isset($aid)) {
        $photos = Items::facebookPhotos($facebook, $aid);
        return Pie::view('items/tool/addPhotoList.php', compact('photos'));
    }
    $facebook->require_login();
    $album_rows = Items::facebookAlbums($facebook);
    $albums = array();
    foreach ($album_rows as $ar) {
        if (isset($filter_visible) and $ar['visible'] != $filter_visible) {
            continue;
        }
        $albums[$ar['aid']] = $ar['name'];
    }
    $albums = $albums;
    if (count($album_rows)) {
        $row = reset($album_rows);
        $photos = Items::facebookPhotos($facebook, $row['aid']);
    }
    $throbber_url = Pie_Html::themedUrl('plugins/items/img/anim/throbber.gif');
    $url_json = json_encode(Pie_Uri::url($action_uri));
    Pie_Response::addStylesheet('plugins/items/css/Items.css');
    if (Pie_Request::accepts('text/fbml')) {
        Pie_Response::addScript('plugins/items/fbjs/Items.fb.js');
    } else {
        Pie_Response::addScript('plugins/items/js/Items.js');
    }
    if (is_bool($upload)) {
        $upload = uniqid('up.', false);
    }
    $addPhoto_url_json = json_encode(Pie_Uri::url('items/addPhoto'));
    Pie_Response::addScriptLine("\tPie.Items.urls['items/addPhoto'] = {$addPhoto_url_json};");
    return Pie::view('items/tool/addPhoto.php', compact('action_uri', 'on_success', 'on_added', 'albums', 'photos', 'throbber_url', 'upload'));
}
Beispiel #4
0
function pie_after_tool_render($params, &$result)
{
    $tool_name = $params['tool_name'];
    $fields = $params['fields'];
    $pie_options = $params['pie_options'];
    if (empty($pie_options['inner'])) {
        $classes = isset($pie_options['classes']) ? ' ' . $pie_options['classes'] : '';
        $p = implode('_', explode('/', $tool_name)) . '_';
        $result = "<!--\n\nstart tool {$tool_name}\n\n-->" . Pie_Html::div('tool', "pie_tool {$p}tool{$classes}") . $result . "</div><!--\n\nend tool {$tool_name} \n\n-->";
    }
    $prefix = Pie_Html::pieIdPrefix();
}
Beispiel #5
0
function users_contact_tool($params)
{
    $defaults = array('uri' => 'users/contact', 'omit' => array(), 'fields' => array(), 'title' => "Contact Info", 'collapsed' => false, 'toggle' => false, 'editing' => true, 'complete' => true, 'inProcess' => false, 'prompt' => "In order for things to work, we must be able to reach you.", 'button_content' => 'OK');
    extract(array_merge($defaults, $params));
    $default_fields = array('first_name' => array('type' => 'text', 'label' => 'First Name'), 'last_name' => array('type' => 'text', 'label' => 'Last Name'), 'email_address' => array('type' => 'text', 'label' => 'Email'));
    $fields = array_merge($default_fields, $fields);
    $user = Users::loggedInUser();
    if (!$user) {
        throw new Users_Exception_NotLoggedIn();
    }
    $email = null;
    $missing_fields = Users::accountStatus($email);
    if (isset($user->first_name)) {
        $fields['first_name']['value'] = $user->first_name;
    }
    if (isset($user->last_name)) {
        $fields['last_name']['value'] = $user->last_name;
    }
    if (isset($user->email_address)) {
        $fields['email_address']['value'] = $user->email_address;
    } else {
        if ($email) {
            $link = Pie_Html::a('#resend', array('class' => 'users_contact_tool_resend'), "You can re-send the activation email");
            switch ($email->state) {
                case 'active':
                    if ($email->user_id == $user->id) {
                        $message = "Please confirm this email address.<br>{$link}";
                    } else {
                        $message = "This email seems to belong to another user";
                    }
                    break;
                case 'suspended':
                    $message = "This address has been suspended.";
                    break;
                case 'unsubscribed':
                    $message = "The owner of this address has unsubscribed";
                    break;
                case 'unverified':
                default:
                    $message = "Not verified yet.<br>{$link}";
                    break;
            }
            $fields['email_address']['value'] = $email->address;
            $fields['email_address']['message'] = $message;
        }
    }
    $on_success = isset($_REQUEST['_pie']['onSuccess']) ? $_REQUEST['_pie']['onSuccess'] : Pie_Request::url();
    Pie_Response::addScript('plugins/users/js/Users.js');
    $form = $static = compact('fields');
    return Pie::tool('pie/panel', compact('uri', 'on_success', 'form', 'static', 'title', 'collapsed', 'toggle', 'complete', 'editing', 'inProcess', '_form_static'));
}
Beispiel #6
0
/**
 * This tool is meant to be wrapped in a <form> tag
 * @param array $params
 *  An associative array of parameters, containing:
 *  "fields" => an associative array of fieldname => fieldinfo pairs,
 *   where fieldinfo contains the following:
 *     "type" => the type of the field (@see Pie_Html::smartTag())
 *     "attributes" => additional attributes for the field input
 *     "value" => the initial value of the field input
 *     "options" => options for the field input (if type is "select", "checkboxes" or "radios")
 *     "message" => initial message, if any to put in the field's message space
 */
function pie_form_tool($params)
{
    if (empty($params['fields'])) {
        return '';
    }
    $field_defaults = array('type' => 'text', 'attributes' => array(), 'value' => null, 'options' => array(), 'message' => '');
    $tr_array = array();
    foreach ($params['fields'] as $name => $field) {
        if (!is_array($field)) {
            $name2 = '"' . addslashes($name) . '"';
            throw new Pie_Exception_WrongType(array('field' => "\$params[{$name2}]", 'type' => 'array'));
        }
        $field2 = array_merge($field_defaults, $field);
        $type = $field2['type'];
        $attributes = $field2['attributes'];
        $value = $field2['value'];
        $options = $field2['options'];
        $message = $field2['message'];
        $attributes['name'] = $name;
        if (ctype_alnum($type)) {
            if (isset($attributes['class'])) {
                if (is_array($attributes['class'])) {
                    foreach ($attributes['class'] as $k => $v) {
                        $attributes['class'][$k] .= " {$type}";
                    }
                } else {
                    $attributes['class'] .= " {$type}";
                }
            } else {
                $attributes['class'] = " {$type}";
            }
        }
        switch ($type) {
            case 'textarea':
                $tr_rest = "<td class='pie_form_fieldinput' colspan='2'>" . Pie_Html::smartTag($type, $attributes, $value, $options) . "</td></tr><tr><td class='pie_form_placeholder'>" . "</td><td class='pie_form_undermessage pie_form_textarea_undermessage' colspan='2'>" . "<div class='pie_form_undermessagebubble'>{$message}</div></td>";
                break;
            default:
                $tr_rest = "<td class='pie_form_fieldinput'>" . Pie_Html::smartTag($type, $attributes, $value, $options) . "</td><td class='pie_form_fieldmessage pie_form_{$type}_message'>{$message}</td>" . "</tr><tr><td class='pie_form_placeholder'>" . "</td><td class='pie_form_undermessage pie_form_{$type}_undermessage' colspan='2'>" . "<div class='pie_form_undermessagebubble'></div></td>";
                break;
        }
        $label = isset($field['label']) ? $field['label'] : $name;
        $name_text = Pie_Html::text($name);
        $tr_array[] = "<tr><td class='pie_form_fieldname' data-fieldname=\"{$name_text}\">{$label}</td>{$tr_rest}</tr>";
    }
    $result = "<table class='pie_form_tool_table' cellspacing='0'>\n" . implode("\n\t", $tr_array) . "\n</table>";
    Pie_Response::addScript('plugins/pie/js/PieTools.js');
    return $result;
}
Beispiel #7
0
function pie_exception($params)
{
    extract($params);
    /**
     * @var Exception $exception 
     */
    $message = $exception->getMessage();
    $file = $exception->getFile();
    $line = $exception->getLine();
    if ($is_ajax = Pie_Request::isAjax()) {
        // Render a JSON layout for ajax
        switch (strtolower($is_ajax)) {
            case 'json':
            default:
                $json = json_encode(array('errors' => Pie_Exception::toArray(array($exception))));
                $callback = Pie_Request::callback();
                echo "{$callback}({$json})";
        }
    } else {
        if (is_callable(array($exception, 'getTraceAsStringEx'))) {
            $trace_string = $exception->getTraceAsStringEx();
        } else {
            $trace_string = $exception->getTraceAsString();
        }
        if (Pie::textMode()) {
            $result = "{$message}\n" . "in {$file} ({$line})\n" . $trace_string;
        } else {
            if ($exception instanceof Pie_Exception_PhpError or !empty($exception->messageIsHtml)) {
                // do not sanitize $message
            } else {
                $message = Pie_Html::text($message);
            }
            $result = "<h1>{$message}</h1>" . "<h3>in {$file} ({$line})</h3>" . "<pre>" . $trace_string . "</pre>";
        }
        echo $result;
    }
    $app = Pie_Config::get('pie', 'app', null);
    Pie::log("{$app}: Exception in " . ceil(Pie::microtime()) . "ms\n");
    Pie::log("{$message}\n  in {$file} ({$line})");
}
Beispiel #8
0
 /**
  * Returns the HTML markup for referencing all the stylesheets added so far
  * @param string $between
  *  Optional text to insert between the <link> elements.
  * @param string $slot_name
  *  Optional. If provided, returns only the stylesheets added while filling this slot.
  * 
  * @return string the HTML markup for referencing all the stylesheets added so far 
  */
 static function stylesheets($between = '', $slot_name = null)
 {
     $stylesheets = self::stylesheetsArray($slot_name);
     if (empty($stylesheets)) {
         return '';
     }
     $tags = array();
     foreach (self::$stylesheets as $stylesheet) {
         $href = '';
         $media = 'screen, print';
         $type = 'text/css';
         extract($stylesheet, EXTR_IF_EXISTS);
         //$return .= "<style type='$type' media='$media'>@import '$href';</style>\n";
         $tags[] = Pie_Html::tag('link', array('rel' => 'stylesheet', 'type' => $type, 'href' => $href, 'media' => $media));
     }
     return implode($between, $tags);
 }
Beispiel #9
0
 private static function do_dump(&$var, $var_name = NULL, $indent = NULL, $reference = NULL, $as_text = false)
 {
     static $n = null;
     if (!isset($n)) {
         $n = Pie_Config::get('pie', 'newline', "\n");
     }
     $do_dump_indent = $as_text ? "  " : "<span style='color:#eeeeee;'>|</span> &nbsp;&nbsp; ";
     $reference = $reference . $var_name;
     $keyvar = 'the_do_dump_recursion_protection_scheme';
     $keyname = 'referenced_object_name';
     $max_indent = self::$var_dump_max_levels;
     if (strlen($indent) >= strlen($do_dump_indent) * $max_indent) {
         echo $indent . $var_name . " (...){$n}";
         return;
     }
     if (is_array($var) && isset($var[$keyvar])) {
         $real_var =& $var[$keyvar];
         $real_name =& $var[$keyname];
         $type = ucfirst(gettype($real_var));
         if ($as_text) {
             echo "{$indent}{$var_name}<{$type}> = {$real_name}{$n}";
         } else {
             echo "{$indent}{$var_name} <span style='color:#a2a2a2'>{$type}</span> = <span style='color:#e87800;'>&amp;{$real_name}</span><br>";
         }
     } else {
         $var = array($keyvar => $var, $keyname => $reference);
         $avar =& $var[$keyvar];
         $type = ucfirst(gettype($avar));
         if ($type == "String") {
             $type_color = "green";
         } elseif ($type == "Integer") {
             $type_color = "red";
         } elseif ($type == "Double") {
             $type_color = "#0099c5";
             $type = "Float";
         } elseif ($type == "Boolean") {
             $type_color = "#92008d";
         } elseif ($type == "NULL") {
             $type_color = "black";
         } else {
             $type_color = '#92008d';
         }
         if (is_array($avar)) {
             $count = count($avar);
             if ($as_text) {
                 echo "{$indent}" . ($var_name ? "{$var_name} => " : "") . "<{$type}>({$count}){$n}{$indent}({$n}";
             } else {
                 echo "{$indent}" . ($var_name ? "{$var_name} => " : "") . "<span style='color:#a2a2a2'>{$type} ({$count})</span><br>{$indent}(<br>";
             }
             $keys = array_keys($avar);
             foreach ($keys as $name) {
                 $value =& $avar[$name];
                 $display_name = is_string($name) ? "['" . addslashes($name) . "']" : "[{$name}]";
                 self::do_dump($value, $display_name, $indent . $do_dump_indent, $reference, $as_text);
             }
             if ($as_text) {
                 echo "{$indent}){$n}";
             } else {
                 echo "{$indent})<br>";
             }
         } elseif (is_object($avar)) {
             $class = get_class($avar);
             if ($as_text) {
                 echo "{$indent}{$var_name}<{$type}>[{$class}]{$n}{$indent}({$n}";
             } else {
                 echo "{$indent}{$var_name} <span style='color:{$type_color}'>{$type} [{$class}]</span><br>{$indent}(<br>";
             }
             if ($avar instanceof Exception) {
                 $code = $avar->getCode();
                 $message = addslashes($avar->getMessage());
                 echo "{$indent}{$do_dump_indent}" . "code: {$code}, message: \"{$message}\"";
                 if ($avar instanceof Pie_Exception) {
                     echo " inputFields: " . implode(', ', $avar->inputFIelds());
                 }
                 echo $as_text ? $n : "<br />";
             }
             if (class_exists('Pie_Parameters') and $avar instanceof Pie_Parameters) {
                 $getall = $avar->getAll();
                 self::do_dump($getall, "", $indent . $do_dump_indent, $reference, $as_text);
             } else {
                 if ($avar instanceof Pie_Uri) {
                     $arr = $avar->toArray();
                     self::do_dump($arr, 'fields', $indent . $do_dump_indent, $reference, $as_text);
                     self::do_dump($route_pattern, 'route_pattern', $indent . $do_dump_indent, $reference, $as_text);
                 }
             }
             if ($avar instanceof Db_Row) {
                 foreach ($avar as $name => $value) {
                     $modified = $avar->wasModified($name) ? "<span style='color:blue'>*</span>:" : '';
                     self::do_dump($value, "{$name}{$modified}", $indent . $do_dump_indent, $reference, $as_text);
                 }
             } else {
                 foreach ($avar as $name => $value) {
                     self::do_dump($value, "{$name}", $indent . $do_dump_indent, $reference, $as_text);
                 }
             }
             if ($as_text) {
                 echo "{$indent}){$n}";
             } else {
                 echo "{$indent})<br>";
             }
         } elseif (is_int($avar)) {
             $avar_len = strlen((string) $avar);
             if ($as_text) {
                 echo sprintf("{$indent}{$var_name} = <{$type}(%d)>{$avar}{$n}", $avar_len);
             } else {
                 echo sprintf("{$indent}{$var_name} = <span style='color:#a2a2a2'>{$type}(%d)</span>" . " <span style='color:{$type_color}'>{$avar}</span><br>", $avar_len);
             }
         } elseif (is_string($avar)) {
             $avar_len = strlen($avar);
             if ($as_text) {
                 echo sprintf("{$indent}{$var_name} = <{$type}(%d)> ", $avar_len), $avar, "{$n}";
             } else {
                 echo sprintf("{$indent}{$var_name} = <span style='color:#a2a2a2'>{$type}(%d)</span>", $avar_len) . " <span style='color:{$type_color}'>" . Pie_Html::text($avar) . "</span><br>";
             }
         } elseif (is_float($avar)) {
             $avar_len = strlen((string) $avar);
             if ($as_text) {
                 echo sprintf("{$indent}{$var_name} = <{$type}(%d)>{$avar}{$n}", $avar_len);
             } else {
                 echo sprintf("{$indent}{$var_name} = <span style='color:#a2a2a2'>{$type}(%d)</span>" . " <span style='color:{$type_color}'>{$avar}</span><br>", $avar_len);
             }
         } elseif (is_bool($avar)) {
             $v = $avar == 1 ? "TRUE" : "FALSE";
             if ($as_text) {
                 echo "{$indent}{$var_name} = <{$type}>{$v}{$n}";
             } else {
                 echo "{$indent}{$var_name} = <span style='color:#a2a2a2'>{$type}</span>" . " <span style='color:{$type_color}'>{$v}</span><br>";
             }
         } elseif (is_null($avar)) {
             if ($as_text) {
                 echo "{$indent}{$var_name} = NULL{$n}";
             } else {
                 echo "{$indent}{$var_name} = " . " <span style='color:{$type_color}'>NULL</span><br>";
             }
         } else {
             $avar_len = strlen((string) $avar);
             if ($as_text) {
                 echo sprintf("{$indent}{$var_name} = <{$type}(%d)>{$avar}{$n}", $avar_len);
             } else {
                 echo sprintf("{$indent}{$var_name} = <span style='color:#a2a2a2'>{$type}(%d)</span>", $avar_len) . " <span style='color:{$type_color}'>" . gettype($avar) . "</span><br>";
             }
         }
         $var = $var[$keyvar];
     }
 }
Beispiel #10
0
 /**
  * Pies the last id prefix.
  * Now all ids rendered by Pie_Html will be prefixed with the
  * id previously on top of the stack, if any.
  * @return string|null
  *  The prefix that has been pieped, if any
  */
 static function pieIdPrefix()
 {
     if (count(self::$id_prefixes) <= 1) {
         throw new Exception("Nothing to pie from prefix stack");
     }
     $pieped_prefix = array_pop(self::$id_prefixes);
     self::$id_prefix = end(self::$id_prefixes);
     return $pieped_prefix;
 }
Beispiel #11
0
echo $dashboard;
?>
 
	</div>
	<?php 
if ($notices) {
    ?>
		<div id="notices_slot">
			<?php 
    echo $notices;
    ?>
		</div>
	<?php 
}
?>
	<div id="content_slot">
		<?php 
echo $content;
?>
 
	</div>
	<br style="clear: both;">
</div>

<?php 
echo Pie_Html::script(Pie_Response::scriptLines());
echo Pie_html::script("Pie.ready();");
?>
	
</fb:fbml>
Beispiel #12
0
/**
 * This tool generates a panel with a <form> tag inside it
 * @param array $params
 *  An associative array of parameters, containing:
 *  "uri" => the uri or url the form should post to
 *  "title" => the title of the panel
 *  "complete" => boolean, indicating whether the data on the server is in a complete state
 *  "editing" => boolean, indicating whether to show the form in the "editing" state
 *  "form" => string containing the contents of the form portion of the panel
 *    which is normally generated by a "pie/form" tool
 *  "static" => string containing the contents of the "static" portion
 *  "collapsed" => defaults to false. Whether the panel is shown as collapsed into just the header
 *  "toggle" => defaults to false. The events that cause toggling of collapsed state.
 *    If the string is 'click' then toggles the panel on clicks.
 *    If the string is 'move' then toggles the panel on mouseenter/mouseleave.
 *  "edit_button" => optional, to override the edit button
 *  "save_button" => optional, to override the save button
 *  "cancel_button" => optional, to override the cancel button
 *  "panel_classes" => optional, additional classes for the panel
 *  "snf" => optional. The name of the nonce field in the session
 *  "on_success" => optional. The URI to redirect to on success
 *  "on_errors" => optional. The URI to display if errors occur
 *  "inProcess" => optional. Causes the panel to appear as if it's a step in a process.
 */
function pie_panel_tool($params)
{
    foreach (array('title', 'complete', 'editing', 'static', 'form') as $f) {
        if (!array_key_exists($f, $params)) {
            throw new Pie_Exception_RequiredField(array('field' => '$' . $f));
        }
    }
    $defaults = array('edit_button' => "<button type='submit' class='basic16 basic16_edit pie_panel_tool_edit'>edit</button>", 'save_button' => "<button type='submit' class='basic16 basic16_check pie_panel_tool_save'>save</button>", 'cancel_button' => "<button type='reset' class='basic16 basic16_cancel pie_panel_tool_cancel'>cancel</button>", 'panel_classes' => '', 'uri' => null, 'collapsed' => false, 'toggle' => false, 'inProcess' => false, 'on_success' => null, 'on_errors' => null, 'snf' => null);
    extract(array_merge($defaults, $params));
    $more_class = $params['complete'] ? 'pie_panel_tool_complete' : 'pie_panel_tool_incomplete';
    $panel_classes = "{$more_class} {$panel_classes}";
    $title_div = "<div class='pie_panel_tool_title'>{$title}</div>";
    if ($uri) {
        $header = "<div class='pie_panel_tool_buttons'>{$save_button}{$cancel_button}{$edit_button}</div>{$title_div}";
    } else {
        $header = $title_div;
    }
    // Whether to display the panel one way or the other
    if ($inProcess) {
        $header = $title_div;
        if (is_array($form)) {
            $form['fields']['_pie_buttons'] = array('type' => 'buttons', 'label' => '', 'options' => array('continue' => 'Continue'), 'attributes' => array('class' => 'basic32 basic32_right', 'type' => 'submit'));
        } else {
            $form .= "<div class='pie_panel_tool_formbuttons'><button type='submit' class='pie_panel_tool_continue basic32 basic32_right' value='continue'>Continue</button></div>";
        }
    }
    // Turn the static into a string, if it's an array
    // This currently doesn't work well, because it causes
    // a bug where the outer form is submitted twice.
    if (is_array($static)) {
        foreach ($static['fields'] as $k => $f) {
            if (Pie::ifset($static['fields'][$k]['type'])) {
                switch ($static['fields'][$k]['type']) {
                    case 'textarea':
                        $static['fields'][$k]['value'] = str_replace("\n", "<br>", $static['fields'][$k]['value']);
                        break;
                    case 'date':
                        if (!isset($static['fields'][$k]['options']['date'])) {
                            $static['fields'][$k]['options']['date'] = "M j, Y";
                        }
                        break;
                    case 'buttons':
                        unset($static['fields'][$k]);
                }
            }
            $static['fields'][$k]['type'] = 'static';
        }
        $static = Pie::tool('pie/form', $static, array('id' => 'static'));
    }
    // Turn the form into a form
    if (is_array($form)) {
        $form = Pie::tool('pie/form', $form);
    }
    // Build the panel
    $panel = "<div class='pie_panel_tool_header'>{$header}</div>" . "<div class='pie_panel_tool_form'>{$form}</div>";
    if (isset($snf) or isset($on_success) or isset($on_errors)) {
        $panel .= "<div>" . Pie_Html::formInfo($on_success, $on_errors, $snf) . "</div>";
    }
    if ($uri) {
        $panel = Pie_Html::form($uri, 'post', array('class' => "pie_panel_tool_panel"), $panel);
    }
    $panel .= "<div class='pie_panel_tool_static'>{$static}</div>";
    if ($editing) {
        $panel_classes .= ' pie_editing';
    }
    if ($complete) {
        $panel_classes .= ' pie_complete';
    }
    if ($collapsed) {
        $panel_classes .= ' pie_collapsed';
    }
    if ($toggle === 'click') {
        $panel_classes .= ' pie_panel_tool_toggle_onclick';
    }
    if ($toggle === 'move') {
        $panel_classes .= ' pie_panel_tool_toggle_move';
    }
    Pie_Response::addScript('plugins/pie/js/PieTools.js');
    Pie_Response::addStylesheet('plugins/pie/css/Ui.css');
    if (isset($_form_static)) {
        Pie_Response::setSlot('form', $form);
        Pie_Response::setSlot('static', $static);
    }
    return "<div class='pie_panel_tool_container {$panel_classes}'>{$panel}</div>";
}
Beispiel #13
0
<div class="items_addPhoto_tool_photos_list">
	<?php 
if ($photos) {
    ?>
		<?php 
    foreach ($photos as $photo) {
        $pid = $photo['pid'];
        echo Pie_Html::form('items/addPhoto', 'post', array('id' => 'facebook' . $pid, 'style' => 'display: inline')), Pie_Html::img($photo['src'], $photo['pid']), Pie_Html::hidden(array("src[{$pid}]" => $photo['src'], "src_width[{$pid}]" => $photo['src_width'], "src_height[{$pid}]" => $photo['src_height'], "src_small[{$pid}]" => $photo['src_small'], "src_small_width[{$pid}]" => $photo['src_small_width'], "src_small_height[{$pid}]" => $photo['src_small_height'], "src_big[{$pid}]" => $photo['src_big'], "src_big_width[{$pid}]" => $photo['src_big_width'], "src_big_height[{$pid}]" => $photo['src_big_height'], "link[{$pid}]" => $photo['link'], "caption[{$pid}]" => $photo['caption'], "object_id[{$pid}]" => $photo['object_id'])), "</form>";
    }
    ?>
	<?php 
} else {
    ?>
		<span class='pie_missing'>No photos in this album</span>
	<?php 
}
?>
</div>
Beispiel #14
0
function myApp_greeting_tool($fields)
{
    $defaults = array('greeting' => 'Default greeting');
    extract(array_merge($defaults, $fields));
    return '<h1 class="myApp_greeting_tool tool">' . Pie_Html::text($greeting) . '</h1>';
}
Beispiel #15
0
<?php

if ($verified) {
    ?>
	<?php 
    echo Pie_Html::div('tool', 'users_contact_tool fleeting panel');
    ?>
		<h3>
			Congratulations, you've verified your email, 
			<span class='email'><?php 
    echo $user->email_address;
    ?>
</span>
		</h3>
	</div>
<?php 
}
Beispiel #16
0
<?php

echo Pie_Html::div('tool', 'users_contact_tool necessary panel');
?>
 
	<?php 
echo Pie_Html::form($tool_action_url, 'post', array('class' => 'askEmail'));
?>
 
		<?php 
echo Pie_Html::formInfo($on_success, null, $snf);
?>
 
		<h3 class='prompt'>
			<?php 
echo $prompt;
?>
		</h3>
		<label for="authorized_email">your email address:</label>
		<input id="authorized_email" name="email_address" type="text" />
		<button type="submit" name="do_add" class="submit"><?php 
echo $button_content;
?>
</button>
	</form>
</div>
Beispiel #17
0
<?php

echo Pie_Html::div('tool', 'zoomer tool');
?>
</div>
Beispiel #18
0
<?php 
if ($upload) {
    echo Pie_Html::form($action_uri, 'post', array('id' => 'form', 'enctype' => 'multipart/form-data'));
    ?>
 
<?php 
    echo Pie_Html::formInfo($on_success);
    ?>
	<div class='items_addPhoto_tool_upload pie_choice'>
		<h2>Upload</h2>
		<div class="items_addPhoto_tool_certify">
			By uploading, you certify that you have the right to distribute the image and that it does not violate the Terms of Service.
		</div>
		<div class='items_addPhoto_tool_photo_uploader'>
			<!-- MAX_FILE_SIZE must precede the file input field -->
			<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
			<input type="hidden" name="uniqid" value="<?php 
    echo $upload;
    ?>
" />
			<input name="upload" type="file" 
				id="<?php 
    echo Pie_Html::getIdPrefix();
    ?>
upload" 
				class="file" accept="image/gif,image/jpeg,image/png" />
		</div>
	</div>
</form>
<?php 
}