Ejemplo n.º 1
0
/**
 * Quick solution to include proprietary or sensitive content for the production
 * build, such as PayPal, advertising, and so on. Some of these are viewable in
 * the public site html source, but are better left out of the Open Source
 * repository to avoid misuse of tracking ids, emails and so on.
 * 
 * If the asset to include is not found, a box displays a message instead.
 * 
 * Those assets use a file naming pattern excluded from commits (.gitignore)
 * 
 * TODO: find way to handle a "production site" branch, instead of run time mode.
 * 
 * @author  Fabrice Denis
 */
function get_local_content($fromTemplate, $assetName)
{
    ob_start();
    if (coreConfig::get('koohii_build')) {
        $assetFile = '__' . $assetName . 'View.php';
        $assetPath = dirname(realpath($fromTemplate));
        $file = $assetPath . DIRECTORY_SEPARATOR . $assetFile;
        if (file_exists($file)) {
            // render as a partial so we have access to the default template variables
            $view = new coreView(coreContext::getInstance());
            $view->setTemplate($file);
            echo $view->render();
        } else {
            echo <<<EOD
<div style="background:red;color:yellow;padding:10px;">
koohii_build content NOT FOUND: <strong>{$assetName}</strong>
</div>
EOD;
        }
    } else {
        // show a little box with the name of the local asset
        echo <<<EOD
<div style="border-radius:5px;-moz-border-radius:5px;border:none;background:#b2d2e3;color:#42697e;padding:10px;margin:0 0 1em;">
Public site content: <strong>{$assetName}</strong>
</div>
EOD;
    }
    return ob_get_clean();
}
Ejemplo n.º 2
0
/**
 * uiChartVs
 * 
 * Options:
 *   labelLeft, labelRight   Labels on each side
 * 	 valueLeft, valueRight   Values, will be summed up to calculate percentage
 *   labelLeftMax            Label to use when value of the other side is 0 (OPTIONAL)
 *   labelRightMax
 * 
 * @see /doc/slicing/RevTK/charts/uiChartVs.html
 */
function ui_chart_vs(array $options)
{
    $valueTotal = $options['valueLeft'] + $options['valueRight'];
    $pctLeft = ceil($options['valueLeft'] * 100 / $valueTotal);
    $pctRight = 100 - $pctLeft;
    $captionLeft = isset($options['labelLeftMax']) && $options['valueRight'] == 0 ? $options['labelLeftMax'] : $options['labelLeft'];
    $captionRight = isset($options['labelRightMax']) && $options['valueLeft'] == 0 ? $options['labelRightMax'] : $options['labelRight'];
    $options = array_merge($options, array('pctLeft' => $pctLeft, 'pctRight' => $pctRight, 'bZeroLeft' => $pctLeft == 0, 'bZeroRight' => $pctRight == 0, 'captionLeft' => $captionLeft, 'captionRight' => $captionRight));
    $view = new coreView(coreContext::getInstance());
    $view->getParameterHolder()->add($options);
    $view->setTemplate(dirname(__FILE__) . '/templates/ui_chart_vs.php');
    return $view->render();
}
Ejemplo n.º 3
0
/**
 * Returns HTML code for a uiWindow.
 * 
 * @uses   jquery, jquery UI/Draggable
 * @uses   ui_box_rounded() for the window border
 * 
 * @param  string  $content  HTML content for the uiWindow div.window-body
 * @param  array   $options  Tag attributes as for tag() helper (to set id, etc)
 *                           Classes can be set, "uiWindow" class is merged
 * 
 * @return string  HTML code
 */
function ui_window($content = '', $options = array())
{
    // add uiWindow class
    $options['class'] = _merge_class_names(isset($options['class']) ? $options['class'] : array(), array('uiWindow'));
    $view = new coreView(coreContext::getInstance());
    $view->getParameterHolder()->add(array('content' => $content, 'options' => $options));
    $view->setTemplate(dirname(__FILE__) . '/templates/ui_window.php');
    return $view->render();
}
Ejemplo n.º 4
0
/**
 * Evaluates and returns a component.
 * The syntax is similar to the one of include_component.
 *
 * <b>Example:</b>
 * <code>
 *  echo get_component('mymodule', 'mypartial', array('myvar' => 12345));
 * </code>
 *
 * @param  string module name
 * @param  string component name
 * @param  array variables to be made accessible to the component
 * @return string result of the component execution
 * @see    include_component
 */
function get_component($moduleName, $componentName, $vars = array())
{
    $context = coreContext::getInstance();
    $actionName = '_' . $componentName;
    $allVars = _call_component($moduleName, $componentName, $vars);
    if (!is_null($allVars)) {
        // render
        $view = new coreView($context, $moduleName, $actionName, '');
        //      $view->getParameterHolder()->add($vars);
        $view->getParameterHolder()->add($allVars);
        return $view->render();
    }
}