/**
  * @param mixed $url
  * @return string
  */
 public static function url($url = null)
 {
     if ($url === null) {
         $http = env('HTTPS') ? 'https://' : 'http://';
         return $http . env('HTTP_HOST') . env('REQUEST_URI');
     }
     $routedUrl = $url;
     if (is_array($url)) {
         if (is_admin() || isset($url['admin']) && $url['admin'] === true) {
             if (isset($url['ajax']) && $url['ajax'] === true) {
                 $routedUrl = admin_url('admin-ajax.php');
             } else {
                 $routedUrl = get_admin_url();
             }
         } else {
             $routedUrl = get_site_url();
         }
         $routedUrl = trim($routedUrl, '/');
         $urlParams = array();
         if (isset($url['controller'])) {
             $urlParams['gummcontroller'] = $url['controller'];
         }
         if (isset($url['action'])) {
             $urlParams['action'] = GUMM_FW_PREFIX . $url['action'];
         }
         $requestParams = GummRouter::getUrlParams($url);
         foreach ($requestParams['params'] as $value) {
             $urlParams['gummparams[]'] = $value;
         }
         foreach ($requestParams['named'] as $param => $value) {
             $urlParams["gummnamed[{$param}]"] = $value;
         }
         $routedUrl .= $urlParams ? '?' . http_build_query($urlParams) : '';
     }
     return $routedUrl;
 }
Example #2
0
<?php

GummRouter::connect('custom_portfolio_cat', '/work/%pagename%/%portfolio_cat%', array('reverseRewrite' => array()));
Example #3
0
 /**
  * @param
  */
 public static function mediaUrl($url, array $options = array())
 {
     $urlPath = self::mediaUrlPath($url, $options);
     return GummRouter::url(array('admin' => false, 'controller' => 'media', 'action' => 'display', urlencode($urlPath)));
 }
 /**
  * @return string
  */
 private function getEditLink()
 {
     $link = '#';
     if ($this->editable === 'ajax') {
         $link = GummRouter::url(array('ajax' => true, 'admin' => 'true', 'controller' => 'layouts', 'action' => 'edit_layout_element', 'elementName' => $this->name, 'elementId' => $this->id(), 'postId' => $this->postId, 'model' => $this->model));
     }
     return $link;
 }
 /**
  * @param array $callback
  * @param mixed $params
  * @return void
  */
 public function requestAction($requested, $render = true)
 {
     if (!isset($requested['controller'])) {
         if (is_a($this, 'View')) {
             if (isset($this->controller)) {
                 $requested['controller'] = str_replace('_controller', '', Inflector::underscore(get_class($this->controller)));
             }
         }
     }
     if (!isset($requested['controller']) || !isset($requested['action'])) {
         return false;
     }
     $callback = GummDispatcher::getCallbackToDispatch($requested);
     if (!$callback) {
         return false;
     }
     $args = GummRouter::getUrlParams($requested);
     $params = $args['params'];
     $controller =& $callback[0];
     $controller->startupProcess();
     $return = call_user_func_array($callback, $params);
     if ($render === false) {
         ob_start();
         $controller->shutdownProcess(false);
         $return = ob_get_clean();
     } else {
         $controller->shutdownProcess(false);
     }
     return $return;
 }
