コード例 #1
0
ファイル: class.php プロジェクト: nxtclass/NXTClass-themes
 /**
  */
 public function load_field_options()
 {
     // file extension is required
     if (strlen($this->file_extension)) {
         // check file directory
         if ($this->file_directory) {
             // locate it
             $path = ICE_Scheme::instance()->locate_file($this->file_directory);
             // find it?
             if ($path) {
                 // found the path, list files with extension
                 $images = ICE_Files::list_filtered($path, sprintf('/\\.%s$/', $this->file_extension), true);
                 // find any images?
                 if (count($images)) {
                     // options to return
                     $field_options = array();
                     // format the array
                     foreach ($images as $key => $value) {
                         // clean up key
                         $key = str_replace('.', '-', $key);
                         // value is absolute URL
                         $field_options[$key] = ICE_Files::theme_file_to_url($value);
                     }
                     // all done, return them
                     return $field_options;
                 } else {
                     throw new Exception(sprintf('No images found with the ".%s" extension', $this->file_extension));
                 }
             } else {
                 throw new Exception(sprintf('Unable to locate the "%s" path', $this->file_directory));
             }
         } else {
             throw new Exception('No file directory has been set');
         }
     } else {
         throw new Exception('No file extension has been set');
     }
 }
コード例 #2
0
 /**
  * Register all scripts
  */
 public final function register_scripts()
 {
     // check if at least one theme defined this dep
     if ($this->scheme->directives()->has(ICE_Scheme::DIRECTIVE_SCRIPT_DEPS)) {
         // get dep directives for all themes
         $script_depends = $this->scheme->directives()->get_map(ICE_Scheme::DIRECTIVE_SCRIPT_DEPS);
         // create new map so we can write to it
         $script_depends_w = new ICE_Map($script_depends);
         // start with empty stacks
         $dep_stack = new ICE_Stack();
         $dep_admin_stack = new ICE_Stack();
         // add dynamic script depends for every policy
         foreach (ICE_Policy::all() as $policy) {
             // loop through all registered components
             foreach ($policy->registry()->get_all() as $component) {
                 // push deps onto stacks
                 $component->script()->push_deps($dep_stack);
                 $component->script()->section('admin')->push_deps($dep_admin_stack);
             }
         }
         // add addtl dependancies
         $dep_map = new ICE_Map();
         $dep_map->add('@:dynamic', $dep_stack->to_array());
         $dep_map->add('@:dynamic-admin', $dep_admin_stack->to_array());
         $directive_deps = new ICE_Init_Directive('@', 'script_depends', $dep_map);
         $script_depends_w->add('@', $directive_deps, true);
         // init script depends
         $this->depends($this->scripts, $script_depends_w);
     }
     // init script action triggers
     $this->triggers($this->scripts, ICE_Scheme::DIRECTIVE_SCRIPT_ACTS, self::TRIGGER_ACTS);
     // init script condition triggers
     $this->triggers($this->scripts, ICE_Scheme::DIRECTIVE_SCRIPT_CONDS, self::TRIGGER_CONDS, 'ice_enqueue_scripts');
     foreach ($this->scripts as $handle => $config_map) {
         $this->register_script($handle, $config_map);
     }
 }
コード例 #3
0
ファイル: registry.php プロジェクト: nathan929/infinity
 /**
  * Look through POST vars for options from this registry and try to save them
  *
  * @return integer Number of options saved
  */
 public function process_form()
 {
     if (empty($_POST)) {
         return false;
     } elseif (isset($_POST[ICE_Option_Renderer::FIELD_MANIFEST])) {
         $manifest = $_POST[ICE_Option_Renderer::FIELD_MANIFEST];
         // "save only these" option names if param is set
         $save_options = !empty($_POST['option_names']) ? explode(',', $_POST['option_names']) : null;
         // do a reset if option reset param is set
         $reset_options = !empty($_POST['option_reset']) ? (bool) $_POST['option_reset'] : false;
         // keep track of how many were updated
         $save_count = 0;
         // loop through manifest options
         foreach ($manifest as $option_name) {
             // skip options that don't exist in save options if set
             if (!empty($save_options) && !in_array($option_name, $save_options)) {
                 continue;
             }
             // is this option registered?
             if ($this->has($option_name)) {
                 // get the option
                 $option = $this->get($option_name);
                 // look for option name as POST key
                 if (array_key_exists($option->property('name'), $_POST)) {
                     // reset?
                     if ($reset_options) {
                         $option->delete();
                     } else {
                         // get new value
                         $new_value = $_POST[$option->property('name')];
                         // strip slashes from new value?
                         if (is_scalar($new_value)) {
                             $new_value = stripslashes($_POST[$option->property('name')]);
                         }
                         // update it
                         $option->update($new_value);
                     }
                 } else {
                     // not in POST, delete it
                     $option->delete();
                 }
                 // increment the count
                 $save_count++;
             }
         }
         // hard refresh all scheme exports
         ICE_Scheme::instance()->exports_refresh(true);
         // done saving
         return $save_count;
     } else {
         throw new Exception('No manifest was rendered');
     }
 }
