function smarty_function_admin_relations($params = array(), &$smarty)
{
    require_once $smarty->_get_plugin_filepath('function', 'admin_link');
    $relations = array('parent' => 'edit ', 'children' => 'add/edit ');
    $object = null;
    $wrap = false;
    $links = array();
    $output = '';
    foreach ($params as $_key => $_value) {
        ${$_key} = $_value;
    }
    if (empty($object)) {
        $smarty->trigger_error("admin_relations: missing 'object' parameter", E_USER_NOTICE);
        return;
    }
    // cycle relations
    foreach ($relations as $relation_name => $relation_prefix) {
        // cycle object's 'get_' variables
        $i = 0;
        foreach ($object->{'get_' . $relation_name} as $model_name => $model_params) {
            AppModel::RelationNameParams($model_name, $model_params);
            // get controller
            $controller = Globe::Init($model_name, 'controller');
            // TODO replace by ::singleton, find others
            // action & text
            switch ($relation_name) {
                case 'parent':
                    $action = ($model = object_get($object, $model_name)) ? 'edit' . DS . $model->id : null;
                    $text = ucwords(AppInflector::titleize($model_name));
                    $image = 'page_white_edit';
                    break;
                case 'children':
                    $prefix = $i == 0 ? '' : AppInflector::tableize(get_class($object)) . '_id=';
                    $action = '?filter=' . $prefix . $object->id;
                    $text = ucwords(AppInflector::pluralize(AppInflector::titleize($model_name)));
                    $image = 'magnifier';
                    break;
                default:
                    $action = '';
                    $text = AppInflector::titleize($model_name);
                    $image = 'magnifier';
                    break;
            }
            // build link
            $links[] = smarty_function_admin_link(array('controller' => AppInflector::fileize(get_class($controller), 'controller'), 'action' => $action, 'text' => "<span>{$relation_prefix}{$text}</span>" . ' <img src="/assets/images/admin/silk/' . $image . '.png" width="16" height="16">'), $smarty);
            $i++;
        }
    }
    foreach ($links as $link) {
        $output .= "<li>{$link}</li>\n";
    }
    if ($wrap) {
        $output = '<ul class="relations">' . $output . '</ul>';
    }
    return $output;
}
Example #2
0
function smarty_modifier_textile($string, $lite = false, $restricted = false)
{
    if (!isset($string) || $string === '') {
        return $string;
    } else {
        Globe::Load('Textile/library/Vendor/Textile', 'package');
        $textile = new Textile();
        return $restricted ? $textile->TextileRestricted($string, $lite) : $textile->TextileThis($string, $lite);
    }
}
Example #3
0
function template_handler($resource_type, $resource_name, &$source_content, &$source_timestamp, &$smarty)
{
    if ($filepath = Globe::Find($resource_name, array(APP_ROOT . SMARTY_TEMPLATE_DIR . DS, ENDO_ROOT . SMARTY_TEMPLATE_DIR . DS))) {
        return set_resource($filepath, &$source_content, &$source_timestamp, &$smarty);
    } else {
        // not found. set error...
        Error::Set("Template '" . Globe::CleanDir($filepath) . "' not found!");
        return false;
    }
}
Example #4
0
 public function get_parent_obj()
 {
     if (!$this->parent_obj && $this->parent) {
         $this->parent_obj = object_get($this->root, $this->parent);
         if (!$this->parent_obj) {
             Globe::Load($this->parent, 'model');
             $this->parent_obj = $this->root->{$this->parent} = $this->root->find_parent($this->parent);
         }
     }
     return $this->parent_obj;
 }
Example #5
0
function smarty_function_for_layout($params, $content, &$smarty)
{
    foreach ($params as $_key => $_value) {
        switch ($_key) {
            case 'variable':
                ${$_key} = $_value;
                break;
            default:
                $smarty->trigger_error("for_layout: unknown attribute '{$_key}'");
                break;
        }
    }
    return Globe::ForLayout($assign);
}
Example #6
0
 static function Output($key = 'default', $layout = 'default')
 {
     $View = new AppView();
     if (array_key_exists($key, self::$errors)) {
         $output = '';
         foreach (self::$errors[$key] as $index => $message) {
             $View->assign('key', $key);
             $View->assign('index', $index);
             $View->assign('message', $message);
             $output .= $View->fetch(Globe::GetTemplate($layout, 'errors', Url::$data['type'])) . "\n";
         }
         unset(self::$errors[$key]);
         return $output;
     } else {
         return false;
     }
 }
Example #7
0
<?php