Example #6
0
    /**
     * @param array $options
     * @param array $attributes
     * @param array $settings
     * @return string
     */
    public function contentTabs($option, $attributes, $settings)
    {
        $settings = array_merge(array('contentTypes' => array('post', 'text'), 'additionalInputs' => array(), 'fields' => array('title', 'textarea'), 'fieldsSettings' => array(), 'tabLabel' => __('Tab', 'gummfw'), 'buttonLabel' => __('Add New Tab', 'gummfw'), 'deleteButtonLabel' => __('Delete Current Tab', 'gummfw')), $settings);
        $id = 'content-tabs-editor-' . uniqid();
        $tabs = $this->value;
        if (!$tabs) {
            $tabs = array(uniqid() => array());
        }
        $addTabUrl = GummRouter::url(array('ajax' => true, 'admin' => true, 'controller' => 'layout_elements', 'action' => 'content_tab_add', 'optionId' => $option['id'], 'modelName' => $this->model, 'inputSettings' => array('contentTypes' => $settings['contentTypes'], 'additionalInputs' => $settings['additionalInputs'], 'fields' => $settings['fields'], 'fieldsSettings' => $settings['fieldsSettings'], 'tabLabel' => $settings['tabLabel'])));
        $outputHtml = '<div id="' . $id . '" class="tabbable span12">';
        $outputHtml .= '
            <div class="bb-option-row">
                <a href="#" class="gumm-add-content-tab-inputs btn btn-success gumm-action-button" data-add-new-url="' . $addTabUrl . '" data-tab-editor="#' . $id . '"><span>' . $settings['buttonLabel'] . '</span><i class="icon-spinner icon-spin"></i></a>
            </div>';
        $outputHtml .= '<ul class="nav nav-tabs" data-tab-label="' . $settings['tabLabel'] . '">';
        $counter = 0;
        foreach ($tabs as $tabId => $tabData) {
            $liAtts = array('class' => null);
            if ($counter === 0) {
                $liAtts['class'] = 'active';
            }
            $outputHtml .= '<li' . $this->_constructTagAttributes($liAtts) . '>';
            $outputHtml .= '<a href="#">' . $settings['tabLabel'] . ' #' . ($counter + 1) . '</a>';
            $outputHtml .= '</li>';
            $counter++;
        }
        $outputHtml .= '</ul>';
        $outputHtml .= '<div class="tabbed-inputs bb-option-row">';
        $counter = 0;
        foreach ($tabs as $tabId => $tabData) {
            $divAtts = array();
            if ($counter !== 0) {
                $divAtts['style'] = 'display:none;';
            }
            $outputHtml .= '<div' . $this->_constructTagAttributes($divAtts) . '>';
            $outputHtml .= $this->input($this->model, array('id' => $option['id'] . '.' . $tabId, 'name' => '', 'type' => 'content-tab'), array('value' => $tabData), array('contentTypes' => $settings['contentTypes'], 'additionalInputs' => $settings['additionalInputs'], 'fields' => $settings['fields'], 'fieldsSettings' => $settings['fieldsSettings'], 'tabLabel' => $settings['tabLabel']));
            $outputHtml .= '</div>';
            $counter++;
        }
        $outputHtml .= '</div>';
        $outputHtml .= '
                <div class="bb-option-row">
                    <button type="button" class="btn btn-danger gumm-delete-content-tab" data-tab-editor="#' . $id . '">' . $settings['deleteButtonLabel'] . '</button>
                </div>';
        $outputHtml .= '</div>';
        $this->scriptBlockStart();
        ?>
        $('#<?php 
        echo $id;
        ?>
').gummTabbedInput({sortable: true});
<?php 
        $this->scriptBlockEnd();
        return $outputHtml;
        /// ===== //
        foreach ($tabs as $tabId => $tabData) {
            $outputHtml .= $this->input($this->model, array('id' => $option['id'] . '.' . $tabId, 'name' => '', 'type' => 'content-tab'), array('value' => $tabData), array('contentTypes' => $settings['contentTypes'], 'additionalInputs' => $settings['additionalInputs'], 'fields' => $settings['fields'], 'fieldsSettings' => $settings['fieldsSettings'], 'tabLabel' => $settings['tabLabel']));
        }
        $addTabUrl = GummRouter::url(array('ajax' => true, 'admin' => true, 'controller' => 'layout_elements', 'action' => 'content_tab_add', 'optionId' => $option['id'], 'modelName' => $this->model, 'inputSettings' => array('contentTypes' => $settings['contentTypes'], 'additionalInputs' => $settings['additionalInputs'], 'fields' => $settings['fields'], 'fieldsSettings' => $settings['fieldsSettings'], 'tabLabel' => $settings['tabLabel'])));
        $outputHtml .= '
            <div class="input-wrap">
                <a href="#" class="gumm-add-content-tab-inputs btn btn-success" data-add-new-url="' . $addTabUrl . '">' . $settings['buttonLabel'] . '</a>
            </div>';
        $outputHtml .= '</div>';
        return $outputHtml;
    }
 /**
  * @param array $items
  * @return array
  */
 public function prepareForQuickLaunchDisplay(array $items = array(), array $params = array())
 {
     $params = array_merge(array('items' => 'types', 'url' => array(), 'urlParams' => array(), 'contentCallback' => null, 'showContent' => true), $params);
     extract($params, EXTR_PREFIX_ALL, 'param');
     foreach ($items as &$item) {
         $item = array_merge(array('id' => uniqid(), 'contentHtml' => '', 'icon' => ''), (array) $item);
         if (isset($item[$param_items]) && $item[$param_items]) {
             $url = $param_url;
             if ($param_urlParams) {
                 foreach ($param_urlParams as $k => $v) {
                     if (isset($item[$v])) {
                         $url[$k] = $item[$v];
                     }
                 }
             }
             $item['qlItemNavigateTo'] = 'view';
             $item['qlItemAction'] = GummRouter::url($url);
             $item['qlItemContent'] = '';
         } else {
             $item['qlItemNavigateTo'] = $param_showContent ? 'content' : 'none';
             $item['qlItemAction'] = '#' . $item['id'] . '-quickLaunchContent';
             if ($params['contentCallback']) {
                 if (is_callable($params['contentCallback'])) {
                     $item['qlItemContent'] = call_user_func_array($params['contentCallback'], array($item));
                 } elseif (is_array($params['contentCallback']) && isset($params['contentCallback']['action'])) {
                     $requestAction = $params['contentCallback'];
                     $requestAction[] = $item;
                     ob_start();
                     $this->requestAction($requestAction);
                     $item['qlItemContent'] = ob_get_clean();
                 }
             }
         }
     }
     return $items;
 }
Example #8
0
 public function link($title, $url, $htmlAttributes = array(), $options = array())
 {
     $htmlAttributes = array_merge(array('class' => ''), $htmlAttributes);
     $options = array_merge(array('popup' => false, 'confirm' => false, 'ajax' => false), $options);
     if (is_array($url) && $options['popup'] == 'ajax' || $options['ajax'] === true) {
         $url['ajax'] = true;
     }
     $href = GummRouter::url($url);
     if ($options['popup']) {
         if ($options['popup'] == 'ajax') {
             $htmlAttributes['class'] .= ' gumm-open-ajax-popup';
         }
     }
     $htmlAttributes = array_merge(array('href' => $href, 'onclick' => $options['confirm'] ? 'return confirm(\'' . $options['confirm'] . '\');' : false), $htmlAttributes);
     return '<a' . $this->_constructTagAttributes($htmlAttributes) . '>' . $title . '</a>';
 }
Example #9
0
 public function getMonthLink($type)
 {
     global $wp_rewrite;
     $url = GummRouter::url();
     $date = $this->getCurrentDate();
     switch ($type) {
         case 'next':
             $date = date('Ym', strtotime(date('Ymd', strtotime($date)) . ' +1 month'));
             break;
         case 'prev':
         case 'previous':
             $date = date('Ym', strtotime(date('Ymd', strtotime($date)) . ' -1 month'));
             break;
     }
     if (strpos($url, '?') === false) {
         $url .= '?eventsdate=' . $date;
     } else {
         if (strpos($url, 'eventsdate=') !== false) {
             $url = preg_replace('|(eventsdate=)\\d{6}|im', '${1}' . $date, $url);
         } else {
             $url .= '&eventsdate=' . $date;
         }
     }
     return $url;
 }