コード例 #4
0
ファイル: block.php プロジェクト: nxtclass/NXTClass-themes
?>
</p>
	<?php 
$this->load_template();
$this->render_meta();
?>
</div>
<?php 
if ($this->has_documentation()) {
    ?>
<div id="<?php 
    $this->render_name();
    ?>
-tabs-2">
	<div class="infinity-docs"><?php 
    $this->render_documentation(ICE_Scheme::instance()->theme_documentation_dirs());
    ?>
</div>
</div>
<?php 
}
if (is_admin() && 1 == constant('INFINITY_DEV_MODE')) {
    ?>
<div id="<?php 
    $this->render_name();
    ?>
-tabs-3">
	<p><?php 
    $this->render_sample_code();
    ?>
</p>
コード例 #5
0
ファイル: widgets.php プロジェクト: shads196770/cbox-theme
/**
 * Initialize widgets environment
 *
 * @package Infinity-api
 * @subpackage widgets
 */
function infinity_widgets_init()
{
    // component policy
    $widgets_policy = Infinity_Widgets_Policy::instance();
    // enable component
    ICE_Scheme::instance()->enable_component($widgets_policy);
    do_action('infinity_widgets_init');
}
コード例 #6
0
ファイル: component.php プロジェクト: shads196770/cbox-theme
 /**
  * Return absolute URL of the default image (if set)
  *
  * @return string|false
  */
 public function get_default_image_url()
 {
     // was a default set?
     if (strlen($this->default_value)) {
         // use default
         return ICE_Scheme::instance()->theme_file_url($this->config()->get('default_value')->get_theme(), $this->default_value);
     }
     // no default set
     return false;
 }
コード例 #7
0
ファイル: scheme.php プロジェクト: nathan929/infinity
/**
 * Load a template part from the scheme stack
 *
 * @package Infinity-api
 * @param string $slug The slug name for the generic template.
 * @param string $name The name of the specialised template.
 * @return boolean
 */
function infinity_get_template_part($slug, $name = null)
{
    return ICE_Scheme::instance()->get_template_part($slug, $name);
}
コード例 #8
0
ファイル: features.php プロジェクト: nxtclass/NXTClass-themes
/**
 * Initialize features environment
 *
 * @package Infinity-api
 * @subpackage features
 */
function infinity_features_init()
{
    // component policies
    $features_policy = Infinity_Features_Policy::instance();
    // enable components
    ICE_Scheme::instance()->enable_component($features_policy);
    do_action('infinity_features_init');
}
コード例 #9
0
ファイル: component.php プロジェクト: shads196770/cbox-theme
 /**
  * Return absolute path to default template
  *
  * @return string
  */
 public final function get_template_path()
 {
     // template path to return
     $template = null;
     // try to locate the template
     if ($this->template) {
         // was absolute path given?
         if (ICE_Files::path_is_absolute($this->template)) {
             // yep, use as is
             $template = $this->template;
         } else {
             // its relative, try to locate it
             $template = ICE_Scheme::instance()->locate_template($this->template);
         }
     }
     // was a template found?
     if ($template) {
         // yes! use that one
         return $template;
     } else {
         // try to locate the default template
         return $this->locate_file('template.php');
     }
 }
コード例 #10
0
ファイル: registry.php プロジェクト: nxtclass/NXTClass-themes
 /**
  * Get data by name (key)
  *
  * @param string $name Name of key to retrieve (slug)
  * @return ICE_Init_Data
  */
 public function get($name, $use_cache = true)
 {
     // use the cache?
     if (true === $use_cache) {
         // does it exist in the cache (even if null)?
         if (isset($this->__lookup_cache__[$name]) || array_key_exists($name, $this->__lookup_cache__)) {
             // yep, use cached value
             return $this->__lookup_cache__[$name];
         }
     }
     // value is null by default
     $value = null;
     // use existing data map if exists
     $theme_map = $this->item_at($name);
     // get a map?
     if ($theme_map) {
         // check for data according to theme stack
         foreach (ICE_Scheme::instance()->theme_stack() as $theme) {
             // does theme have this data key set?
             if ($theme_map->contains($theme)) {
                 // yes, grab value
                 $value = $theme_map->item_at($theme);
                 // and skip remaining themes
                 break;
             }
         }
     }
     // update cache if applicable
     if (true === $use_cache) {
         // cache toggled on, set it
         $this->__lookup_cache__[$name] = $value;
     }
     // always return looked up value
     return $value;
 }
コード例 #11
0
ファイル: component.php プロジェクト: nathan929/infinity
 /**
  */
 public function get_image_url($size = 'thumbnail')
 {
     // get the value
     $value = $this->get();
     // did we get a number?
     if (is_numeric($value) && $value >= 1) {
         // get the details
         $src = $this->get_image_src($size, $value);
         // try to return a url
         return $src ? $src[0] : false;
     } elseif (is_string($value) && strlen($value) >= 1) {
         // they must have provided an image path
         return ICE_Scheme::instance()->theme_file_url($this->config()->get('default_value')->get_theme(), $this->default_value);
     }
     return null;
 }
コード例 #12
0
ファイル: component.php プロジェクト: nathan929/infinity
 /**
  * Return absolute path to default template
  *
  * @return string
  */
 public final function get_template_path()
 {
     // template path to return
     $template = null;
     // try to locate the template
     if ($this->template) {
         $template = ICE_Scheme::instance()->locate_template($this->template);
     }
     // was a template found?
     if ($template) {
         // yes! use that one
         return $template;
     } else {
         // try to locate the default template
         return $this->locate_file('template.php');
     }
 }
コード例 #13
0
 /**
  * Return absolute path to default template
  *
  * @param integer $ancestor Number of ancestories to skip, including self
  * @return string
  */
 public final function get_template_path($ancestor = 0)
 {
     // template path to return
     $template = null;
     // try to locate the template
     if ($this->template) {
         $template = ICE_Scheme::instance()->locate_template($this->template);
     }
     // was a template found?
     if ($template) {
         // yes! use that one
         return $template;
     } else {
         // is a template part set?
         if (strlen($this->__template_part__)) {
             // yes, append it
             $filename = sprintf('template-%s.php', $this->__template_part__);
         } else {
             // no, use default
             $filename = 'template.php';
         }
         // try to locate the template
         return $this->locate_file($filename, $ancestor);
     }
 }
コード例 #14
0
ファイル: loader.php プロジェクト: nathan929/infinity
/**
 * Publish a document page
 *
 * @package Infinity
 * @subpackage dashboard
 * @param string $page Name of page to publish
 */
function infinity_dashboard_doc_publish($page = null)
{
    ICE_Loader::load('utils/docs');
    $doc = new ICE_Docs(ICE_Scheme::instance()->theme_documentation_dirs(), $page);
    $doc->set_pre_filter('infinity_dashboard_doc_filter');
    $doc->publish();
}
コード例 #15
0
ファイル: scheme.php プロジェクト: shads196770/cbox-theme
 /**
  * Return the singleton instance of the scheme
  *
  * @return ICE_Scheme
  */
 public static function instance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     return self::$instance;
 }
