예제 #1
0
    /**
     * Load meta boxes in specific position
     *
     * @param string $position Meta box position
     *
     * @return string
     */
    public function loadMetaBoxes($position)
    {
        $metaBoxHtml = [];
        foreach (HuradMetaBox::getMetaBoxes() as $metaBox) {
            if ($metaBox['position'] != $position) {
                continue;
            }
            if ($this->_View->elementExists($metaBox['plugin'] . '.' . $metaBox['element'])) {
                $this->PluginForm->pluginName = $metaBox['plugin'];
                if ($this->hasFormHelper(file_get_contents(APP . 'Plugin/' . $metaBox['plugin'] . '/View/Elements/' . $metaBox['element'] . '.ctp'))) {
                    $element = __d('hurad', 'You are not use form helper.');
                } else {
                    $element = $this->_View->element($metaBox['plugin'] . '.' . $metaBox['element'], ['prefix' => strtolower($metaBox['plugin'])]);
                }
            } else {
                $element = __d('hurad', 'Element not found: "%s"', "Elements/{$metaBox['element']}.ctp");
            }
            $metaBoxHtml[] = <<<HTML
            <div class="panel panel-default">
                <div class="panel-heading">{$metaBox['title']}</div>
                <div class="panel-body">
                    {$element}
                </div>
            </div>
HTML;
        }
        $output = implode(' ', $metaBoxHtml);
        return $output;
    }