Globe::Load('AppUsers', 'controller');
class AdminsController extends AppUsersController
{
    var $name = 'users';
}
Example #8
0
$Controller->call_afterFilter();
// --------------------------------------------------
// Debug
// --------------------------------------------------
$debug_dump = '';
$debug_dump .= d_pre('Url::$data', false) . d_arr(Url::$data, false);
$debug_dump .= d_pre('$Controller->LoggedIn', false) . d_arr($Controller->LoggedIn, false);
$debug_dump .= d_pre('$Controller->filter', false) . d_arr($Controller->filter, false);
// $debug_dump .= d_pre('Error::$errors', false).d_arr(Error::$errors, false);
// $debug_dump .= d_pre('$_SESSION', false).d_arr($_SESSION, false);
// $debug_dump .= d_pre('$_SERVER', false).d_arr($_SERVER, false);
// $debug_dump .= d_pre('CONSTANTS', false).d_arr(get_constants(), false);
// --------------------------------------------------
// Output
// --------------------------------------------------
// create View
$View = new AppView();
// assign standards
$View->assign(array('id' => $Controller->name . '_' . $Controller->action, 'url' => Url::$data, 'has_errors' => Error::HasErrors(), 'debug_dump' => $debug_dump));
// assign content if no fatal
$View->assign('content', !Error::IsFatal() || DEBUG != 0 ? $Controller->output : null);
// assign case-specific
$View->assign(Globe::$variables_for_layout);
// remove junk from xml/json/...
if ($Controller->type != DEFAULT_REQUEST_TYPE) {
    $View->debugging = false;
    $View->error_reporting = false;
}
// echo
$View->display(Globe::GetTemplate($Controller->layout, 'layouts', $Controller->type));
// d_pre("execution time:".(microtime(true) - $time));
Example #9
0
<?php

Globe::Load('Setting', 'model');
class Email
{
    var $from, $to, $cc, $bcc, $subject, $message;
    var $parts = array();
    function __construct($from, $to, $include_admin = false, $options = array())
    {
        $admin = Setting::Get('admin', 'emails', true);
        if ($include_admin) {
            $to = $admin . wrap($to, ', ');
        }
        $this->from = $from ? $from : $admin;
        $this->to = $to ? $to : $admin;
        foreach ($options as $key => $value) {
            $this->{$key} = $value;
        }
    }
    function send_data($data, $subject = '[Data Send]')
    {
        return $this->send($this->build_message($data), $subject, true);
    }
    function send($message, $subject = '[Send]', $is_html = false)
    {
        $this->set_part('message', $message);
        $this->message = $this->get_part('prepends') . $this->get_part('message') . $this->get_part('appends');
        $this->subject = $subject;
        $this->build_headers(true);
        return mail($this->to, $this->subject, $this->message, $this->headers);
    }
Example #10
0
 private function _set_filter()
 {
     // filter?
     $value = Url::GetRequest('filter', null);
     // parents?
     $parents = $this->Model ? $this->Model->get_first_parent() : false;
     if (!empty($parents)) {
         $parent = $parents['key'];
         $parent_params = $parents['value'];
         AppModel::RelationNameParams($parent, $parent_params);
         $parents = add_all(AppModel::FindAllAssoc_options($parent));
     } else {
         $parents = $parent = false;
     }
     // short filter?
     if ($short = is_numeric($value)) {
         if ($parent) {
             Globe::Load($parent, 'model');
             $field = array_get($parent_params, 'foreignKey', AppInflector::tableize($parent) . '_id');
             if ($value != false) {
                 $where = "{$field}={$value}";
             } else {
                 $where = null;
             }
         } else {
             $field = $where = null;
         }
     } else {
         if (!empty($value)) {
             preg_match_all('/\\s*([^=]+)\\s*/', $value, $parts);
             // explode & trim!
             $field = array_shift($parts[0]);
             $value = implode('=', $parts[0]);
             $where = "{$field}='{$value}'";
         } else {
             $field = $where = null;
         }
     }
     $this->assign('filter', $this->filter = (object) array('short' => $short, 'where' => $where, 'field' => $field, 'value' => $value, 'parent' => $parent, 'parents' => $parents));
 }
Example #11
0
 * @author Philip Blyth
 */
require_once ENDO_ROOT . INCLUDES_DIR . 'debug.php';
require_once ENDO_ROOT . CLASSES_DIR . 'class.log.php';
require_once ENDO_ROOT . CLASSES_DIR . 'class.error.php';
require_once ENDO_ROOT . CLASSES_DIR . 'class.globe.php';
// --------------------------------------------------
// INCLUDES
// --------------------------------------------------
Globe::Load(array('endo_bootstrap', 'app_bootstrap'), 'include');
// --------------------------------------------------
// PACKAGES
// --------------------------------------------------
Globe::Load(array('MyActiveRecord/MyActiveRecord.0.4', 'Smarty/Smarty.class'), 'package');
// --------------------------------------------------
// CLASSES
// --------------------------------------------------
Globe::Load(array('log', 'endo_view', 'app_view', 'url', 'app_url'));
// --------------------------------------------------
// MODELS
// --------------------------------------------------
Globe::Load(array('endo', 'app', 'event', 'user', 'app_user', 'admin'), 'model');
// --------------------------------------------------
// CONTROLLERS
// --------------------------------------------------
Globe::Load(array('endo', 'app'), 'controller');
// --------------------------------------------------
// BEHAVIORS
// --------------------------------------------------
Globe::Load(array('endo', 'app'), STR_BEHAVIOR);
Example #12
0
 private function _detach_from_all($class)
 {
     Globe::Load($class, 'model');
     // get all objects:
     $objects = Listing::FindAll($class, true);
     // cycle listings
     foreach ($objects as $object) {
         // attach & save
         $object->detach($this);
     }
 }