コード例 #16
0
ファイル: class.php プロジェクト: shads196770/cbox-theme
 /**
  */
 public function get_image_url()
 {
     // get value
     $value = $this->get();
     // has a value?
     if ($value) {
         // yep, locate path
         $path = ICE_Scheme::instance()->locate_file($this->file_directory);
         // find that dir path?
         if ($path) {
             // yep, return as url
             return ICE_Files::theme_file_to_url($path . '/' . $value);
         }
     }
     // value not set
     return null;
 }
コード例 #17
0
ファイル: sections.php プロジェクト: shads196770/cbox-theme
/**
 * Initialize sections environment
 *
 * @package Infinity-api
 * @subpackage sections
 */
function infinity_sections_init()
{
    // component policies
    $sections_policy = Infinity_Sections_Policy::instance();
    // enable component
    ICE_Scheme::instance()->enable_component($sections_policy);
    do_action('infinity_sections_init');
}
コード例 #18
0
ファイル: shortcodes.php プロジェクト: shads196770/cbox-theme
/**
 * Initialize shortcodes environment
 *
 * @package Infinity-api
 * @subpackage shortcodes
 */
function infinity_shortcodes_init()
{
    // component policy
    $shortcodes_policy = Infinity_Shortcodes_Policy::instance();
    // enable component
    ICE_Scheme::instance()->enable_component($shortcodes_policy);
    do_action('infinity_shortcodes_init');
}
コード例 #19
0
ファイル: class.php プロジェクト: shads196770/cbox-theme
    /**
     * Render values of one directive for each scheme in stack
     *
     * @param ICE_Map $directive_map
     */
    protected function render_directive(ICE_Map $directive_map)
    {
        // get the theme stack from the scheme
        $stack = ICE_Scheme::instance()->theme_stack();
        $map_last = null;
        // open list
        ?>
		<ul><?php 
        foreach ($stack as $theme) {
            if ($directive_map->contains($theme)) {
                $directive = $directive_map->item_at($theme);
                $map_child = new ICE_Map();
                $map_child->add($directive->get_name(), $directive->get_value());
                // render item
                ?>
				<li id="<?php 
                $this->render_item_id($theme);
                ?>
" class="jstree-open">
					<a><?php 
                print $theme;
                ?>
</a>
					<?php 
                $this->render_value_map($map_child, $map_last);
                ?>
				</li><?php 
                $map_last = $map_child;
                $this->render_item_id();
            } else {
                $map_last = null;
            }
        }
        ?>
		</ul><?php 
    }