Ejemplo n.º 1
0
 /**
  * Network Lists
  * 
  * List network lists.
  * Use the `slug` parameter to access a specific list.
  * 
  * **Examples**
  * 
  * Iterate over all lists.
  * 
  * ```jinja
  * {% for list in network.lists %}
  *     {{ list.title }}
  * {% endfor %}
  * ```
  * 
  * Access a specific list by id.
  * 
  * ```jinja
  * {{ network.lists({id: "example"}).title }}
  * ```
  * 
  * @see list
  * @accessor
  */
 public function lists($args = [])
 {
     NetworksModel\PodcastList::activate_network_scope();
     if (isset($args['id'])) {
         if ($list = NetworksModel\PodcastList::find_one_by_slug($args['id'])) {
             return new NetworksTemplate\PodcastList($list);
         }
     }
     $lists = [];
     foreach (NetworksModel\PodcastList::all() as $list) {
         $lists[] = new PodcastList($list);
     }
     NetworksModel\PodcastList::deactivate_network_scope();
     return $lists;
 }
 public function prepare_items()
 {
     // define column headers
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = false;
     $this->_column_headers = array($columns, $hidden, $sortable);
     PodcastList::activate_network_scope();
     $items = \Podlove\Modules\Networks\Model\PodcastList::all();
     PodcastList::deactivate_network_scope();
     uasort($items, function ($a, $b) {
         return strnatcmp($a->title, $b->title);
     });
     $this->items = $items;
 }
    function page()
    {
        if (isset($_GET["action"]) and $_GET["action"] == 'confirm_delete' and isset($_REQUEST['list'])) {
            PodcastList::activate_network_scope();
            $list = PodcastList::find_by_id($_REQUEST['list']);
            PodcastList::deactivate_network_scope();
            ?>
			<div class="updated">
				<p>
					<strong>
						<?php 
            echo sprintf(__('You selected to delete the list "%s". Please confirm this action.', 'podlove'), $list->title);
            ?>
					</strong>
				</p>
				<p>
					<?php 
            echo self::get_action_link($list, __('Delete list permanently', 'podlove'), 'delete', 'button');
            ?>
					<?php 
            echo self::get_action_link($list, __('Don\'t change anything', 'podlove'), 'keep', 'button-primary');
            ?>
				</p>
			</div>
			<?php 
        }
        ?>
		<div class="wrap">
			<?php 
        screen_icon('podlove-podcast');
        ?>
			<h2><?php 
        echo __('Lists', 'podlove');
        ?>
 <a href="?page=<?php 
        echo $_REQUEST['page'];
        ?>
&amp;action=new" class="add-new-h2"><?php 
        echo __('Add New', 'podlove');
        ?>
</a></h2>
			<?php 
        if (isset($_GET["action"])) {
            switch ($_GET["action"]) {
                case 'new':
                    $this->new_template();
                    break;
                case 'edit':
                    $this->edit_template();
                    break;
                default:
                    $this->view_template();
                    break;
            }
        } else {
            $this->view_template();
        }
        ?>
		</div>	
		<?php 
    }